34require
'../main.inc.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
44require_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/salaries/class/paymentsalary.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/lib/salaries.lib.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
52 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
53 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
57$langs->loadLangs(array(
"compta",
"banks",
"bills",
"users",
"salaries",
"hrm",
"trips"));
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'));
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);
123$permissiontoeditextra = $permissiontoadd;
124if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
126 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
129$upload_dir = $conf->salaries->multidir_output[$conf->entity];
137$parameters = array();
139$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
144if (empty($reshook)) {
147 $backurlforlist =
dolBuildUrl(DOL_URL_ROOT.
'/salaries/list.php');
149 if (empty($backtopage) || ($cancel && empty($id))) {
150 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
151 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
152 $backtopage = $backurlforlist;
154 $backtopage =
dolBuildUrl(DOL_URL_ROOT.
'/salaries/card.php', [
'id' => ($id > 0 ? $id :
'__ID__')]);
160 if (!empty($backtopageforcancel)) {
161 header(
"Location: ".$backtopageforcancel);
163 } elseif (!empty($backtopage)) {
164 header(
"Location: ".$backtopage);
171 $triggersendname =
'COMPANY_SENTBYMAIL';
173 $mode =
'emailfromthirdparty';
174 $trackid =
'sal'.$object->id;
175 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
179 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
183if ($action ==
'classin' && $permissiontoadd) {
185 $object->setProject($projectid);
189if ($action ==
'setlabel' && $permissiontoadd) {
196if ($action ==
'confirm_paid' && $permissiontoadd && $confirm ==
'yes') {
198 $result =
$object->setPaid($user);
201if ($action ==
'setfk_user' && $permissiontoadd) {
212if ($action ==
'reopen' && $permissiontoadd) {
215 $result =
$object->set_unpaid($user);
217 header(
'Location: '.
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' => $id]));
226if ($action ==
'setmode' && $permissiontoadd) {
235if ($action ==
'setbankaccount' && $permissiontoadd) {
243if ($action ==
'add' && empty($cancel) && $permissiontoadd) {
262 $object->type_payment = ($type_payment > 0 ? $type_payment : 0);
263 $object->fk_user_author = $user->id;
264 $object->fk_project = $projectid;
267 $fuser =
new User($db);
269 $object->salary = $fuser->salary;
272 $ret = $extrafields->setOptionalsFromPost(
null, $object);
277 if (!empty($auto_create_paiement) && empty($datep)) {
278 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DATE_PAIEMENT")),
null,
'errors');
281 if (empty($datesp) || empty($dateep)) {
282 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
286 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Employee")),
null,
'errors');
289 if (!empty($auto_create_paiement) && (empty($type_payment) || $type_payment < 0)) {
290 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PaymentMode")),
null,
'errors');
294 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount")),
null,
'errors');
298 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankAccount")),
null,
'errors');
310 if (!empty($auto_create_paiement) && !$error) {
313 $paiement->fk_salary =
$object->id;
315 $paiement->datep = $datep;
316 $paiement->datev = $datev;
317 $paiement->amounts = array(
$object->id => $amount);
318 $paiement->fk_typepayment = $type_payment;
319 $paiement->num_payment =
GETPOST(
"num_payment",
'alphanohtml');
320 $paiement->note_private =
GETPOST(
"note",
'restricthtml');
323 $paymentid = $paiement->create($user, (
int)
GETPOST(
'closepaidsalary'));
324 if ($paymentid < 0) {
332 $result = $paiement->addPaymentToBank($user,
'payment_salary',
'(SalaryPayment)',
GETPOSTINT(
'accountid'),
'',
'');
333 if (!($result > 0)) {
343 if (
GETPOST(
'saveandnew',
'alpha')) {
346 'action' =>
'create',
347 'fk_project' => $projectid,
348 'accountid' => $accountid,
354 header(
"Location: ".
dolBuildUrl($_SERVER[
'PHP_SELF'], $query));
368if ($action ==
'confirm_delete' && $permissiontodelete) {
370 $totalpaid =
$object->getSommePaiement();
372 if (empty($totalpaid)) {
378 header(
"Location: ".
dolBuildUrl(DOL_URL_ROOT.
'/salaries/list.php'));
390if ($action ==
'update' && !
GETPOST(
"cancel") && $permissiontoadd) {
393 if (empty($amount)) {
394 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Amount")),
null,
'errors');
396 } elseif (!is_numeric($amount)) {
397 setEventMessages($langs->trans(
"ErrorFieldMustBeANumeric", $langs->transnoentities(
"Amount")),
null,
'errors');
406 $result =
$object->update($user);
413if ($action ==
'confirm_clone' && $confirm !=
'yes') {
417if ($action ==
'confirm_clone' && $confirm ==
'yes' && $permissiontoadd) {
429 if (
GETPOST(
'amount',
'alphanohtml')) {
433 if (
GETPOST(
'clone_label',
'alphanohtml')) {
443 $object->datesp = $newdatestart;
454 header(
"Location: ".
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' => $id]));
470if ($action ==
'update_extras' && $permissiontoeditextra) {
473 $attribute =
GETPOST(
'attribute',
'aZ09');
476 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute);
483 $result =
$object->updateExtraField($attribute,
'SALARY_MODIFY');
491 $action =
'edit_extras';
500$form =
new Form($db);
506$title = $langs->trans(
'Salary').
" - ".
$object->ref;
507if ($action ==
'create') {
508 $title = $langs->trans(
"NewSalary");
523if ($action ==
'create' && $permissiontoadd) {
526 $pastmonthyear = $year_current;
527 if ($pastmonth == 0) {
538 $datesp =
dol_mktime(0, 0, 0, $datespmonth, $datespday, $datespyear);
539 $dateep =
dol_mktime(23, 59, 59, $dateepmonth, $dateepday, $dateepyear);
541 if (empty($datesp) || empty($dateep)) {
546 print
'<form name="salary" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'" method="POST">';
547 print
'<input type="hidden" name="token" value="'.newToken().
'">';
548 print
'<input type="hidden" name="action" value="add">';
550 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
552 if ($backtopageforcancel) {
553 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
558 if (!empty($conf->use_javascript_ajax)) {
559 print
"\n".
'<script type="text/javascript">';
561 $(document).ready(function () {
562 let onAutoCreatePaiementChange = function () {
563 if($("#auto_create_paiement").is(":checked")) {
564 $("#label_fk_account").find("span").addClass("fieldrequired");
565 $("#label_type_payment").find("span").addClass("fieldrequired");
566 $(".hide_if_no_auto_create_payment").show();
568 $("#label_fk_account").find("span").removeClass("fieldrequired");
569 $("#label_type_payment").find("span").removeClass("fieldrequired");
570 $(".hide_if_no_auto_create_payment").hide();
573 $("#radiopayment").click(function() {
574 $("#label").val($(this).data("label"));
576 $("#radiorefund").click(function() {
577 $("#label").val($(this).data("label"));
579 $("#auto_create_paiement").click(function () {
580 onAutoCreatePaiementChange();
582 onAutoCreatePaiementChange();
585 print
'</script>'.
"\n";
590 print
'<table class="border centpercent">';
593 print
'<tr><td class="titlefieldcreate">';
594 print $form->editfieldkey(
'Employee',
'fk_user',
'', $object, 0,
'string',
'', 1).
'</td><td>';
596 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->select_dolusers(
GETPOSTINT(
'fk_user'),
'fk_user', 1,
null, 0,
'',
'',
'0', 0, 0,
'employee:=:1', 0,
'',
'maxwidth300', $noactive);
601 print $form->editfieldkey(
'Label',
'label',
'', $object, 0,
'string',
'', 1).
'</td><td>';
602 print
'<input name="label" id="label" class="minwidth300" value="'.(GETPOST(
"label") ?
GETPOST(
"label") : $langs->trans(
"Salary")).
'">';
607 print $form->editfieldkey(
'DateStartPeriod',
'datesp',
'', $object, 0,
'string',
'', 1).
'</td><td>';
608 print $form->selectDate($datesp,
"datesp", 0, 0, 0,
'add');
613 print $form->editfieldkey(
'DateEndPeriod',
'dateep',
'', $object, 0,
'string',
'', 1).
'</td><td>';
614 print $form->selectDate($dateep,
"dateep", 0, 0, 0,
'add');
619 print $form->editfieldkey(
'Amount',
'amount',
'', $object, 0,
'string',
'', 1).
'</td><td>';
620 print
'<input name="amount" id="amount" class="minwidth75 maxwidth100" value="'.GETPOST(
"amount").
'"> ';
621 print
' <button class="dpInvisibleButtons datenowlink" id="updateAmountWithLastSalary" name="_useless" type="button">'.$langs->trans(
'UpdateAmountWithLastSalary').
'</a>';
629 print
'<tr><td>'.$langs->trans(
"Project").
'</td><td>';
630 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
631 print $formproject->select_projects(-1, (
string) $projectid,
'fk_project', 0, 0, 1, 1, 0, 0, 0,
'', 1);
637 print
'<td class="tdtop">'.$langs->trans(
"Comments").
'</td>';
638 print
'<td class="tdtop"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.
'">'.
GETPOST(
'note',
'restricthtml').
'</textarea></td>';
642 print
'<tr><td colspan="2"><hr></td></tr>';
646 print
'<tr><td><label for="auto_create_paiement">'.$langs->trans(
'AutomaticCreationPayment').
'</label></td>';
647 print
'<td><input id="auto_create_paiement" name="auto_create_paiement" type="checkbox" ' . (empty($auto_create_paiement) ?
'' :
'checked="checked"') .
' value="1"></td></tr>'.
"\n";
651 print
'<tr><td id="label_fk_account">';
652 print $form->editfieldkey(
'BankAccount',
'selectaccountid',
'', $object, 0,
'string',
'', 1).
'</td><td>';
653 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
654 $form->select_comptes($accountid,
"accountid", 0,
'', 1);
659 print
'<tr><td id="label_type_payment">';
660 print $form->editfieldkey(
'PaymentMode',
'selectpaymenttype',
'', $object, 0,
'string',
'', 1).
'</td><td>';
661 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
662 print $form->select_types_paiements(
GETPOST(
"paymenttype",
'aZ09'),
"paymenttype",
'');
666 print
'<tr class="hide_if_no_auto_create_payment"><td>';
667 print $form->editfieldkey(
'DatePayment',
'datep',
'', $object, 0,
'string',
'', 1).
'</td><td>';
668 print $form->selectDate((empty($datep) ?
'' : $datep),
"datep", 0, 0, 0,
'add', 1, 1);
672 print
'<tr class="hide_if_no_auto_create_payment"><td>';
673 print $form->editfieldkey(
'DateValue',
'datev',
'', $object, 0).
'</td><td>';
674 print $form->selectDate((empty($datev) ? -1 : $datev),
"datev", 0, 0, 0,
'add', 1, 1);
680 print
'<tr class="hide_if_no_auto_create_payment"><td><label for="num_payment">'.$langs->trans(
'Numero');
681 print
' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
682 print
'</label></td>';
683 print
'<td><input name="num_payment" id="num_payment" type="text" value="'.GETPOST(
"num_payment").
'"></td></tr>'.
"\n";
687 $parameters = array();
688 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
689 print $hookmanager->resPrint;
690 if (empty($reshook)) {
691 print
$object->showOptionals($extrafields,
'create');
698 print
'<div class="center">';
700 print
'<div class="hide_if_no_auto_create_payment paddingbottom">';
701 print
'<input type="checkbox" checked value="1" name="closepaidsalary" id="closepaidsalary" class="marginrightonly"><label for="closepaidsalary" class="opacitymedium">'.$langs->trans(
"ClosePaidSalaryAutomatically").
'</label>';
706 $addition_button = array(
707 'name' =>
'saveandnew',
708 'label_key' =>
'SaveAndNew',
710 print $form->buttonsSaveCancel(
"Save",
"Cancel", $addition_button);
714 print
'$( document ).ready(function() {';
715 print
'$("#updateAmountWithLastSalary").on("click", function updateAmountWithLastSalary() {
716 var fk_user = $("#fk_user").val()
717 var url = "'.DOL_URL_ROOT.
'/salaries/ajax/ajaxsalaries.php?fk_user="+fk_user;
718 console.log("We click on link to autofill salary amount url="+url);
724 console.log("Data returned: "+data);
726 if (typeof data == "object") {
727 console.log("data is already type object, no need to parse it");
730 console.log("data is type "+(typeof data));
731 item = JSON.parse(data);
733 if (item[0].key == "Amount") {
734 value = item[0].value;
735 console.log("amount returned = "+value);
737 $("#amount").val(item[0].value);
739 console.error("Error: Ajax url "+url+" has returned a null value.");
742 console.error("Error: Ajax url "+url+" has returned the wrong key.");
745 console.error("Error: Ajax url "+url+" has returned an empty page.");
751 alert("'.
dol_escape_js($langs->transnoentitiesnoconv(
"FillFieldFirst")).
'");
761 $head = salaries_prepare_head($object);
765 if ($action ===
'clone') {
766 $formquestion = array(
767 array(
'type' =>
'text',
'name' =>
'clone_label',
'label' => $langs->trans(
"Label"),
'value' => $langs->trans(
"CopyOf").
' '.
$object->label),
772 $formquestion[] = array(
'type' =>
'date',
'name' =>
'clone_date_start',
'label' => $langs->trans(
"DateStart"),
'value' => (
$object->dateep) + 86400);
774 $formquestion[] = array(
'type' =>
'date',
'name' =>
'clone_date_start',
'label' => $langs->trans(
"DateStart"),
'value' => -1);
776 $formquestion[] = array(
'type' =>
'date',
'name' =>
'clone_date_end',
'label' => $langs->trans(
"DateEnd"),
'value' => -1);
777 $formquestion[] = array(
'type' =>
'text',
'name' =>
'amount',
'label' => $langs->trans(
"Amount"),
'value' =>
price(
$object->amount),
'morecss' =>
'width100 right');
779 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneSalary',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1, 300);
782 $formconfirm .=
"<script>
783 // Buttons for start date: previous month, current month, previous week, current week
784 $('#clone_date_start').after(
785 $('<button id=\"start_prev_month\" class=\"dpInvisibleButtons\" style=\"color: var(--colortextlink);font-size: 0.8em;opacity: 0.7;margin-left:4px;\" type=\"button\">".$langs->trans(
'PreviousMonthShort').
"</button>')
786 .add('<button id=\"start_curr_month\" class=\"dpInvisibleButtons\" style=\"color: var(--colortextlink);font-size: 0.8em;opacity: 0.7;margin-left:4px;\" type=\"button\">".$langs->trans(
'CurrentMonthShort').
"</button>')
790 .add('<button id=\"start_prev_week\" class=\"dpInvisibleButtons\" style=\"color: var(--colortextlink);font-size: 0.8em;opacity: 0.7;margin-left:4px;\" type=\"button\">".$langs->trans(
'PreviousWeekShort').
"</button>')
791 .add('<button id=\"start_curr_week\" class=\"dpInvisibleButtons\" style=\"color: var(--colortextlink);font-size: 0.8em;opacity: 0.7;margin-left:4px;\" type=\"button\">".$langs->trans(
'CurrentWeekShort').
"</button>')";
796 $('#start_prev_month').click(function(){
797 var now = new Date();
798 var startPrevMonth = new Date(now.getFullYear(), now.getMonth() - 1, 1);
799 setStartDate(startPrevMonth);
802 $('#start_curr_month').click(function(){
803 var now = new Date();
804 var startCurrMonth = new Date(now.getFullYear(), now.getMonth(), 1);
805 setStartDate(startCurrMonth);
808 $('#start_prev_week').click(function(){
809 var now = new Date();
810 var startPrevWeek = new Date(now.setDate(now.getDate() - now.getDay() - 7));
811 startPrevWeek.setDate(startPrevWeek.getDate() + 1);
812 setStartDate(startPrevWeek);
815 $('#start_curr_week').click(function(){
816 var now = new Date();
817 var startCurrWeek = new Date(now.setDate(now.getDate() - now.getDay() + 1));
818 setStartDate(startCurrWeek);
821 function setStartDate(date) {
822 $('#clone_date_start').val(formatDate(date, '".$langs->trans(
"FormatDateShortJavaInput").
"'));
823 $('#clone_date_startday').val(date.getDate());
824 $('#clone_date_startmonth').val(date.getMonth() + 1);
825 $('#clone_date_startyear').val(date.getFullYear());
828 // Button for end date
829 $('#clone_date_end').after($('<button id=\"fill_end_of_month\" class=\"dpInvisibleButtons\" style=\"color: var(--colortextlink);font-size: 0.8em;opacity: 0.7;margin-left:4px;\" type=\"button\">".$langs->trans(
'FillEndOfMonth').
"</button>'));
830 $('#fill_end_of_month').click(function(){
831 var clone_date_startmonth = +$('#clone_date_startmonth').val();
832 var clone_date_startyear = +$('#clone_date_startyear').val();
835 if (clone_date_startmonth && clone_date_startyear) {
836 end_date = new Date(clone_date_startyear, clone_date_startmonth, 0);
838 var currentDate = new Date();
839 var currentDay = currentDate.getDate();
840 if (currentDay <= 15) {
841 end_date = new Date(currentDate.getFullYear(), currentDate.getMonth(), 0);
843 end_date = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0);
847 $('#clone_date_end').val(formatDate(end_date,'".$langs->trans(
"FormatDateShortJavaInput").
"'));
848 $('#clone_date_endday').val(end_date.getDate());
849 $('#clone_date_endmonth').val(end_date.getMonth() + 1);
850 $('#clone_date_endyear').val(end_date.getFullYear());
855 if ($action ==
'paid') {
856 $text = $langs->trans(
'ConfirmPaySalary');
857 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'PaySalary'), $text,
"confirm_paid",
'',
'', 2);
860 if ($action ==
'delete') {
861 $text = $langs->trans(
'ConfirmDeleteSalary');
862 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id]), $langs->trans(
'DeleteSalary'), $text,
'confirm_delete',
'',
'', 2);
865 if ($action ==
'edit') {
866 print
'<form name="charge" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id,
'action' =>
'update']).
'" method="post">';
867 print
'<input type="hidden" name="token" value="'.newToken().
'">';
871 $parameters = array(
'formConfirm' => $formconfirm);
872 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
873 if (empty($reshook)) {
874 $formconfirm .= $hookmanager->resPrint;
875 } elseif ($reshook > 0) {
876 $formconfirm = $hookmanager->resPrint;
883 print
dol_get_fiche_head($head,
'card', $langs->trans(
"SalaryPayment"), -1,
'salary', 0,
'',
'', 0,
'', 1);
885 $linkback =
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/salaries/list.php', [
'restore_lastsearch_values' => 1]).(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
887 $morehtmlref =
'<div class="refidno">';
890 if ($action !=
'editlabel') {
891 $morehtmlref .= $form->editfieldkey(
"Label",
'label',
$object->label, $object, $permissiontoadd,
'string',
'', 0, 1);
892 $morehtmlref .=
$object->label;
894 $morehtmlref .= $langs->trans(
'Label').
' : ';
895 $morehtmlref .=
'<form method="post" action="'.$pageurl.
'">';
896 $morehtmlref .=
'<input type="hidden" name="action" value="setlabel">';
897 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
898 $morehtmlref .=
'<input type="text" name="label" value="'.$object->label.
'"/>';
899 $morehtmlref .=
'<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
900 $morehtmlref .=
'</form>';
904 if ($action !=
'editfk_user') {
905 if (
$object->getSommePaiement() > 0 && !empty(
$object->fk_user)) {
906 $userstatic =
new User($db);
907 $result = $userstatic->fetch(
$object->fk_user);
909 $morehtmlref .=
'<br>'.$userstatic->getNomUrl(-1);
912 $morehtmlref .=
'<br>' . $form->editfieldkey(
"",
'fk_user',
$object->label, $object, $permissiontoadd,
'string',
'', 0, 1);
914 if (!empty(
$object->fk_user)) {
915 $userstatic =
new User($db);
916 $result = $userstatic->fetch(
$object->fk_user);
918 $morehtmlref .= $userstatic->getNomUrl(-1);
926 $morehtmlref .=
'<br>';
927 $morehtmlref .=
'<form method="post" action="'.$pageurl.
'">';
928 $morehtmlref .=
'<input type="hidden" name="action" value="setfk_user">';
929 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
930 $morehtmlref .= $form->select_dolusers(
$object->fk_user,
'userid', 1);
931 $morehtmlref .=
'<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
932 $morehtmlref .=
'</form>';
935 $usercancreate = $permissiontoadd;
939 $langs->load(
"projects");
940 $morehtmlref .=
'<br>';
941 if ($usercancreate) {
942 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
943 if ($action !=
'classify') {
944 $morehtmlref .=
'<a class="editfielda" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'classify',
'id' =>
$object->id],
true).
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
946 $morehtmlref .= $form->form_project($pageurl, -1, (
string)
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
948 if (!empty(
$object->fk_project)) {
950 $proj->fetch(
$object->fk_project);
951 $morehtmlref .= $proj->getNomUrl(1);
953 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
959 $morehtmlref .=
'</div>';
961 $totalpaid =
$object->getSommePaiement();
963 $object->totalpaid = $totalpaid;
964 $object->alreadypaid = $totalpaid;
966 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref,
'', 0,
'',
'');
968 print
'<div class="fichecenter">';
969 print
'<div class="fichehalfleft">';
970 print
'<div class="underbanner clearboth"></div>';
972 print
'<table class="border centpercent tableforfield">';
974 if ($action ==
'edit') {
975 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"DateStartPeriod").
"</td><td>";
976 print $form->selectDate(
$object->datesp,
'datesp', 0, 0, 0,
'datesp', 1);
980 print
'<td class="titlefieldmiddle">' . $langs->trans(
"DateStartPeriod") .
'</td><td>';
985 if ($action ==
'edit') {
986 print
'<tr><td>'.$langs->trans(
"DateEndPeriod").
"</td><td>";
987 print $form->selectDate(
$object->dateep,
'dateep', 0, 0, 0,
'dateep', 1);
991 print
'<td>' . $langs->trans(
"DateEndPeriod") .
'</td><td>';
996 if ($action ==
'edit') {
997 print
'<tr><td class="fieldrequired">' . $langs->trans(
"Amount") .
'</td><td><input name="amount" size="10" value="' .
price(
$object->amount) .
'"></td></tr>';
999 print
'<tr><td>' . $langs->trans(
"Amount") .
'</td><td><span class="amount">' .
price(
$object->amount, 0, $langs, 1, -1, -1, $conf->currency) .
'</span></td></tr>';
1004 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1005 print $langs->trans(
'DefaultPaymentMode');
1007 if ($action !=
'editmode') {
1008 print
'<td class="right"><a class="editfielda" href="'.dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'editmode',
'id' =>
$object->id],
true).
'">'.
img_edit($langs->trans(
'SetMode'), 1).
'</a></td>';
1010 print
'</tr></table>';
1013 if ($action ==
'editmode') {
1014 $form->form_modes_reglement($pageurl, (
string)
$object->type_payment,
'mode_reglement_id');
1016 $form->form_modes_reglement($pageurl, (
string)
$object->type_payment,
'none');
1022 print
'<tr><td class="nowrap">';
1023 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
1024 print $langs->trans(
'DefaultBankAccount');
1026 if ($action !=
'editbankaccount' && $permissiontoadd) {
1027 print
'<td class="right"><a class="editfielda" href="'.dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'editbankaccount',
'id' =>
$object->id],
true).
'">'.
img_edit($langs->trans(
'SetBankAccount'), 1).
'</a></td>';
1029 print
'</tr></table>';
1031 if ($action ==
'editbankaccount') {
1032 $form->formSelectAccount($pageurl, (
string)
$object->fk_account,
'fk_account', 1);
1034 $form->formSelectAccount($pageurl, (
string)
$object->fk_account,
'none');
1041 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1047 print
'<div class="fichehalfright">';
1057 $sql =
"SELECT p.rowid, p.num_payment as num_payment, p.datep as dp, p.amount,";
1058 $sql .=
" c.code as type_code,c.libelle as paiement_type,";
1059 $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';
1060 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_salary as p";
1061 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
1062 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
1063 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as c ON p.fk_typepayment = c.id";
1064 $sql .=
", ".MAIN_DB_PREFIX.
"salary as salaire";
1065 $sql .=
" WHERE p.fk_salary = ".((int) $id);
1066 $sql .=
" AND p.fk_salary = salaire.rowid";
1067 $sql .=
" AND salaire.entity IN (".getEntity(
'tax').
")";
1068 $sql .=
" ORDER BY dp DESC";
1070 $resql = $db->query($sql);
1074 $num = $db->num_rows($resql);
1077 print
'<div class="div-table-responsive-no-min">';
1078 print
'<table class="noborder paymenttable">';
1079 print
'<tr class="liste_titre">';
1080 print
'<td>'.$langs->trans(
"RefPayment").
'</td>';
1081 print
'<td>'.$langs->trans(
"Date").
'</td>';
1082 print
'<td>'.$langs->trans(
"Type").
'</td>';
1084 print
'<td class="liste_titre right">'.$langs->trans(
'BankAccount').
'</td>';
1086 print
'<td class="right">'.$langs->trans(
"Amount").
'</td>';
1092 $bankaccountstatic =
new Account($db);
1094 $objp = $db->fetch_object($resql);
1096 $paymentsalarytemp->id = $objp->rowid;
1097 $paymentsalarytemp->ref = $objp->rowid;
1098 $paymentsalarytemp->num_payment = $objp->num_payment;
1099 $paymentsalarytemp->datep = $objp->dp;
1101 print
'<tr class="oddeven"><td>';
1102 print $paymentsalarytemp->getNomUrl(1);
1104 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'dayhour',
'tzuserrel').
"</td>\n";
1105 $labeltype = $langs->trans(
"PaymentType".$objp->type_code) !=
"PaymentType".$objp->type_code ? $langs->trans(
"PaymentType".$objp->type_code) : $objp->paiement_type;
1106 print
"<td>".$labeltype.
' '.$objp->num_payment.
"</td>\n";
1108 $bankaccountstatic->id = $objp->baid;
1109 $bankaccountstatic->ref = $objp->baref;
1110 $bankaccountstatic->label = $objp->baref;
1111 $bankaccountstatic->number = $objp->banumber;
1112 $bankaccountstatic->currency_code = $objp->bacurrency_code;
1115 $bankaccountstatic->account_number = $objp->account_number;
1118 $accountingjournal->fetch($objp->fk_accountancy_journal);
1119 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
1122 print
'<td class="right">';
1123 if ($bankaccountstatic->id) {
1124 print $bankaccountstatic->getNomUrl(1,
'transactions');
1128 print
'<td class="right nowrap amountcard">'.price($objp->amount).
"</td>\n";
1130 $totalpaid += $objp->amount;
1134 print
'<tr class="oddeven"><td><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td>';
1135 print
'<td></td><td></td><td></td><td></td>';
1139 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AlreadyPaid").
' :</td><td class="right nowrap amountcard">'.
price($totalpaid).
"</td></tr>\n";
1140 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AmountExpected").
' :</td><td class="right nowrap amountcard">'.
price(
$object->amount).
"</td></tr>\n";
1142 $resteapayer = (float)
$object->amount - $totalpaid;
1143 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
1145 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"RemainderToPay").
" :</td>";
1146 print
'<td class="right nowrap'.($resteapayer ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayer).
"</td></tr>\n";
1159 print
'<div class="clearboth"></div>';
1163 if ($action ==
'edit') {
1164 print $form->buttonsSaveCancel();
1168 $resteapayer =
price2num($resteapayer,
'MT');
1175 print
'<div class="tabsAction">'.
"\n";
1176 if ($action !=
'edit') {
1178 $parameters = array();
1179 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1180 if (empty($reshook)) {
1181 if (empty($user->socid)) {
1182 $canSendMail =
true;
1184 print
dolGetButtonAction($langs->trans(
'SendMail'),
'',
'default',
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id,
'action' =>
'presend',
'mode' =>
'init'],
true).
'#formmailbeforetitle',
'', $canSendMail);
1189 if (
$object->status == $object::STATUS_PAID && $permissiontoadd) {
1194 if (
$object->status == $object::STATUS_UNPAID && $permissiontoadd) {
1205 print
dolGetButtonAction(
'', $langs->trans(
'DoPayment'),
'default',
dolBuildUrl(DOL_URL_ROOT.
'/salaries/payment_salary.php', [
'action' =>
'create',
'id' =>
$object->id],
false),
'');
1210 if (
$object->status == $object::STATUS_UNPAID && (($resteapayer <= 0 && $object->
amount > 0) || (
$object->amount <= 0)) && $permissiontoadd) {
1215 if ($permissiontoadd) {
1219 if ($permissiontodelete && empty($totalpaid)) {
1222 print
dolGetButtonAction($langs->trans(
'DisabledBecausePayments'), $langs->trans(
'Delete'),
'default',
dolBuildUrl($_SERVER[
'PHP_SELF']).
'#',
'',
false);
1230 if (
GETPOST(
'modelselected')) {
1231 $action =
'presend';
1234 if ($action !=
'presend') {
1235 print
'<div class="fichecenter"><div class="fichehalfleft">';
1236 print
'<a name="builddoc"></a>';
1238 $includedocgeneration = 1;
1241 if ($includedocgeneration) {
1243 $relativepath = $objref.
'/'.$objref.
'.pdf';
1244 $filedir = $conf->salaries->dir_output.
'/'.$objref;
1248 $delallowed = $permissiontoadd;
1249 print $formfile->showdocuments(
'salaries', $objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
1262 print
'</div><div class="fichehalfright">';
1269 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1273 print
'</div></div>';
1277 if (
GETPOST(
'modelselected')) {
1278 $action =
'presend';
1282 $modelmail =
'salary';
1283 $defaulttopic =
'InformationMessage';
1284 $diroutput = $conf->salaries->dir_output;
1285 $trackid =
'salary'.$object->id;
1287 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
1290 $parameters = array();
1291 $reshook = $hookmanager->executeHooks(
'salaryCardTabAddMore', $parameters, $object, $action);
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage bank accounts.
Class to manage accounting journals.
Class to manage payments of salaries.
Class to manage projects.
Class to manage salary payments.
Class to manage Dolibarr users.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
dol_now($mode='gmt')
Return date for now.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolBuildUrl($url, $params=[], $addtoken=false)
Return path of url.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
if(getDolGlobalString( 'TAKEPOS_SHOW_CUSTOMER')) print $langs trans('Date')." left Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right PaymentTypeShortLIQ right SELECT p pos_change as p datep as p p num_paiement as f pf amount as amount
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.