30 require
'../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/salaries/class/paymentsalary.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/salaries.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
45 $langs->loadLangs(array(
"compta",
"banks",
"bills",
"users",
"salaries",
"hrm",
"trips"));
47 $langs->load(
"projects");
52 $action =
GETPOST(
'action',
'aZ09');
53 $cancel =
GETPOST(
'cancel',
'aZ09');
54 $backtopage =
GETPOST(
'backtopage',
'alpha');
55 $backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
58 $label =
GETPOST(
'label',
'alphanohtml');
59 $projectid = (
GETPOST(
'projectid',
'int') ?
GETPOST(
'projectid',
'int') :
GETPOST(
'fk_project',
'int'));
60 $accountid =
GETPOST(
'accountid',
'int') > 0 ?
GETPOST(
'accountid',
'int') : 0;
61 if (
GETPOSTISSET(
'auto_create_paiement') || $action ===
'add') {
62 $auto_create_paiement =
GETPOST(
"auto_create_paiement",
"int");
64 $auto_create_paiement = empty($conf->global->CREATE_NEW_SALARY_WITHOUT_AUTO_PAYMENT);
76 $childids = $user->getAllChildIds(1);
79 $extrafields->fetch_name_optionals_label($object->table_element);
82 $hookmanager->initHooks(array(
'salarycard',
'globalcard'));
84 if ($id > 0 || !empty($ref)) {
85 $object->fetch($id, $ref);
89 if (!empty($user->rights->salaries->readall)) {
92 if (!empty($user->rights->salaries->read) && $object->fk_user > 0 && in_array($object->fk_user, $childids)) {
103 $socid = $user->socid;
108 $permissiontoread = $user->rights->salaries->read;
109 $permissiontoadd = $user->rights->salaries->write;
110 $permissiontodelete = $user->rights->salaries->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
119 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
124 if (empty($reshook)) {
127 $backurlforlist = DOL_URL_ROOT.
'/salaries/list.php';
129 if (empty($backtopage) || ($cancel && empty($id))) {
130 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
131 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
132 $backtopage = $backurlforlist;
134 $backtopage = DOL_URL_ROOT.
'/salaries/card.php?id='.($id > 0 ? $id :
'__ID__');
142 if (!empty($backtopageforcancel)) {
143 header(
"Location: ".$backtopageforcancel);
145 } elseif (!empty($backtopage)) {
146 header(
"Location: ".$backtopage);
154 if ($action ==
'classin' && $user->rights->banque->modifier) {
156 $object->setProject($projectid);
160 if ($action ==
'setlabel' && $user->rights->salaries->write) {
162 $object->label = $label;
163 $object->update($user);
167 if ($action ==
'confirm_paid' && $user->rights->salaries->write && $confirm ==
'yes') {
169 $result = $object->set_paid($user);
172 if ($action ==
'setfk_user' && $user->rights->salaries->write) {
173 $result = $object->fetch($id);
175 $object->fk_user = $fk_user;
176 $object->update($user);
183 if ($action ==
'reopen' && $user->rights->salaries->write) {
184 $result = $object->fetch($id);
186 $result = $object->set_unpaid($user);
188 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
197 if ($action ==
'setmode' && $user->rights->salaries->write) {
199 $result = $object->setPaymentMethods(
GETPOST(
'mode_reglement_id',
'int'));
205 if ($action ==
'setbankaccount' && $user->rights->salaries->write) {
207 $result = $object->setBankAccount(
GETPOST(
'fk_account',
'int'));
213 if ($action ==
'add' && empty($cancel)) {
216 if (empty($datev)) $datev = $datep;
218 $type_payment =
GETPOST(
"paymenttype",
'alpha');
221 $object->accountid =
GETPOST(
"accountid",
'int') > 0 ?
GETPOST(
"accountid",
"int") : 0;
222 $object->fk_user =
GETPOST(
"fk_user",
'int') > 0 ?
GETPOST(
"fk_user",
"int") : 0;
223 $object->datev = $datev;
224 $object->datep = $datep;
225 $object->amount = $amount;
226 $object->label =
GETPOST(
"label",
'alphanohtml');
227 $object->datesp = $datesp;
228 $object->dateep = $dateep;
229 $object->note =
GETPOST(
"note",
'restricthtml');
230 $object->type_payment = ($type_payment > 0 ? $type_payment : 0);
231 $object->fk_user_author = $user->id;
232 $object->fk_project = $projectid;
235 $fuser =
new User($db);
236 $fuser->fetch(
GETPOST(
"fk_user",
"int"));
237 $object->salary = $fuser->salary;
240 $ret = $extrafields->setOptionalsFromPost(
null, $object);
245 if (!empty($auto_create_paiement) && empty($datep)) {
246 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DATE_PAIEMENT")),
null,
'errors');
249 if (empty($datesp) || empty($dateep)) {
250 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
253 if (empty($object->fk_user) || $object->fk_user < 0) {
254 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Employee")),
null,
'errors');
257 if (!empty($auto_create_paiement) && (empty($type_payment) || $type_payment < 0)) {
258 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PaymentMode")),
null,
'errors');
261 if (empty($object->amount)) {
262 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount")),
null,
'errors');
265 if (
isModEnabled(
"banque") && !empty($auto_create_paiement) && !$object->accountid > 0) {
266 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"BankAccount")),
null,
'errors');
273 $ret = $object->create($user);
278 if (!empty($auto_create_paiement) && !$error) {
281 $paiement->chid = $object->id;
282 $paiement->datepaye = $datep;
283 $paiement->datev = $datev;
284 $paiement->amounts = array($object->id=>$amount);
285 $paiement->paiementtype = $type_payment;
286 $paiement->num_payment =
GETPOST(
"num_payment",
'alphanohtml');
287 $paiement->note =
GETPOST(
"note",
'restricthtml');
290 $paymentid = $paiement->create($user, (
int)
GETPOST(
'closepaidsalary'));
291 if ($paymentid < 0) {
299 $result = $paiement->addPaymentToBank($user,
'payment_salary',
'(SalaryPayment)',
GETPOST(
'accountid',
'int'),
'',
'');
300 if (!($result > 0)) {
310 if (
GETPOST(
'saveandnew',
'alpha')) {
312 header(
"Location: card.php?action=create&fk_project=" . urlencode($projectid) .
"&accountid=" . urlencode($accountid) .
'&paymenttype=' . urlencode(
GETPOST(
'paymenttype',
'az09')) .
'&datepday=' .
GETPOST(
"datepday",
'int') .
'&datepmonth=' .
GETPOST(
"datepmonth",
'int') .
'&datepyear=' .
GETPOST(
"datepyear",
'int'));
315 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id);
326 if ($action ==
'confirm_delete') {
327 $result = $object->fetch($id);
328 $totalpaid = $object->getSommePaiement();
330 if (empty($totalpaid)) {
333 $ret = $object->delete($user);
336 header(
"Location: ".DOL_URL_ROOT.
'/salaries/list.php');
348 if ($action ==
'update' && !
GETPOST(
"cancel") && $user->rights->salaries->write) {
351 if (empty($amount)) {
352 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Amount")),
null,
'errors');
354 } elseif (!is_numeric($amount)) {
355 setEventMessages($langs->trans(
"ErrorFieldMustBeANumeric", $langs->transnoentities(
"Amount")),
null,
'errors');
358 $result = $object->fetch($id);
364 $result = $object->update($user);
371 if ($action ==
'confirm_clone' && $confirm !=
'yes') { $action =
''; }
373 if ($action ==
'confirm_clone' && $confirm ==
'yes' && ($user->rights->salaries->write)) {
380 if ($object->id > 0) {
382 $object->id = $object->ref =
null;
384 if (
GETPOST(
'clone_label',
'alphanohtml')) {
385 $object->label =
GETPOST(
'clone_label',
'alphanohtml');
387 $object->label = $langs->trans(
"CopyOf").
' '.$object->label;
390 $newdatestart =
dol_mktime(0, 0, 0,
GETPOST(
'clone_date_startmonth',
'int'),
GETPOST(
'clone_date_startday',
'int'),
GETPOST(
'clone_date_startyear',
'int'));
393 if ($newdatestart) $object->datesp = $newdatestart;
394 if ($newdateend) $object->dateep = $newdateend;
396 $id = $object->create($user);
401 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
416 if ($action ==
"update_extras" && !empty($user->rights->salaries->read)) {
417 $object->fetch(
GETPOST(
'id',
'int'));
419 $attributekey =
GETPOST(
'attribute',
'alpha');
420 $attributekeylong =
'options_'.$attributekey;
424 $object->array_options[
'options_'.$attributekey] =
dol_mktime(
GETPOST($attributekeylong.
'hour',
'int'),
GETPOST($attributekeylong.
'min',
'int'),
GETPOST($attributekeylong.
'sec',
'int'),
GETPOST($attributekeylong.
'month',
'int'),
GETPOST($attributekeylong.
'day',
'int'),
GETPOST($attributekeylong.
'year',
'int'));
427 $object->array_options[
'options_'.$attributekey] =
GETPOST($attributekeylong,
'alpha');
430 $result = $object->insertExtraFields(empty($triggermodname) ?
'' : $triggermodname, $user);
436 $action =
'edit_extras';
448 $title = $langs->trans(
'Salary').
" - ".$object->ref;
455 $result = $object->fetch($id);
463 if ($action ==
'create' && $permissiontoadd) {
465 $pastmonth = strftime(
"%m",
dol_now()) - 1;
466 $pastmonthyear = $year_current;
467 if ($pastmonth == 0) {
472 $datespmonth =
GETPOST(
'datespmonth',
'int');
473 $datespday =
GETPOST(
'datespday',
'int');
474 $datespyear =
GETPOST(
'datespyear',
'int');
475 $dateepmonth =
GETPOST(
'dateepmonth',
'int');
476 $dateepday =
GETPOST(
'dateepday',
'int');
477 $dateepyear =
GETPOST(
'dateepyear',
'int');
478 $datesp =
dol_mktime(0, 0, 0, $datespmonth, $datespday, $datespyear);
479 $dateep =
dol_mktime(23, 59, 59, $dateepmonth, $dateepday, $dateepyear);
481 if (empty($datesp) || empty($dateep)) {
485 print
'<form name="salary" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
486 print
'<input type="hidden" name="token" value="'.newToken().
'">';
487 print
'<input type="hidden" name="action" value="add">';
489 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
491 if ($backtopageforcancel) {
492 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
497 if (!empty($conf->use_javascript_ajax)) {
498 print
"\n".
'<script type="text/javascript">';
500 $(document).ready(function () {
501 let onAutoCreatePaiementChange = function () {
502 if($("#auto_create_paiement").is(":checked")) {
503 $("#label_fk_account").find("span").addClass("fieldrequired");
504 $("#label_type_payment").find("span").addClass("fieldrequired");
505 $(".hide_if_no_auto_create_payment").show();
507 $("#label_fk_account").find("span").removeClass("fieldrequired");
508 $("#label_type_payment").find("span").removeClass("fieldrequired");
509 $(".hide_if_no_auto_create_payment").hide();
512 $("#radiopayment").click(function() {
513 $("#label").val($(this).data("label"));
515 $("#radiorefund").click(function() {
516 $("#label").val($(this).data("label"));
518 $("#auto_create_paiement").click(function () {
519 onAutoCreatePaiementChange();
521 onAutoCreatePaiementChange();
524 print
'</script>'.
"\n";
529 print
'<table class="border centpercent">';
532 print
'<tr><td class="titlefieldcreate">';
533 print
$form->editfieldkey(
'Employee',
'fk_user',
'', $object, 0,
'string',
'', 1).
'</td><td>';
535 print
img_picto(
'',
'user',
'class="paddingrighonly"').$form->select_dolusers(
GETPOST(
'fk_user',
'int'),
'fk_user', 1,
'', 0,
'',
'', 0, 0, 0,
'AND employee=1', 0,
'',
'maxwidth300', $noactive);
540 print
$form->editfieldkey(
'Label',
'label',
'', $object, 0,
'string',
'', 1).
'</td><td>';
541 print
'<input name="label" id="label" class="minwidth300" value="'.(GETPOST(
"label") ?
GETPOST(
"label") : $langs->trans(
"Salary")).
'">';
546 print
$form->editfieldkey(
'DateStartPeriod',
'datesp',
'', $object, 0,
'string',
'', 1).
'</td><td>';
547 print
$form->selectDate($datesp,
"datesp",
'',
'',
'',
'add');
552 print
$form->editfieldkey(
'DateEndPeriod',
'dateep',
'', $object, 0,
'string',
'', 1).
'</td><td>';
553 print
$form->selectDate($dateep,
"dateep",
'',
'',
'',
'add');
558 print
$form->editfieldkey(
'Amount',
'amount',
'', $object, 0,
'string',
'', 1).
'</td><td>';
559 print
'<input name="amount" id="amount" class="minwidth75 maxwidth100" value="'.GETPOST(
"amount").
'"> ';
560 print
'<button class="dpInvisibleButtons datenow" id="updateAmountWithLastSalary" name="_useless" type="button">'.$langs->trans(
'UpdateAmountWithLastSalary').
'</a>';
568 print
'<tr><td>'.$langs->trans(
"Project").
'</td><td>';
569 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
570 print $formproject->select_projects(-1, $projectid,
'fk_project', 0, 0, 1, 1, 0, 0, 0,
'', 1);
576 print
'<td class="tdtop">'.$langs->trans(
"Comments").
'</td>';
577 print
'<td class="tdtop"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.
'">'.
GETPOST(
'note',
'restricthtml').
'</textarea></td>';
581 print
'<tr><td colspan="2"><hr></td></tr>';
585 print
'<tr><td><label for="auto_create_paiement">'.$langs->trans(
'AutomaticCreationPayment').
'</label></td>';
586 print
'<td><input id="auto_create_paiement" name="auto_create_paiement" type="checkbox" ' . (empty($auto_create_paiement) ?
'' :
'checked="checked"') .
' value="1"></td></tr>'.
"\n";
590 print
'<tr><td id="label_fk_account">';
591 print
$form->editfieldkey(
'BankAccount',
'selectaccountid',
'', $object, 0,
'string',
'', 1).
'</td><td>';
592 print
img_picto(
'',
'bank_account',
'class="paddingrighonly"');
593 $form->select_comptes($accountid,
"accountid", 0,
'', 1);
598 print
'<tr><td id="label_type_payment">';
599 print
$form->editfieldkey(
'PaymentMode',
'selectpaymenttype',
'', $object, 0,
'string',
'', 1).
'</td><td>';
600 $form->select_types_paiements(
GETPOST(
"paymenttype",
'aZ09'),
"paymenttype",
'');
604 print
'<tr class="hide_if_no_auto_create_payment"><td>';
605 print
$form->editfieldkey(
'DatePayment',
'datep',
'', $object, 0,
'string',
'', 1).
'</td><td>';
606 print
$form->selectDate((empty($datep) ?
'' : $datep),
"datep", 0, 0, 0,
'add', 1, 1);
610 print
'<tr class="hide_if_no_auto_create_payment"><td>';
611 print
$form->editfieldkey(
'DateValue',
'datev',
'', $object, 0).
'</td><td>';
612 print
$form->selectDate((empty($datev) ?-1 : $datev),
"datev",
'',
'',
'',
'add', 1, 1);
618 print
'<tr class="hide_if_no_auto_create_payment"><td><label for="num_payment">'.$langs->trans(
'Numero');
619 print
' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
620 print
'</label></td>';
621 print
'<td><input name="num_payment" id="num_payment" type="text" value="'.GETPOST(
"num_payment").
'"></td></tr>'.
"\n";
633 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
634 print $hookmanager->resPrint;
635 if (empty($reshook)) {
636 print $object->showOptionals($extrafields,
'create');
643 print
'<div class="center">';
645 print
'<div class="hide_if_no_auto_create_payment paddingbottom">';
646 print
'<input type="checkbox" checked value="1" name="closepaidsalary">'.$langs->trans(
"ClosePaidSalaryAutomatically");
651 $addition_button = array(
652 'name' =>
'saveandnew',
653 'label_key' =>
'SaveAndNew',
655 print
$form->buttonsSaveCancel(
"Save",
"Cancel", $addition_button);
659 print
'$( document ).ready(function() {';
660 print
'$("#updateAmountWithLastSalary").on("click", function updateAmountWithLastSalary() {
661 var fk_user = $("#fk_user").val()
662 var url = "'.DOL_URL_ROOT.
'/salaries/ajax/ajaxsalaries.php?fk_user="+fk_user;
663 console.log("We click on link to autofill salary amount url="+url);
668 console.log("Data returned: "+data);
670 if (typeof data == "object") {
671 console.log("data is already type object, no need to parse it");
674 console.log("data is type "+(typeof data));
675 item = JSON.parse(data);
677 if (item[0].key == "Amount") {
678 value = item[0].value;
679 console.log("amount returned = "+value);
681 $("#amount").val(item[0].value);
683 console.error("Error: Ajax url "+url+" has returned a null value.");
686 console.error("Error: Ajax url "+url+" has returned the wrong key.");
689 console.error("Error: Ajax url "+url+" has returned an empty page.");
695 alert("'.
dol_escape_js($langs->transnoentitiesnoconv(
"FillFieldFirst")).
'");
706 $head = salaries_prepare_head($object);
709 if ($action ===
'clone') {
710 $formquestion = array(
711 array(
'type' =>
'text',
'name' =>
'clone_label',
'label' => $langs->trans(
"Label"),
'value' => $langs->trans(
"CopyOf").
' '.$object->label),
715 $formquestion[] = array(
'type' =>
'date',
'name' =>
'clone_date_start',
'label' => $langs->trans(
"DateStart"),
'value' => -1);
716 $formquestion[] = array(
'type' =>
'date',
'name' =>
'clone_date_end',
'label' => $langs->trans(
"DateEnd"),
'value' => -1);
718 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneSalary', $object->ref),
'confirm_clone', $formquestion,
'yes', 1, 250);
721 if ($action ==
'paid') {
722 $text = $langs->trans(
'ConfirmPaySalary');
723 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
'PaySalary'), $text,
"confirm_paid",
'',
'', 2);
726 if ($action ==
'delete') {
727 $text = $langs->trans(
'ConfirmDeleteSalary');
728 $formconfirm =
$form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $langs->trans(
'DeleteSalary'), $text,
'confirm_delete',
'',
'', 2);
731 if ($action ==
'edit') {
732 print
"<form name=\"charge\" action=\"".$_SERVER[
"PHP_SELF"].
"?id=$object->id&action=update\" method=\"post\">";
733 print
'<input type="hidden" name="token" value="'.newToken().
'">';
738 $reshook = $hookmanager->executeHooks(
'formConfirm',
$parameters, $object, $action);
739 if (empty($reshook)) {
741 } elseif ($reshook > 0) {
749 print
dol_get_fiche_head($head,
'card', $langs->trans(
"SalaryPayment"), -1,
'salary');
751 $linkback =
'<a href="'.DOL_URL_ROOT.
'/salaries/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
753 $morehtmlref =
'<div class="refidno">';
756 if ($action !=
'editlabel') {
757 $morehtmlref .=
$form->editfieldkey(
"Label",
'label', $object->label, $object, $user->rights->salaries->write,
'string',
'', 0, 1);
758 $morehtmlref .= $object->label;
760 $morehtmlref .= $langs->trans(
'Label').
' : ';
761 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
762 $morehtmlref .=
'<input type="hidden" name="action" value="setlabel">';
763 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
764 $morehtmlref .=
'<input type="text" name="label" value="'.$object->label.
'"/>';
765 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
766 $morehtmlref .=
'</form>';
770 if ($action !=
'editfk_user') {
771 if ($object->getSommePaiement() > 0 && !empty($object->fk_user)) {
772 $userstatic =
new User($db);
773 $result = $userstatic->fetch($object->fk_user);
775 $morehtmlref .=
'<br>' .$langs->trans(
'Employee').
' : '.$userstatic->getNomUrl(-1);
778 $morehtmlref .=
'<br>' .
$form->editfieldkey(
"Employee",
'fk_user', $object->label, $object, $user->rights->salaries->write,
'string',
'', 0, 1);
780 if (!empty($object->fk_user)) {
781 $userstatic =
new User($db);
782 $result = $userstatic->fetch($object->fk_user);
784 $morehtmlref .= $userstatic->getNomUrl(-1);
792 $morehtmlref .=
'<br>'.$langs->trans(
'Employee').
' : ';
793 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
794 $morehtmlref .=
'<input type="hidden" name="action" value="setfk_user">';
795 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
796 $morehtmlref .=
$form->select_dolusers($object->fk_user,
'userid', 1);
797 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
798 $morehtmlref .=
'</form>';
801 $usercancreate = $permissiontoadd;
805 $langs->load(
"projects");
806 $morehtmlref .=
'<br>';
807 if ($usercancreate) {
808 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
809 if ($action !=
'classify') {
810 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
812 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
814 if (!empty($object->fk_project)) {
816 $proj->fetch($object->fk_project);
817 $morehtmlref .= $proj->getNomUrl(1);
819 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
825 $morehtmlref .=
'</div>';
827 $totalpaid = $object->getSommePaiement();
828 $object->totalpaid = $totalpaid;
830 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref,
'', 0,
'',
'');
832 print
'<div class="fichecenter">';
833 print
'<div class="fichehalfleft">';
834 print
'<div class="underbanner clearboth"></div>';
836 print
'<table class="border centpercent tableforfield">';
838 if ($action ==
'edit') {
839 print
'<tr><td class="titlefield">'.$langs->trans(
"DateStartPeriod").
"</td><td>";
840 print
$form->selectDate($object->datesp,
'datesp', 0, 0, 0,
'datesp', 1);
844 print
'<td class="titlefield">' . $langs->trans(
"DateStartPeriod") .
'</td><td>';
849 if ($action ==
'edit') {
850 print
'<tr><td>'.$langs->trans(
"DateEndPeriod").
"</td><td>";
851 print
$form->selectDate($object->dateep,
'dateep', 0, 0, 0,
'dateep', 1);
855 print
'<td>' . $langs->trans(
"DateEndPeriod") .
'</td><td>';
869 if ($action ==
'edit') {
870 print
'<tr><td class="fieldrequired">' . $langs->trans(
"Amount") .
'</td><td><input name="amount" size="10" value="' .
price($object->amount) .
'"></td></tr>';
872 print
'<tr><td>' . $langs->trans(
"Amount") .
'</td><td><span class="amount">' .
price($object->amount, 0, $langs, 1, -1, -1, $conf->currency) .
'</span></td></tr>';
877 print
'<table class="nobordernopadding" width="100%"><tr><td>';
878 print $langs->trans(
'DefaultPaymentMode');
880 if ($action !=
'editmode')
881 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>';
882 print
'</tr></table>';
885 if ($action ==
'editmode') {
886 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->type_payment,
'mode_reglement_id');
888 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->type_payment,
'none');
894 print
'<tr><td class="nowrap">';
895 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
896 print $langs->trans(
'DefaultBankAccount');
898 if ($action !=
'editbankaccount' && $user->rights->salaries->write) {
899 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>';
901 print
'</tr></table>';
903 if ($action ==
'editbankaccount') {
904 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'fk_account', 1);
906 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'none');
913 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
919 print
'<div class="fichehalfright">';
929 $sql =
"SELECT p.rowid, p.num_payment as num_payment, p.datep as dp, p.amount,";
930 $sql .=
" c.code as type_code,c.libelle as paiement_type,";
931 $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';
932 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_salary as p";
933 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
934 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
935 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as c ON p.fk_typepayment = c.id";
936 $sql .=
", ".MAIN_DB_PREFIX.
"salary as salaire";
937 $sql .=
" WHERE p.fk_salary = ".((int) $id);
938 $sql .=
" AND p.fk_salary = salaire.rowid";
939 $sql .=
" AND salaire.entity IN (".getEntity(
'tax').
")";
940 $sql .=
" ORDER BY dp DESC";
943 $resql = $db->query($sql);
947 $num = $db->num_rows(
$resql);
950 print
'<div class="div-table-responsive-no-min">';
951 print
'<table class="noborder paymenttable">';
952 print
'<tr class="liste_titre">';
953 print
'<td>'.$langs->trans(
"RefPayment").
'</td>';
954 print
'<td>'.$langs->trans(
"Date").
'</td>';
955 print
'<td>'.$langs->trans(
"Type").
'</td>';
957 print
'<td class="liste_titre right">'.$langs->trans(
'BankAccount').
'</td>';
959 print
'<td class="right">'.$langs->trans(
"Amount").
'</td>';
963 $bankaccountstatic =
new Account($db);
965 $objp = $db->fetch_object(
$resql);
967 print
'<tr class="oddeven"><td>';
968 print
'<a href="'.DOL_URL_ROOT.
'/salaries/payment_salary/card.php?id='.$objp->rowid.
'">'.
img_object($langs->trans(
"Payment"),
"payment").
' '.$objp->rowid.
'</a></td>';
969 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'day').
"</td>\n";
970 $labeltype = $langs->trans(
"PaymentType".$objp->type_code) != (
"PaymentType".$objp->type_code) ? $langs->trans(
"PaymentType".$objp->type_code) : $objp->paiement_type;
971 print
"<td>".$labeltype.
' '.$objp->num_payment.
"</td>\n";
973 $bankaccountstatic->id = $objp->baid;
974 $bankaccountstatic->ref = $objp->baref;
975 $bankaccountstatic->label = $objp->baref;
976 $bankaccountstatic->number = $objp->banumber;
977 $bankaccountstatic->currency_code = $objp->bacurrency_code;
980 $bankaccountstatic->account_number = $objp->account_number;
983 $accountingjournal->fetch($objp->fk_accountancy_journal);
984 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
987 print
'<td class="right">';
988 if ($bankaccountstatic->id)
989 print $bankaccountstatic->getNomUrl(1,
'transactions');
992 print
'<td class="right nowrap amountcard">'.price($objp->amount).
"</td>\n";
994 $totalpaid += $objp->amount;
998 print
'<tr class="oddeven"><td><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td>';
999 print
'<td></td><td></td><td></td><td></td>';
1003 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AlreadyPaid").
" :</td><td class=\"right nowrap amountcard\">".
price($totalpaid).
"</td></tr>\n";
1004 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AmountExpected").
" :</td><td class=\"right nowrap amountcard\">".
price($object->amount).
"</td></tr>\n";
1006 $resteapayer = $object->amount - $totalpaid;
1007 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
1009 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"RemainderToPay").
" :</td>";
1010 print
'<td class="right nowrap'.($resteapayer ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayer).
"</td></tr>\n";
1023 print
'<div class="clearboth"></div>';
1027 if ($action ==
'edit') {
1028 print
$form->buttonsSaveCancel();
1032 $resteapayer =
price2num($resteapayer,
'MT');
1039 print
'<div class="tabsAction">'.
"\n";
1040 if ($action !=
'edit') {
1042 if ($object->paye && $user->rights->salaries->write) {
1043 print
dolGetButtonAction(
'', $langs->trans(
'ReOpen'),
'default', $_SERVER[
"PHP_SELF"].
'?action=reopen&token='.
newToken().
'&id='.$object->id,
'');
1047 if ($object->paye == 0 && $user->rights->salaries->write) {
1048 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'&id='.$object->id,
'');
1052 if ($object->paye == 0 && ((
price2num($object->amount) < 0 && $resteapayer < 0) || (
price2num($object->amount) > 0 && $resteapayer > 0)) && $user->rights->salaries->write) {
1053 print
dolGetButtonAction(
'', $langs->trans(
'DoPayment'),
'default', DOL_URL_ROOT.
'/salaries/paiement_salary.php?action=create&token='.
newToken().
'&id='. $object->id,
'');
1058 if ($object->paye == 0 && (($resteapayer <= 0 && $object->amount > 0) || ($object->amount <= 0)) && $user->rights->salaries->write) {
1059 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyPaid'),
'default', $_SERVER[
"PHP_SELF"].
'?action=paid&token='.
newToken().
'&id='.$object->id,
'');
1063 if ($user->rights->salaries->write) {
1064 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
"PHP_SELF"].
'?action=clone&token='.
newToken().
'&id='.$object->id,
'');
1067 if (!empty($user->rights->salaries->delete) && empty($totalpaid)) {
1068 print
dolGetButtonAction(
'', $langs->trans(
'Delete'),
'delete', $_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&id='.$object->id,
'');
1070 print
dolGetButtonAction($langs->trans(
'DisabledBecausePayments'), $langs->trans(
'Delete'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1078 if (
GETPOST(
'modelselected')) {
1079 $action =
'presend';
1082 if ($action !=
'presend') {
1083 print
'<div class="fichecenter"><div class="fichehalfleft">';
1084 print
'<a name="builddoc"></a>';
1086 $includedocgeneration = 1;
1089 if ($includedocgeneration) {
1091 $relativepath = $objref.
'/'.$objref.
'.pdf';
1092 $filedir = $conf->salaries->dir_output.
'/'.$objref;
1093 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
1096 $delallowed = $permissiontoadd;
1097 print $formfile->showdocuments(
'salaries', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
1106 print
'</div><div class="fichehalfright">';
1110 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode',
dol_buildpath(
'/mymodule/myobject_agenda.php', 1).
'?id='.$object->id);
1113 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1117 print
'</div></div>';
1121 if (
GETPOST(
'modelselected')) {
1122 $action =
'presend';
1126 $modelmail =
'salary';
1127 $defaulttopic =
'InformationMessage';
1128 $diroutput = $conf->salaries->dir_output;
1129 $trackid =
'salary'.$object->id;
1131 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif($action=='specimen') elseif($action=='setmodel') elseif($action=='del') elseif($action=='setdoc') $formactions
View.
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 accounts.
Class to manage payments of salaries.
Class to manage projects.
Class to manage salary payments.
Class to manage Dolibarr users.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
GETPOSTINT($paramname, $method=0)
Return value of a param into GET or POST supervariable.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
$formconfirm
if ($action == 'delbookkeepingyear') {
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.