card.php 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020
  1. <?php
  2. /* Copyright (C) 2011-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
  3. * Copyright (C) 2014-2020 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
  5. * Copyright (C) 2015 Charlie BENKE <charlie@patas-monkey.com>
  6. * Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
  7. * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  21. */
  22. /**
  23. * \file htdocs/salaries/card.php
  24. * \ingroup salaries
  25. * \brief Page of salaries payments
  26. */
  27. require '../main.inc.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
  34. require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
  35. if (!empty($conf->projet->enabled)) {
  36. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  37. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
  38. }
  39. // Load translation files required by the page
  40. $langs->loadLangs(array("compta", "banks", "bills", "users", "salaries", "hrm", "trips"));
  41. if (!empty($conf->projet->enabled)) {
  42. $langs->load("projects");
  43. }
  44. $id = GETPOSTINT('id');
  45. $ref = GETPOST('ref', 'alpha');
  46. $action = GETPOST('action', 'aZ09');
  47. $cancel = GETPOST('cancel', 'aZ09');
  48. $confirm = GETPOST('confirm');
  49. $label = GETPOST('label', 'alphanohtml');
  50. $projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int'));
  51. $accountid = GETPOST('accountid', 'int') > 0 ? GETPOST('accountid', 'int') : 0;
  52. if (GETPOSTISSET('auto_create_paiement') || $action === 'add') {
  53. $auto_create_paiement = GETPOST("auto_create_paiement", "int");
  54. } else {
  55. $auto_create_paiement = empty($conf->global->CREATE_NEW_SALARY_WITHOUT_AUTO_PAYMENT);
  56. }
  57. $datep = dol_mktime(12, 0, 0, GETPOST("datepmonth", 'int'), GETPOST("datepday", 'int'), GETPOST("datepyear", 'int'));
  58. $datev = dol_mktime(12, 0, 0, GETPOST("datevmonth", 'int'), GETPOST("datevday", 'int'), GETPOST("datevyear", 'int'));
  59. $datesp = dol_mktime(12, 0, 0, GETPOST("datespmonth", 'int'), GETPOST("datespday", 'int'), GETPOST("datespyear", 'int'));
  60. $dateep = dol_mktime(12, 0, 0, GETPOST("dateepmonth", 'int'), GETPOST("dateepday", 'int'), GETPOST("dateepyear", 'int'));
  61. $fk_user = GETPOSTINT('userid');
  62. $object = new Salary($db);
  63. $extrafields = new ExtraFields($db);
  64. $childids = $user->getAllChildIds(1);
  65. // fetch optionals attributes and labels
  66. $extrafields->fetch_name_optionals_label($object->table_element);
  67. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  68. $hookmanager->initHooks(array('salarycard', 'globalcard'));
  69. $object = new Salary($db);
  70. if ($id > 0 || !empty($ref)) {
  71. $object->fetch($id, $ref);
  72. // Check current user can read this salary
  73. $canread = 0;
  74. if (!empty($user->rights->salaries->readall)) {
  75. $canread = 1;
  76. }
  77. if (!empty($user->rights->salaries->read) && $object->fk_user > 0 && in_array($object->fk_user, $childids)) {
  78. $canread = 1;
  79. }
  80. if (!$canread) {
  81. accessforbidden();
  82. }
  83. }
  84. // Security check
  85. $socid = GETPOSTINT('socid');
  86. if ($user->socid) {
  87. $socid = $user->socid;
  88. }
  89. restrictedArea($user, 'salaries', $object->id, 'salary', '');
  90. /**
  91. * Actions
  92. */
  93. if ($cancel) {
  94. header("Location: list.php");
  95. exit;
  96. }
  97. // Link to a project
  98. if ($action == 'classin' && $user->rights->banque->modifier) {
  99. $object->fetch($id);
  100. $object->setProject($projectid);
  101. }
  102. // set label
  103. if ($action == 'setlabel' && $user->rights->salaries->write) {
  104. $object->fetch($id);
  105. $object->label = $label;
  106. $object->update($user);
  107. }
  108. // Classify paid
  109. if ($action == 'confirm_paid' && $user->rights->salaries->write && $confirm == 'yes') {
  110. $object->fetch($id);
  111. $result = $object->set_paid($user);
  112. }
  113. if ($action == 'setfk_user' && $user->rights->salaries->write) {
  114. $result = $object->fetch($id);
  115. if ($result > 0) {
  116. $object->fk_user = $fk_user;
  117. $object->update($user);
  118. } else {
  119. dol_print_error($db);
  120. exit;
  121. }
  122. }
  123. if ($action == 'reopen' && $user->rights->salaries->write) {
  124. $result = $object->fetch($id);
  125. if ($object->paye) {
  126. $result = $object->set_unpaid($user);
  127. if ($result > 0) {
  128. header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
  129. exit();
  130. } else {
  131. setEventMessages($object->error, $object->errors, 'errors');
  132. }
  133. }
  134. }
  135. // payment mode
  136. if ($action == 'setmode' && $user->rights->salaries->write) {
  137. $object->fetch($id);
  138. $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
  139. if ($result < 0)
  140. setEventMessages($object->error, $object->errors, 'errors');
  141. }
  142. // bank account
  143. if ($action == 'setbankaccount' && $user->rights->salaries->write) {
  144. $object->fetch($id);
  145. $result = $object->setBankAccount(GETPOST('fk_account', 'int'));
  146. if ($result < 0) {
  147. setEventMessages($object->error, $object->errors, 'errors');
  148. }
  149. }
  150. if ($action == 'add' && empty($cancel)) {
  151. $error = 0;
  152. if (empty($datev)) $datev = $datep;
  153. $type_payment = GETPOST("paymenttype", 'alpha');
  154. $amount = price2num(GETPOST("amount", 'alpha'), 'MT', 2);
  155. $object->accountid = GETPOST("accountid", 'int') > 0 ? GETPOST("accountid", "int") : 0;
  156. $object->fk_user = GETPOST("fk_user", 'int') > 0 ? GETPOST("fk_user", "int") : 0;
  157. $object->datev = $datev;
  158. $object->datep = $datep;
  159. $object->amount = $amount;
  160. $object->label = GETPOST("label", 'alphanohtml');
  161. $object->datesp = $datesp;
  162. $object->dateep = $dateep;
  163. $object->note = GETPOST("note", 'restricthtml');
  164. $object->type_payment = ($type_payment > 0 ? $type_payment : 0);
  165. $object->fk_user_author = $user->id;
  166. $object->fk_project = $projectid;
  167. // Set user current salary as ref salary for the payment
  168. $fuser = new User($db);
  169. $fuser->fetch(GETPOST("fk_user", "int"));
  170. $object->salary = $fuser->salary;
  171. // Fill array 'array_options' with data from add form
  172. $ret = $extrafields->setOptionalsFromPost(null, $object);
  173. if ($ret < 0) {
  174. $error++;
  175. }
  176. if (!empty($auto_create_paiement) && empty($datep)) {
  177. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DATE_PAIEMENT")), null, 'errors');
  178. $error++;
  179. }
  180. if (empty($datesp) || empty($dateep)) {
  181. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
  182. $error++;
  183. }
  184. if (empty($object->fk_user) || $object->fk_user < 0) {
  185. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Employee")), null, 'errors');
  186. $error++;
  187. }
  188. if (!empty($auto_create_paiement) && (empty($type_payment) || $type_payment < 0)) {
  189. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors');
  190. $error++;
  191. }
  192. if (empty($object->amount)) {
  193. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
  194. $error++;
  195. }
  196. if (!empty($conf->banque->enabled) && !empty($auto_create_paiement) && !$object->accountid > 0) {
  197. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors');
  198. $error++;
  199. }
  200. if (!$error) {
  201. $db->begin();
  202. $ret = $object->create($user);
  203. if ($ret < 0) $error++;
  204. if (!empty($auto_create_paiement) && !$error) {
  205. // Create a line of payments
  206. $paiement = new PaymentSalary($db);
  207. $paiement->chid = $object->id;
  208. $paiement->datepaye = $datep;
  209. $paiement->datev = $datev;
  210. $paiement->amounts = array($object->id=>$amount); // Tableau de montant
  211. $paiement->paiementtype = $type_payment;
  212. $paiement->num_payment = GETPOST("num_payment", 'alphanohtml');
  213. $paiement->note = GETPOST("note", 'none');
  214. if (!$error) {
  215. $paymentid = $paiement->create($user, (int) GETPOST('closepaidsalary'));
  216. if ($paymentid < 0) {
  217. $error++;
  218. setEventMessages($paiement->error, null, 'errors');
  219. $action = 'create';
  220. }
  221. }
  222. if (!$error) {
  223. $result = $paiement->addPaymentToBank($user, 'payment_salary', '(SalaryPayment)', GETPOST('accountid', 'int'), '', '');
  224. if (!($result > 0)) {
  225. $error++;
  226. setEventMessages($paiement->error, null, 'errors');
  227. }
  228. }
  229. }
  230. if (empty($error)) {
  231. $db->commit();
  232. if (GETPOST('saveandnew', 'alpha')) {
  233. setEventMessages($langs->trans("RecordSaved"), '', 'mesgs');
  234. 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'));
  235. exit;
  236. } else {
  237. header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $object->id);
  238. exit;
  239. }
  240. } else {
  241. $db->rollback();
  242. }
  243. }
  244. $action = 'create';
  245. }
  246. if ($action == 'confirm_delete') {
  247. $result = $object->fetch($id);
  248. $totalpaye = $object->getSommePaiement();
  249. if (empty($totalpaye)) {
  250. $db->begin();
  251. $ret = $object->delete($user);
  252. if ($ret > 0) {
  253. $db->commit();
  254. header("Location: ".DOL_URL_ROOT.'/salaries/list.php');
  255. exit;
  256. } else {
  257. $db->rollback();
  258. setEventMessages($object->error, $object->errors, 'errors');
  259. }
  260. } else {
  261. setEventMessages($langs->trans('DisabledBecausePayments'), null, 'errors');
  262. }
  263. }
  264. if ($action == 'update' && !GETPOST("cancel") && $user->rights->salaries->write) {
  265. $amount = price2num(GETPOST('amount'), 'MT', 2);
  266. if (empty($amount)) {
  267. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors');
  268. $action = 'edit';
  269. } elseif (!is_numeric($amount)) {
  270. setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentities("Amount")), null, 'errors');
  271. $action = 'create';
  272. } else {
  273. $result = $object->fetch($id);
  274. $object->amount = price2num($amount);
  275. $object->datesp = price2num($datesp);
  276. $object->dateep = price2num($dateep);
  277. $result = $object->update($user);
  278. if ($result <= 0) {
  279. setEventMessages($object->error, $object->errors, 'errors');
  280. }
  281. }
  282. }
  283. if ($action == 'confirm_clone' && $confirm != 'yes') { $action = ''; }
  284. if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->salaries->write)) {
  285. $db->begin();
  286. $originalId = $id;
  287. $object->fetch($id);
  288. if ($object->id > 0) {
  289. $object->paye = 0;
  290. $object->id = $object->ref = null;
  291. if (GETPOST('clone_label', 'alphanohtml')) {
  292. $object->label = GETPOST('clone_label', 'alphanohtml');
  293. } else {
  294. $object->label = $langs->trans("CopyOf").' '.$object->label;
  295. }
  296. $newdatestart = dol_mktime(0, 0, 0, GETPOST('clone_date_startmonth', 'int'), GETPOST('clone_date_startday', 'int'), GETPOST('clone_date_startyear', 'int'));
  297. $newdateend = dol_mktime(0, 0, 0, GETPOST('clone_date_endmonth', 'int'), GETPOST('clone_date_endday', 'int'), GETPOST('clone_date_endyear', 'int'));
  298. if ($newdatestart) $object->datesp = $newdatestart;
  299. if ($newdateend) $object->dateep = $newdateend;
  300. $id = $object->create($user);
  301. if ($id > 0) {
  302. $db->commit();
  303. $db->close();
  304. header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
  305. exit;
  306. } else {
  307. $id = $originalId;
  308. $db->rollback();
  309. setEventMessages($object->error, $object->errors, 'errors');
  310. }
  311. } else {
  312. $db->rollback();
  313. dol_print_error($db, $object->error);
  314. }
  315. }
  316. // Action to update one extrafield
  317. if ($action == "update_extras" && !empty($user->rights->salaries->read)) {
  318. $object->fetch(GETPOST('id', 'int'));
  319. $attributekey = GETPOST('attribute', 'alpha');
  320. $attributekeylong = 'options_'.$attributekey;
  321. if (GETPOSTISSET($attributekeylong.'day') && GETPOSTISSET($attributekeylong.'month') && GETPOSTISSET($attributekeylong.'year')) {
  322. // This is properties of a date
  323. $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'));
  324. //var_dump(dol_print_date($object->array_options['options_'.$attributekey]));exit;
  325. } else {
  326. $object->array_options['options_'.$attributekey] = GETPOST($attributekeylong, 'alpha');
  327. }
  328. $result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user);
  329. if ($result > 0) {
  330. setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
  331. $action = 'view';
  332. } else {
  333. setEventMessages($object->error, $object->errors, 'errors');
  334. $action = 'edit_extras';
  335. }
  336. }
  337. /*
  338. * View
  339. */
  340. $title = $langs->trans('Salary')." - ".$langs->trans('Card');
  341. $help_url = "";
  342. llxHeader("", $title, $help_url);
  343. $form = new Form($db);
  344. if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db);
  345. if ($id) {
  346. $object = new Salary($db);
  347. $result = $object->fetch($id);
  348. if ($result <= 0) {
  349. dol_print_error($db);
  350. exit;
  351. }
  352. }
  353. // Create
  354. if ($action == 'create') {
  355. $year_current = strftime("%Y", dol_now());
  356. $pastmonth = strftime("%m", dol_now()) - 1;
  357. $pastmonthyear = $year_current;
  358. if ($pastmonth == 0) {
  359. $pastmonth = 12;
  360. $pastmonthyear--;
  361. }
  362. $datespmonth = GETPOST('datespmonth', 'int');
  363. $datespday = GETPOST('datespday', 'int');
  364. $datespyear = GETPOST('datespyear', 'int');
  365. $dateepmonth = GETPOST('dateepmonth', 'int');
  366. $dateepday = GETPOST('dateepday', 'int');
  367. $dateepyear = GETPOST('dateepyear', 'int');
  368. $datesp = dol_mktime(0, 0, 0, $datespmonth, $datespday, $datespyear);
  369. $dateep = dol_mktime(23, 59, 59, $dateepmonth, $dateepday, $dateepyear);
  370. if (empty($datesp) || empty($dateep)) { // We define date_start and date_end
  371. $datesp = dol_get_first_day($pastmonthyear, $pastmonth, false); $dateep = dol_get_last_day($pastmonthyear, $pastmonth, false);
  372. }
  373. print '<form name="salary" action="'.$_SERVER["PHP_SELF"].'" method="post">';
  374. print '<input type="hidden" name="token" value="'.newToken().'">';
  375. print '<input type="hidden" name="action" value="add">';
  376. print load_fiche_titre($langs->trans("NewSalary"), '', 'salary');
  377. if (!empty($conf->use_javascript_ajax)) {
  378. print "\n".'<script type="text/javascript" language="javascript">';
  379. print /** @lang JavaScript */'
  380. $(document).ready(function () {
  381. let onAutoCreatePaiementChange = function () {
  382. if($("#auto_create_paiement").is(":checked")) {
  383. $("#label_fk_account").find("span").addClass("fieldrequired");
  384. $("#label_type_payment").find("span").addClass("fieldrequired");
  385. $(".hide_if_no_auto_create_payment").show();
  386. } else {
  387. $("#label_fk_account").find("span").removeClass("fieldrequired");
  388. $("#label_type_payment").find("span").removeClass("fieldrequired");
  389. $(".hide_if_no_auto_create_payment").hide();
  390. }
  391. };
  392. $("#radiopayment").click(function() {
  393. $("#label").val($(this).data("label"));
  394. });
  395. $("#radiorefund").click(function() {
  396. $("#label").val($(this).data("label"));
  397. });
  398. $("#auto_create_paiement").click(function () {
  399. onAutoCreatePaiementChange();
  400. });
  401. onAutoCreatePaiementChange();
  402. });
  403. ';
  404. print '</script>'."\n";
  405. }
  406. print dol_get_fiche_head('', '');
  407. print '<table class="border centpercent">';
  408. // Employee
  409. print '<tr><td class="titlefieldcreate">';
  410. print $form->editfieldkey('Employee', 'fk_user', '', $object, 0, 'string', '', 1).'</td><td>';
  411. $noactive = 0; // We keep active and unactive users
  412. 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);
  413. print '</td></tr>';
  414. // Label
  415. print '<tr><td>';
  416. print $form->editfieldkey('Label', 'label', '', $object, 0, 'string', '', 1).'</td><td>';
  417. print '<input name="label" id="label" class="minwidth300" value="'.(GETPOST("label") ?GETPOST("label") : $langs->trans("Salary")).'">';
  418. print '</td></tr>';
  419. // Date start period
  420. print '<tr><td>';
  421. print $form->editfieldkey('DateStartPeriod', 'datesp', '', $object, 0, 'string', '', 1).'</td><td>';
  422. print $form->selectDate($datesp, "datesp", '', '', '', 'add');
  423. print '</td></tr>';
  424. // Date end period
  425. print '<tr><td>';
  426. print $form->editfieldkey('DateEndPeriod', 'dateep', '', $object, 0, 'string', '', 1).'</td><td>';
  427. print $form->selectDate($dateep, "dateep", '', '', '', 'add');
  428. print '</td></tr>';
  429. // Amount
  430. print '<tr><td>';
  431. print $form->editfieldkey('Amount', 'amount', '', $object, 0, 'string', '', 1).'</td><td>';
  432. print '<input name="amount" id="amount" class="minwidth75 maxwidth100" value="'.GETPOST("amount").'">&nbsp;';
  433. print '<button class="dpInvisibleButtons" id="updateAmountWithLastSalary" name="_useless" type="button">'.$langs->trans('UpdateAmountWithLastSalary').'</a>';
  434. print '</td>';
  435. print '</tr>';
  436. // Project
  437. if (!empty($conf->projet->enabled)) {
  438. $formproject = new FormProjets($db);
  439. print '<tr><td>'.$langs->trans("Project").'</td><td>';
  440. $formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1);
  441. print '</td></tr>';
  442. }
  443. // Comments
  444. print '<tr>';
  445. print '<td class="tdtop">'.$langs->trans("Comments").'</td>';
  446. print '<td class="tdtop"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.'">'.GETPOST('note', 'restricthtml').'</textarea></td>';
  447. print '</tr>';
  448. print '<tr><td colspan="2"><hr></td></tr>';
  449. // Auto create payment
  450. print '<tr><td>'.$langs->trans('AutomaticCreationPayment').'</td>';
  451. print '<td><input id="auto_create_paiement" name="auto_create_paiement" type="checkbox" ' . (empty($auto_create_paiement) ? '' : 'checked="checked"') . ' value="1"></td></tr>'."\n"; // Date payment
  452. // Bank
  453. if (!empty($conf->banque->enabled)) {
  454. print '<tr><td id="label_fk_account">';
  455. print $form->editfieldkey('BankAccount', 'selectaccountid', '', $object, 0, 'string', '', 1).'</td><td>';
  456. print img_picto('', 'bank_account', 'class="paddingrighonly"');
  457. $form->select_comptes($accountid, "accountid", 0, '', 1); // Affiche liste des comptes courant
  458. print '</td></tr>';
  459. }
  460. // Type payment
  461. print '<tr><td id="label_type_payment">';
  462. print $form->editfieldkey('PaymentMode', 'selectpaymenttype', '', $object, 0, 'string', '', 1).'</td><td>';
  463. $form->select_types_paiements(GETPOST("paymenttype", 'aZ09'), "paymenttype", '');
  464. print '</td></tr>';
  465. // Date payment
  466. print '<tr class="hide_if_no_auto_create_payment"><td>';
  467. print $form->editfieldkey('DatePayment', 'datep', '', $object, 0, 'string', '', 1).'</td><td>';
  468. print $form->selectDate((empty($datep) ? '' : $datep), "datep", 0, 0, 0, 'add', 1, 1);
  469. print '</td></tr>';
  470. // Date value for bank
  471. print '<tr class="hide_if_no_auto_create_payment"><td>';
  472. print $form->editfieldkey('DateValue', 'datev', '', $object, 0).'</td><td>';
  473. print $form->selectDate((empty($datev) ?-1 : $datev), "datev", '', '', '', 'add', 1, 1);
  474. print '</td></tr>';
  475. // Number
  476. if (!empty($conf->banque->enabled)) {
  477. // Number
  478. print '<tr class="hide_if_no_auto_create_payment"><td><label for="num_payment">'.$langs->trans('Numero');
  479. print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
  480. print '</label></td>';
  481. print '<td><input name="num_payment" id="num_payment" type="text" value="'.GETPOST("num_payment").'"></td></tr>'."\n";
  482. }
  483. // Bouton Save payment
  484. /*
  485. print '<tr class="hide_if_no_auto_create_payment"><td>';
  486. print $langs->trans("ClosePaidSalaryAutomatically");
  487. print '</td><td><input type="checkbox" checked value="1" name="closepaidsalary"></td></tr>';
  488. */
  489. // Other attributes
  490. $parameters = array();
  491. $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  492. print $hookmanager->resPrint;
  493. if (empty($reshook)) {
  494. print $object->showOptionals($extrafields, 'create');
  495. }
  496. print '</table>';
  497. print dol_get_fiche_end();
  498. print '<div class="center">';
  499. print '<div class="hide_if_no_auto_create_payment paddingbottom">';
  500. print '<input type="checkbox" checked value="1" name="closepaidsalary">'.$langs->trans("ClosePaidSalaryAutomatically");
  501. print '</div>';
  502. print '</div>';
  503. $addition_button = array(
  504. 'name' => 'saveandnew',
  505. 'label_key' => 'SaveAndNew',
  506. );
  507. print $form->buttonsSaveCancel("Save", "Cancel", $addition_button);
  508. print '</form>';
  509. print '<script>';
  510. print '$( document ).ready(function() {';
  511. print '$("#updateAmountWithLastSalary").on("click", function updateAmountWithLastSalary() {
  512. console.log("We click on link to autofill salary amount");
  513. var fk_user = $("#fk_user").val()
  514. var url = "'.DOL_URL_ROOT.'/salaries/ajax/ajaxsalaries.php?fk_user="+fk_user;
  515. if (fk_user != -1) {
  516. $.get(
  517. url,
  518. function( data ) {
  519. if(data!=null) {
  520. console.log("Data returned: "+data);
  521. item = JSON.parse(data);
  522. if(item[0].key == "Amount") {
  523. value = item[0].value;
  524. if (value != null) {
  525. $("#amount").val(item[0].value);
  526. } else {
  527. console.error("Error: Ajax url "+url+" has returned a null value.");
  528. }
  529. } else {
  530. console.error("Error: Ajax url "+url+" has returned the wrong key.");
  531. }
  532. } else {
  533. console.error("Error: Ajax url "+url+" has returned an empty page.");
  534. }
  535. }
  536. );
  537. } else {
  538. alert("'.$langs->trans("FillFieldFirst").'");
  539. }
  540. });
  541. })';
  542. print '</script>';
  543. }
  544. /* ************************************************************************** */
  545. /* */
  546. /* View mode */
  547. /* */
  548. /* ************************************************************************** */
  549. if ($id) {
  550. $head = salaries_prepare_head($object);
  551. if ($action === 'clone') {
  552. $formquestion = array(
  553. array('type' => 'text', 'name' => 'clone_label', 'label' => $langs->trans("Label"), 'value' => $langs->trans("CopyOf").' '.$object->label),
  554. );
  555. //$formquestion[] = array('type' => 'date', 'name' => 'clone_date_ech', 'label' => $langs->trans("Date"), 'value' => -1);
  556. $formquestion[] = array('type' => 'date', 'name' => 'clone_date_start', 'label' => $langs->trans("DateStart"), 'value' => -1);
  557. $formquestion[] = array('type' => 'date', 'name' => 'clone_date_end', 'label' => $langs->trans("DateEnd"), 'value' => -1);
  558. print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneSalary', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 240);
  559. }
  560. if ($action == 'paid') {
  561. $text = $langs->trans('ConfirmPaySalary');
  562. print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans('PaySalary'), $text, "confirm_paid", '', '', 2);
  563. }
  564. if ($action == 'delete') {
  565. $text = $langs->trans('ConfirmDeleteSalary');
  566. print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('DeleteSalary'), $text, 'confirm_delete', '', '', 2);
  567. }
  568. if ($action == 'edit') {
  569. print "<form name=\"charge\" action=\"".$_SERVER["PHP_SELF"]."?id=$object->id&amp;action=update\" method=\"post\">";
  570. print '<input type="hidden" name="token" value="'.newToken().'">';
  571. }
  572. print dol_get_fiche_head($head, 'card', $langs->trans("SalaryPayment"), -1, 'salary');
  573. $linkback = '<a href="'.DOL_URL_ROOT.'/salaries/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  574. $morehtmlref = '<div class="refidno">';
  575. // Label
  576. if ($action != 'editlabel') {
  577. $morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->salaries->write, 'string', '', 0, 1);
  578. $morehtmlref .= $object->label;
  579. } else {
  580. $morehtmlref .= $langs->trans('Label').' :&nbsp;';
  581. $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
  582. $morehtmlref .= '<input type="hidden" name="action" value="setlabel">';
  583. $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
  584. $morehtmlref .= '<input type="text" name="label" value="'.$object->label.'"/>';
  585. $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
  586. $morehtmlref .= '</form>';
  587. }
  588. // Employee
  589. if ($action != 'editfk_user') {
  590. if ($object->getSommePaiement() > 0 && !empty($object->fk_user)) {
  591. $userstatic = new User($db);
  592. $result = $userstatic->fetch($object->fk_user);
  593. if ($result > 0) {
  594. $morehtmlref .= '<br>' .$langs->trans('Employee').' : '.$userstatic->getNomUrl(1);
  595. }
  596. } else {
  597. $morehtmlref .= '<br>' . $form->editfieldkey("Employee", 'fk_user', $object->label, $object, $user->rights->salaries->write, 'string', '', 0, 1);
  598. if (!empty($object->fk_user)) {
  599. $userstatic = new User($db);
  600. $result = $userstatic->fetch($object->fk_user);
  601. if ($result > 0) {
  602. $morehtmlref .= $userstatic->getNomUrl(1);
  603. } else {
  604. dol_print_error($db);
  605. exit();
  606. }
  607. }
  608. }
  609. } else {
  610. $morehtmlref .= '<br>'.$langs->trans('Employee').' :&nbsp;';
  611. $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
  612. $morehtmlref .= '<input type="hidden" name="action" value="setfk_user">';
  613. $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
  614. $morehtmlref .= $form->select_dolusers($object->fk_user, 'userid', 1);
  615. $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
  616. $morehtmlref .= '</form>';
  617. }
  618. // Project
  619. if (!empty($conf->projet->enabled)) {
  620. $morehtmlref .= '<br>'.$langs->trans('Project').' ';
  621. if ($user->rights->salaries->write) {
  622. if ($action != 'classify') {
  623. $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
  624. }
  625. if ($action == 'classify') {
  626. //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
  627. $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
  628. $morehtmlref .= '<input type="hidden" name="action" value="classin">';
  629. $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
  630. $morehtmlref .= $formproject->select_projects(-1, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500');
  631. $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
  632. $morehtmlref .= '</form>';
  633. } else {
  634. $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
  635. }
  636. } else {
  637. if (!empty($object->fk_project)) {
  638. $proj = new Project($db);
  639. $proj->fetch($object->fk_project);
  640. $morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">';
  641. $morehtmlref .= $proj->ref;
  642. $morehtmlref .= '</a>';
  643. } else {
  644. $morehtmlref .= '';
  645. }
  646. }
  647. }
  648. $morehtmlref .= '</div>';
  649. $totalpaye = $object->getSommePaiement();
  650. $object->totalpaye = $totalpaye;
  651. dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', '');
  652. print '<div class="fichecenter">';
  653. print '<div class="fichehalfleft">';
  654. print '<div class="underbanner clearboth"></div>';
  655. print '<table class="border centpercent tableforfield">';
  656. if ($action == 'edit') {
  657. print '<tr><td class="titlefield">'.$langs->trans("DateStartPeriod")."</td><td>";
  658. print $form->selectDate($object->datesp, 'datesp', 0, 0, 0, 'datesp', 1);
  659. print "</td></tr>";
  660. } else {
  661. print "<tr>";
  662. print '<td class="titlefield">' . $langs->trans("DateStartPeriod") . '</td><td>';
  663. print dol_print_date($object->datesp, 'day');
  664. print '</td></tr>';
  665. }
  666. if ($action == 'edit') {
  667. print '<tr><td>'.$langs->trans("DateEndPeriod")."</td><td>";
  668. print $form->selectDate($object->dateep, 'dateep', 0, 0, 0, 'dateep', 1);
  669. print "</td></tr>";
  670. } else {
  671. print "<tr>";
  672. print '<td>' . $langs->trans("DateEndPeriod") . '</td><td>';
  673. print dol_print_date($object->dateep, 'day');
  674. print '</td></tr>';
  675. }
  676. /*print "<tr>";
  677. print '<td>'.$langs->trans("DatePayment").'</td><td>';
  678. print dol_print_date($object->datep, 'day');
  679. print '</td></tr>';
  680. print '<tr><td>'.$langs->trans("DateValue").'</td><td>';
  681. print dol_print_date($object->datev, 'day');
  682. print '</td></tr>';*/
  683. if ($action == 'edit') {
  684. print '<tr><td class="fieldrequired">' . $langs->trans("Amount") . '</td><td><input name="amount" size="10" value="' . price($object->amount) . '"></td></tr>';
  685. } else {
  686. print '<tr><td>' . $langs->trans("Amount") . '</td><td><span class="amount">' . price($object->amount, 0, $langs, 1, -1, -1, $conf->currency) . '</span></td></tr>';
  687. }
  688. // Default mode of payment
  689. print '<tr><td>';
  690. print '<table class="nobordernopadding" width="100%"><tr><td>';
  691. print $langs->trans('DefaultPaymentMode');
  692. print '</td>';
  693. if ($action != 'editmode')
  694. 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>';
  695. print '</tr></table>';
  696. print '</td><td>';
  697. if ($action == 'editmode') {
  698. $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->type_payment, 'mode_reglement_id');
  699. } else {
  700. $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->type_payment, 'none');
  701. }
  702. print '</td></tr>';
  703. // Default Bank Account
  704. if (!empty($conf->banque->enabled)) {
  705. print '<tr><td class="nowrap">';
  706. print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
  707. print $langs->trans('DefaultBankAccount');
  708. print '<td>';
  709. if ($action != 'editbankaccount' && $user->rights->salaries->write) {
  710. 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>';
  711. }
  712. print '</tr></table>';
  713. print '</td><td>';
  714. if ($action == 'editbankaccount') {
  715. $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
  716. } else {
  717. $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
  718. }
  719. print '</td>';
  720. print '</tr>';
  721. }
  722. // Other attributes
  723. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
  724. print '</table>';
  725. print '</div>';
  726. print '<div class="fichehalfright">';
  727. print '<div class="ficheaddleft">';
  728. $nbcols = 3;
  729. if (!empty($conf->banque->enabled)) {
  730. $nbcols++;
  731. }
  732. /*
  733. * Payments
  734. */
  735. $sql = "SELECT p.rowid, p.num_payment as num_payment, p.datep as dp, p.amount,";
  736. $sql .= " c.code as type_code,c.libelle as paiement_type,";
  737. $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';
  738. $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p";
  739. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
  740. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
  741. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id";
  742. $sql .= ", ".MAIN_DB_PREFIX."salary as salaire";
  743. $sql .= " WHERE p.fk_salary = ".((int) $id);
  744. $sql .= " AND p.fk_salary = salaire.rowid";
  745. $sql .= " AND salaire.entity IN (".getEntity('tax').")";
  746. $sql .= " ORDER BY dp DESC";
  747. //print $sql;
  748. $resql = $db->query($sql);
  749. if ($resql) {
  750. $totalpaye = 0;
  751. $num = $db->num_rows($resql);
  752. $i = 0; $total = 0;
  753. print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
  754. print '<table class="noborder paymenttable">';
  755. print '<tr class="liste_titre">';
  756. print '<td>'.$langs->trans("RefPayment").'</td>';
  757. print '<td>'.$langs->trans("Date").'</td>';
  758. print '<td>'.$langs->trans("Type").'</td>';
  759. if (!empty($conf->banque->enabled)) {
  760. print '<td class="liste_titre right">'.$langs->trans('BankAccount').'</td>';
  761. }
  762. print '<td class="right">'.$langs->trans("Amount").'</td>';
  763. print '</tr>';
  764. if ($num > 0) {
  765. $bankaccountstatic = new Account($db);
  766. while ($i < $num) {
  767. $objp = $db->fetch_object($resql);
  768. print '<tr class="oddeven"><td>';
  769. print '<a href="'.DOL_URL_ROOT.'/salaries/payment_salary/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.'</a></td>';
  770. print '<td>'.dol_print_date($db->jdate($objp->dp), 'day')."</td>\n";
  771. $labeltype = $langs->trans("PaymentType".$objp->type_code) != ("PaymentType".$objp->type_code) ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type;
  772. print "<td>".$labeltype.' '.$objp->num_payment."</td>\n";
  773. if (!empty($conf->banque->enabled)) {
  774. $bankaccountstatic->id = $objp->baid;
  775. $bankaccountstatic->ref = $objp->baref;
  776. $bankaccountstatic->label = $objp->baref;
  777. $bankaccountstatic->number = $objp->banumber;
  778. $bankaccountstatic->currency_code = $objp->bacurrency_code;
  779. if (!empty($conf->accounting->enabled)) {
  780. $bankaccountstatic->account_number = $objp->account_number;
  781. $accountingjournal = new AccountingJournal($db);
  782. $accountingjournal->fetch($objp->fk_accountancy_journal);
  783. $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
  784. }
  785. print '<td class="right">';
  786. if ($bankaccountstatic->id)
  787. print $bankaccountstatic->getNomUrl(1, 'transactions');
  788. print '</td>';
  789. }
  790. print '<td class="right">'.price($objp->amount)."</td>\n";
  791. print "</tr>";
  792. $totalpaye += $objp->amount;
  793. $i++;
  794. }
  795. } else {
  796. print '<tr class="oddeven"><td><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
  797. print '<td></td><td></td><td></td><td></td>';
  798. print '</tr>';
  799. }
  800. print '<tr><td colspan="'.$nbcols.'" class="right">'.$langs->trans("AlreadyPaid")." :</td><td class=\"right\">".price($totalpaye)."</td></tr>\n";
  801. print '<tr><td colspan="'.$nbcols.'" class="right">'.$langs->trans("AmountExpected")." :</td><td class=\"right\">".price($object->amount)."</td></tr>\n";
  802. $resteapayer = $object->amount - $totalpaye;
  803. $cssforamountpaymentcomplete = 'amountpaymentcomplete';
  804. print '<tr><td colspan="'.$nbcols.'" class="right">'.$langs->trans("RemainderToPay")." :</td>";
  805. print '<td class="right'.($resteapayer ? ' amountremaintopay' : (' '.$cssforamountpaymentcomplete)).'">'.price($resteapayer)."</td></tr>\n";
  806. print "</table>";
  807. print '</div>';
  808. $db->free($resql);
  809. } else {
  810. dol_print_error($db);
  811. }
  812. print '</div>';
  813. print '</div>';
  814. print '</div>';
  815. print '<div class="clearboth"></div>';
  816. if ($action == 'edit') {
  817. print $form->buttonsSaveCancel();
  818. print "</form>";
  819. }
  820. print dol_get_fiche_end();
  821. /*
  822. * Action bar
  823. */
  824. print '<div class="tabsAction">'."\n";
  825. if ($action != 'edit') {
  826. // Reopen
  827. if ($object->paye && $user->rights->salaries->write) {
  828. print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT."/salaries/card.php?id=".$object->id.'&action=reopen&token='.newToken().'">'.$langs->trans("ReOpen")."</a></div>";
  829. }
  830. // Edit
  831. if ($object->paye == 0 && $user->rights->salaries->write) {
  832. print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT."/salaries/card.php?id=".$object->id.'&action=edit&token='.newToken().'">'.$langs->trans("Modify")."</a></div>";
  833. }
  834. // Emit payment
  835. if ($object->paye == 0 && ((price2num($object->amount) < 0 && price2num($resteapayer, 'MT') < 0) || (price2num($object->amount) > 0 && price2num($resteapayer, 'MT') > 0)) && $user->rights->salaries->write) {
  836. print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT."/salaries/paiement_salary.php?id=".$object->id.'&action=create&token='.newToken().'">'.$langs->trans("DoPayment")."</a></div>";
  837. }
  838. // Classify 'paid'
  839. if ($object->paye == 0
  840. && (
  841. (round($resteapayer) <= 0 && $object->amount > 0)
  842. || (round($resteapayer) >= 0 && $object->amount < 0)
  843. )
  844. && $user->rights->salaries->write) {
  845. print "<div class=\"inline-block divButAction\"><a class=\"butAction\" href=\"".DOL_URL_ROOT."/salaries/card.php?id=".$object->id.'&action=paid&token='.newToken().'">'.$langs->trans("ClassifyPaid")."</a></div>";
  846. }
  847. // Clone
  848. if ($user->rights->salaries->write) {
  849. print "<div class=\"inline-block divButAction\"><a class=\"butAction\" href=\"".DOL_URL_ROOT."/salaries/card.php?id=".$object->id.'&action=clone&token='.newToken().'">'.$langs->trans("ToClone")."</a></div>";
  850. }
  851. if (!empty($user->rights->salaries->delete) && empty($totalpaye)) {
  852. print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete").'</a></div>';
  853. } else {
  854. print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.(dol_escape_htmltag($langs->trans("DisabledBecausePayments"))).'">'.$langs->trans("Delete").'</a></div>';
  855. }
  856. }
  857. print "</div>";
  858. }
  859. // End of page
  860. llxFooter();
  861. $db->close();