diff --git a/htdocs/salaries/admin/salaries.php b/htdocs/salaries/admin/salaries.php index 2b429dc79ec..01f25d56d05 100644 --- a/htdocs/salaries/admin/salaries.php +++ b/htdocs/salaries/admin/salaries.php @@ -27,14 +27,17 @@ require '../../main.inc.php'; // Class require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php'; -if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +if (!empty($conf->accounting->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +} // Load translation files required by the page $langs->loadLangs(array('admin', 'salaries')); // Security check -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} $action = GETPOST('action', 'aZ09'); @@ -47,8 +50,7 @@ $list = array( * Actions */ -if ($action == 'update') -{ +if ($action == 'update') { $error = 0; foreach ($list as $constname) { @@ -59,8 +61,7 @@ if ($action == 'update') } } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); @@ -74,7 +75,9 @@ if ($action == 'update') llxHeader('', $langs->trans('SalariesSetup')); $form = new Form($db); -if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); +if (!empty($conf->accounting->enabled)) { + $formaccounting = new FormAccounting($db); +} $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans('SalariesSetup'), $linkback, 'title_setup'); @@ -99,8 +102,7 @@ print ''.$langs->trans("Parameters").''; print ''.$langs->trans("Value")."\n"; print "\n"; -foreach ($list as $key) -{ +foreach ($list as $key) { print ''; // Param @@ -109,8 +111,7 @@ foreach ($list as $key) // Value print ''; - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); } else { print ''; diff --git a/htdocs/salaries/admin/salaries_extrafields.php b/htdocs/salaries/admin/salaries_extrafields.php index 62073f8177b..59074e582d2 100644 --- a/htdocs/salaries/admin/salaries_extrafields.php +++ b/htdocs/salaries/admin/salaries_extrafields.php @@ -36,13 +36,17 @@ $form = new Form($db); // List of supported format $tmptype2label = ExtraFields::$type2label; $type2label = array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} $action = GETPOST('action', 'aZ09'); $attrname = GETPOST('attrname', 'alpha'); $elementtype = 'payment_salary'; //Must be the $table_element of the class that manage extrafield -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} /* @@ -77,8 +81,7 @@ print dol_get_fiche_end(); // Buttons -if ($action != 'create' && $action != 'edit') -{ +if ($action != 'create' && $action != 'edit') { print '
'; print '
".$langs->trans("NewAttribute").'
'; print "
"; @@ -91,8 +94,7 @@ if ($action != 'create' && $action != 'edit') /* */ /* ************************************************************************** */ -if ($action == 'create') -{ +if ($action == 'create') { print '

'; print load_fiche_titre($langs->trans('NewAttribute')); @@ -104,8 +106,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && !empty($attrname)) -{ +if ($action == 'edit' && !empty($attrname)) { print '

'; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 2fc71bec099..af2aecdfe14 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -31,15 +31,16 @@ require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -if (!empty($conf->projet->enabled)) -{ +if (!empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } // Load translation files required by the page $langs->loadLangs(array("compta", "banks", "bills", "users", "salaries", "hrm")); -if (!empty($conf->projet->enabled)) $langs->load("projects"); +if (!empty($conf->projet->enabled)) { + $langs->load("projects"); +} $id = GETPOST("id", 'int'); $action = GETPOST('action', 'aZ09'); @@ -54,7 +55,9 @@ $dateep = dol_mktime(12, 0, 0, GETPOST("dateepmonth", 'int'), GETPOST("dateepday // Security check $socid = GETPOST("socid", "int"); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'salaries', '', '', ''); $object = new PaymentSalary($db); @@ -71,24 +74,23 @@ $hookmanager->initHooks(array('salarycard', 'globalcard')); * Actions */ -if ($cancel) -{ +if ($cancel) { header("Location: list.php"); exit; } // Link to a project -if ($action == 'classin' && $user->rights->banque->modifier) -{ +if ($action == 'classin' && $user->rights->banque->modifier) { $object->fetch($id); $object->setProject($projectid); } -if ($action == 'add' && empty($cancel)) -{ +if ($action == 'add' && empty($cancel)) { $error = 0; - if (empty($datev)) $datev = $datep; + if (empty($datev)) { + $datev = $datep; + } $type_payment = dol_getIdFromCode($db, GETPOST("paymenttype", 'alpha'), 'c_paiement', 'code', 'id', 1); @@ -113,41 +115,36 @@ if ($action == 'add' && empty($cancel)) // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } - if (empty($datep) || empty($datev) || empty($datesp) || empty($dateep)) - { + if (empty($datep) || empty($datev) || empty($datesp) || empty($dateep)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); $error++; } - if (empty($object->fk_user) || $object->fk_user < 0) - { + if (empty($object->fk_user) || $object->fk_user < 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Employee")), null, 'errors'); $error++; } - if (empty($type_payment) || $type_payment < 0) - { + if (empty($type_payment) || $type_payment < 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors'); $error++; } - if (empty($object->amount)) - { + if (empty($object->amount)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors'); $error++; } - if (!empty($conf->banque->enabled) && !$object->accountid > 0) - { + if (!empty($conf->banque->enabled) && !$object->accountid > 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors'); $error++; } - if (!$error) - { + if (!$error) { $db->begin(); $ret = $object->create($user); - if ($ret > 0) - { + if ($ret > 0) { $db->commit(); if (GETPOST('saveandnew', 'alpha')) { @@ -168,26 +165,23 @@ if ($action == 'add' && empty($cancel)) $action = 'create'; } -if ($action == 'delete') -{ +if ($action == 'delete') { $result = $object->fetch($id); - if ($object->rappro == 0) - { + if ($object->rappro == 0) { $db->begin(); $ret = $object->delete($user); - if ($ret > 0) - { - if ($object->fk_bank) - { + if ($ret > 0) { + if ($object->fk_bank) { $accountline = new AccountLine($db); $result = $accountline->fetch($object->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) { + $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) - { + if ($result >= 0) { $db->commit(); header("Location: ".DOL_URL_ROOT.'/salaries/list.php'); exit; @@ -213,27 +207,25 @@ if ($action == 'delete') llxHeader("", $langs->trans("SalaryPayment")); $form = new Form($db); -if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db); +if (!empty($conf->projet->enabled)) { + $formproject = new FormProjets($db); +} -if ($id) -{ +if ($id) { $object = new PaymentSalary($db); $result = $object->fetch($id); - if ($result <= 0) - { + if ($result <= 0) { dol_print_error($db); exit; } } // Create -if ($action == 'create') -{ +if ($action == 'create') { $year_current = strftime("%Y", dol_now()); $pastmonth = strftime("%m", dol_now()) - 1; $pastmonthyear = $year_current; - if ($pastmonth == 0) - { + if ($pastmonth == 0) { $pastmonth = 12; $pastmonthyear--; } @@ -247,8 +239,7 @@ if ($action == 'create') $datesp = dol_mktime(0, 0, 0, $datespmonth, $datespday, $datespyear); $dateep = dol_mktime(23, 59, 59, $dateepmonth, $dateepday, $dateepyear); - if (empty($datesp) || empty($dateep)) // We define date_start and date_end - { + if (empty($datesp) || empty($dateep)) { // We define date_start and date_end $datesp = dol_get_first_day($pastmonthyear, $pastmonth, false); $dateep = dol_get_last_day($pastmonthyear, $pastmonth, false); } @@ -306,8 +297,7 @@ if ($action == 'create') print ''; // Bank - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) { print ''; print $form->editfieldkey('BankAccount', 'selectaccountid', '', $object, 0, 'string', '', 1).''; $form->select_comptes($accountid, "accountid", 0, '', 1); // Affiche liste des comptes courant @@ -321,8 +311,7 @@ if ($action == 'create') print ''; // Number - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) { // Number print '