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 console.log("We click on link to autofill salary amount");
662 var fk_user = $("#fk_user").val()
663 var url = "'.DOL_URL_ROOT.
'/salaries/ajax/ajaxsalaries.php?fk_user="+fk_user;
669 console.log("Data returned: "+data);
670 item = JSON.parse(data);
671 if(item[0].key == "Amount") {
672 value = item[0].value;
674 $("#amount").val(item[0].value);
676 console.error("Error: Ajax url "+url+" has returned a null value.");
679 console.error("Error: Ajax url "+url+" has returned the wrong key.");
682 console.error("Error: Ajax url "+url+" has returned an empty page.");
688 alert("'.
dol_escape_js($langs->transnoentitiesnoconv(
"FillFieldFirst")).
'");
699 $head = salaries_prepare_head($object);
702 if ($action ===
'clone') {
703 $formquestion = array(
704 array(
'type' =>
'text',
'name' =>
'clone_label',
'label' => $langs->trans(
"Label"),
'value' => $langs->trans(
"CopyOf").
' '.$object->label),
708 $formquestion[] = array(
'type' =>
'date',
'name' =>
'clone_date_start',
'label' => $langs->trans(
"DateStart"),
'value' => -1);
709 $formquestion[] = array(
'type' =>
'date',
'name' =>
'clone_date_end',
'label' => $langs->trans(
"DateEnd"),
'value' => -1);
711 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneSalary', $object->ref),
'confirm_clone', $formquestion,
'yes', 1, 250);
714 if ($action ==
'paid') {
715 $text = $langs->trans(
'ConfirmPaySalary');
716 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
'PaySalary'), $text,
"confirm_paid",
'',
'', 2);
719 if ($action ==
'delete') {
720 $text = $langs->trans(
'ConfirmDeleteSalary');
721 $formconfirm =
$form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $langs->trans(
'DeleteSalary'), $text,
'confirm_delete',
'',
'', 2);
724 if ($action ==
'edit') {
725 print
"<form name=\"charge\" action=\"".$_SERVER[
"PHP_SELF"].
"?id=$object->id&action=update\" method=\"post\">";
726 print
'<input type="hidden" name="token" value="'.newToken().
'">';
731 $reshook = $hookmanager->executeHooks(
'formConfirm',
$parameters, $object, $action);
732 if (empty($reshook)) {
734 } elseif ($reshook > 0) {
742 print
dol_get_fiche_head($head,
'card', $langs->trans(
"SalaryPayment"), -1,
'salary');
744 $linkback =
'<a href="'.DOL_URL_ROOT.
'/salaries/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
746 $morehtmlref =
'<div class="refidno">';
749 if ($action !=
'editlabel') {
750 $morehtmlref .=
$form->editfieldkey(
"Label",
'label', $object->label, $object, $user->rights->salaries->write,
'string',
'', 0, 1);
751 $morehtmlref .= $object->label;
753 $morehtmlref .= $langs->trans(
'Label').
' : ';
754 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
755 $morehtmlref .=
'<input type="hidden" name="action" value="setlabel">';
756 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
757 $morehtmlref .=
'<input type="text" name="label" value="'.$object->label.
'"/>';
758 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
759 $morehtmlref .=
'</form>';
763 if ($action !=
'editfk_user') {
764 if ($object->getSommePaiement() > 0 && !empty($object->fk_user)) {
765 $userstatic =
new User($db);
766 $result = $userstatic->fetch($object->fk_user);
768 $morehtmlref .=
'<br>' .$langs->trans(
'Employee').
' : '.$userstatic->getNomUrl(-1);
771 $morehtmlref .=
'<br>' .
$form->editfieldkey(
"Employee",
'fk_user', $object->label, $object, $user->rights->salaries->write,
'string',
'', 0, 1);
773 if (!empty($object->fk_user)) {
774 $userstatic =
new User($db);
775 $result = $userstatic->fetch($object->fk_user);
777 $morehtmlref .= $userstatic->getNomUrl(-1);
785 $morehtmlref .=
'<br>'.$langs->trans(
'Employee').
' : ';
786 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
787 $morehtmlref .=
'<input type="hidden" name="action" value="setfk_user">';
788 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
789 $morehtmlref .=
$form->select_dolusers($object->fk_user,
'userid', 1);
790 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
791 $morehtmlref .=
'</form>';
794 $usercancreate = $permissiontoadd;
798 $langs->load(
"projects");
799 $morehtmlref .=
'<br>';
800 if ($usercancreate) {
801 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
802 if ($action !=
'classify') {
803 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
805 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, ($action ==
'classify' ? 1 : 0), 0, 1,
'');
807 if (!empty($object->fk_project)) {
809 $proj->fetch($object->fk_project);
810 $morehtmlref .= $proj->getNomUrl(1);
812 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
818 $morehtmlref .=
'</div>';
820 $totalpaid = $object->getSommePaiement();
821 $object->totalpaid = $totalpaid;
823 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref,
'', 0,
'',
'');
825 print
'<div class="fichecenter">';
826 print
'<div class="fichehalfleft">';
827 print
'<div class="underbanner clearboth"></div>';
829 print
'<table class="border centpercent tableforfield">';
831 if ($action ==
'edit') {
832 print
'<tr><td class="titlefield">'.$langs->trans(
"DateStartPeriod").
"</td><td>";
833 print
$form->selectDate($object->datesp,
'datesp', 0, 0, 0,
'datesp', 1);
837 print
'<td class="titlefield">' . $langs->trans(
"DateStartPeriod") .
'</td><td>';
842 if ($action ==
'edit') {
843 print
'<tr><td>'.$langs->trans(
"DateEndPeriod").
"</td><td>";
844 print
$form->selectDate($object->dateep,
'dateep', 0, 0, 0,
'dateep', 1);
848 print
'<td>' . $langs->trans(
"DateEndPeriod") .
'</td><td>';
862 if ($action ==
'edit') {
863 print
'<tr><td class="fieldrequired">' . $langs->trans(
"Amount") .
'</td><td><input name="amount" size="10" value="' .
price($object->amount) .
'"></td></tr>';
865 print
'<tr><td>' . $langs->trans(
"Amount") .
'</td><td><span class="amount">' .
price($object->amount, 0, $langs, 1, -1, -1, $conf->currency) .
'</span></td></tr>';
870 print
'<table class="nobordernopadding" width="100%"><tr><td>';
871 print $langs->trans(
'DefaultPaymentMode');
873 if ($action !=
'editmode')
874 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>';
875 print
'</tr></table>';
878 if ($action ==
'editmode') {
879 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->type_payment,
'mode_reglement_id');
881 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->type_payment,
'none');
887 print
'<tr><td class="nowrap">';
888 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
889 print $langs->trans(
'DefaultBankAccount');
891 if ($action !=
'editbankaccount' && $user->rights->salaries->write) {
892 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>';
894 print
'</tr></table>';
896 if ($action ==
'editbankaccount') {
897 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'fk_account', 1);
899 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'none');
906 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
912 print
'<div class="fichehalfright">';
922 $sql =
"SELECT p.rowid, p.num_payment as num_payment, p.datep as dp, p.amount,";
923 $sql .=
" c.code as type_code,c.libelle as paiement_type,";
924 $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';
925 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_salary as p";
926 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
927 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
928 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as c ON p.fk_typepayment = c.id";
929 $sql .=
", ".MAIN_DB_PREFIX.
"salary as salaire";
930 $sql .=
" WHERE p.fk_salary = ".((int) $id);
931 $sql .=
" AND p.fk_salary = salaire.rowid";
932 $sql .=
" AND salaire.entity IN (".getEntity(
'tax').
")";
933 $sql .=
" ORDER BY dp DESC";
936 $resql = $db->query($sql);
940 $num = $db->num_rows(
$resql);
943 print
'<div class="div-table-responsive-no-min">';
944 print
'<table class="noborder paymenttable">';
945 print
'<tr class="liste_titre">';
946 print
'<td>'.$langs->trans(
"RefPayment").
'</td>';
947 print
'<td>'.$langs->trans(
"Date").
'</td>';
948 print
'<td>'.$langs->trans(
"Type").
'</td>';
950 print
'<td class="liste_titre right">'.$langs->trans(
'BankAccount').
'</td>';
952 print
'<td class="right">'.$langs->trans(
"Amount").
'</td>';
956 $bankaccountstatic =
new Account($db);
958 $objp = $db->fetch_object(
$resql);
960 print
'<tr class="oddeven">';
963 print
'<a href="'.DOL_URL_ROOT.
'/salaries/payment_salary/card.php?id='.$objp->rowid.
'">'.
img_object($langs->trans(
"Payment"),
"payment").
' '.$objp->rowid.
'</a></td>';
965 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'dayhour',
'tzuserrel').
"</td>\n";
966 $labeltype = $langs->trans(
"PaymentType".$objp->type_code) != (
"PaymentType".$objp->type_code) ? $langs->trans(
"PaymentType".$objp->type_code) : $objp->paiement_type;
967 print
"<td>".$labeltype.
' '.$objp->num_payment.
"</td>\n";
969 $bankaccountstatic->id = $objp->baid;
970 $bankaccountstatic->ref = $objp->baref;
971 $bankaccountstatic->label = $objp->baref;
972 $bankaccountstatic->number = $objp->banumber;
973 $bankaccountstatic->currency_code = $objp->bacurrency_code;
976 $bankaccountstatic->account_number = $objp->account_number;
979 $accountingjournal->fetch($objp->fk_accountancy_journal);
980 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
983 print
'<td class="right">';
984 if ($bankaccountstatic->id)
985 print $bankaccountstatic->getNomUrl(1,
'transactions');
988 print
'<td class="right nowrap amountcard">'.price($objp->amount).
"</td>\n";
990 $totalpaid += $objp->amount;
994 print
'<tr class="oddeven"><td><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td>';
995 print
'<td></td><td></td><td></td><td></td>';
999 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AlreadyPaid").
' :</td><td class="right nowrap amountcard">'.
price($totalpaid).
"</td></tr>\n";
1000 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"AmountExpected").
' :</td><td class="right nowrap amountcard">'.
price($object->amount).
"</td></tr>\n";
1002 $resteapayer = $object->amount - $totalpaid;
1003 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
1005 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"RemainderToPay").
" :</td>";
1006 print
'<td class="right nowrap'.($resteapayer ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayer).
"</td></tr>\n";
1019 print
'<div class="clearboth"></div>';
1023 if ($action ==
'edit') {
1024 print
$form->buttonsSaveCancel();
1028 $resteapayer =
price2num($resteapayer,
'MT');
1035 print
'<div class="tabsAction">'.
"\n";
1036 if ($action !=
'edit') {
1038 if ($object->paye && $user->rights->salaries->write) {
1039 print
dolGetButtonAction(
'', $langs->trans(
'ReOpen'),
'default', $_SERVER[
"PHP_SELF"].
'?action=reopen&token='.
newToken().
'&id='.$object->id,
'');
1043 if ($object->paye == 0 && $user->rights->salaries->write) {
1044 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'&id='.$object->id,
'');
1048 if ($object->paye == 0 && ((
price2num($object->amount) < 0 && $resteapayer < 0) || (
price2num($object->amount) > 0 && $resteapayer > 0)) && $user->rights->salaries->write) {
1049 print
dolGetButtonAction(
'', $langs->trans(
'DoPayment'),
'default', DOL_URL_ROOT.
'/salaries/paiement_salary.php?action=create&token='.
newToken().
'&id='. $object->id,
'');
1054 if ($object->paye == 0 && (($resteapayer <= 0 && $object->amount > 0) || ($object->amount <= 0)) && $user->rights->salaries->write) {
1055 print
dolGetButtonAction(
'', $langs->trans(
'ClassifyPaid'),
'default', $_SERVER[
"PHP_SELF"].
'?action=paid&token='.
newToken().
'&id='.$object->id,
'');
1059 if ($user->rights->salaries->write) {
1060 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
"PHP_SELF"].
'?action=clone&token='.
newToken().
'&id='.$object->id,
'');
1063 if (!empty($user->rights->salaries->delete) && empty($totalpaid)) {
1064 print
dolGetButtonAction(
'', $langs->trans(
'Delete'),
'delete', $_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&id='.$object->id,
'');
1066 print
dolGetButtonAction($langs->trans(
'DisabledBecausePayments'), $langs->trans(
'Delete'),
'default', $_SERVER[
'PHP_SELF'].
'#',
'',
false);
1074 if (
GETPOST(
'modelselected')) {
1075 $action =
'presend';
1078 if ($action !=
'presend') {
1079 print
'<div class="fichecenter"><div class="fichehalfleft">';
1080 print
'<a name="builddoc"></a>';
1082 $includedocgeneration = 1;
1085 if ($includedocgeneration) {
1087 $relativepath = $objref.
'/'.$objref.
'.pdf';
1088 $filedir = $conf->salaries->dir_output.
'/'.$objref;
1089 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
1092 $delallowed = $permissiontoadd;
1093 print $formfile->showdocuments(
'salaries', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
1102 print
'</div><div class="fichehalfright">';
1106 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode',
dol_buildpath(
'/mymodule/myobject_agenda.php', 1).
'?id='.$object->id);
1109 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1113 print
'</div></div>';
1117 if (
GETPOST(
'modelselected')) {
1118 $action =
'presend';
1122 $modelmail =
'salary';
1123 $defaulttopic =
'InformationMessage';
1124 $diroutput = $conf->salaries->dir_output;
1125 $trackid =
'salary'.$object->id;
1127 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.