$sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (!$sortorder) { $sortorder = "ASC"; } if (!$sortfield) { $sortfield = "name"; } $object = new PaymentSalary($db); $object->fetch($id, $ref); $upload_dir = $conf->salaries->dir_output . '/' . dol_sanitizeFileName($object->id); $modulepart = 'salaries'; /* * Actions */ include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php'; /* * View */ $form = new Form($db); llxHeader("", "", $langs->trans("SalaryPayment")); if ($object->id) { $object->fetch_thirdparty(); $head = salaries_prepare_head($object); dol_fiche_head($head, 'documents', $langs->trans("SalaryPayment"), 0, 'payment');
} else { $db->rollback(); setEventMessage($object->error, 'errors'); } } else { setEventMessage('Error try do delete a line linked to a conciliated bank transaction', 'errors'); } } /* * View */ llxHeader(); $form = new Form($db); if ($id) { $object = new PaymentSalary($db); $result = $object->fetch($id); if ($result <= 0) { dol_print_error($db); exit; } } // Formulaire saisie salaire if ($action == 'create') { $year_current = strftime("%Y", dol_now()); $pastmonth = strftime("%m", dol_now()) - 1; $pastmonthyear = $year_current; if ($pastmonth == 0) { $pastmonth = 12; $pastmonthyear--; } $datesp = dol_mktime(0, 0, 0, $datespmonth, $datespday, $datespyear);
$db->begin(); $ret = $sal->create($user); if ($ret > 0) { $db->commit(); header("Location: index.php"); exit; } else { $db->rollback(); setEventMessage($sal->error, 'errors'); $action = "create"; } } $action = 'create'; } if ($action == 'delete') { $result = $sal->fetch($id); if ($sal->rappro == 0) { $db->begin(); $ret = $sal->delete($user); if ($ret > 0) { if ($sal->fk_bank) { $accountline = new AccountLine($db); $result = $accountline->fetch($sal->fk_bank); if ($result > 0) { $result = $accountline->delete($user); } // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing) } if ($result >= 0) { $db->commit(); header("Location: " . DOL_URL_ROOT . '/compta/salaries/index.php');