diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index b8de918d66a..29f1fb5ca3e 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -207,7 +207,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; $sql .= " WHERE datep between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; - //$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT; + //$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT; } // Social contributions if (GETPOST('selectsocialcontributions')) { diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index 7dce76c6379..2661678d411 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -415,6 +415,8 @@ while ($j < $numlt) { $num = $db->num_rows($result); $i = 0; $total = 0; + + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'width="120"', $sortfield, $sortorder); @@ -456,6 +458,8 @@ while ($j < $numlt) { print ""; print "
"; + print '
'; + $db->free($result); } else { dol_print_error($db); @@ -464,115 +468,6 @@ while ($j < $numlt) { $j++; } - -// Payment Salary -/* -if (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) -{ - $sal = new Salary($db); - - print "
"; - - print load_fiche_titre($langs->trans("SalariesPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); - - $sql = "SELECT s.rowid, s.amount, s.label, s.datep as datep, s.datev as datev, s.datesp, s.dateep, s.salary, s.fk_bank, u.salary as current_salary,"; - $sql .= " pct.code as payment_code,"; - $sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; - $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON s.fk_typepayment = pct.id"; - $sql .= " , ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE s.entity IN (".getEntity('user').")"; - $sql .= " AND u.rowid = s.fk_user"; - if ($year > 0) - { - $sql .= " AND (s.datesp between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; - $sql .= " OR s.dateep between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."')"; - } - if (preg_match('/^s\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder); - - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $i = 0; - $total = 0; - print ''; - print ''; - print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "s.dateep", "", $param, 'width="140px"', $sortfield, $sortorder); - print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "s.label", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "s.rowid", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "s.datep", "", $param, 'align="center"', $sortfield, $sortorder); - print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); - if (!empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder); - print "\n"; - - while ($i < $num) - { - $obj = $db->fetch_object($result); - - $total = $total + $obj->amount; - - - print ''; - - print ''."\n"; - - print "\n"; - - // Ref payment - $sal_static->id = $obj->rowid; - $sal_static->ref = $obj->rowid; - print '\n"; - - // Date - print '\n"; - - // Type payment - print ''; - - // Account - if (!empty($conf->banque->enabled)) - { - print ''; - } - - // Paid - print '"; - print "\n"; - - $i++; - } - print ''; - print '"; - print ""; - - print "
'.dol_print_date($db->jdate($obj->dateep), 'day').'".$obj->label."'.$sal_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->datep), 'day')."'; - if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; - print $obj->num_payment.''; - if ($obj->fk_bank > 0) - { - //$accountstatic->fetch($obj->fk_bank); - $accountstatic->id = $obj->bid; - $accountstatic->ref = $obj->bref; - $accountstatic->number = $obj->bnumber; - $accountstatic->accountancy_number = $obj->account_number; - $accountstatic->accountancy_journal = $obj->accountancy_journal; - $accountstatic->label = $obj->blabel; - print $accountstatic->getNomUrl(1); - } else print ' '; - print ''.price($obj->amount)."
'.$langs->trans("Total").''.price($total)."
"; - $db->free($result); - - print "
"; - } else { - dol_print_error($db); - } -} -*/ - print ''; $parameters = array('user' => $user); diff --git a/htdocs/core/lib/salaries.lib.php b/htdocs/core/lib/salaries.lib.php index f2e5fd4baf0..57cb9675e3f 100644 --- a/htdocs/core/lib/salaries.lib.php +++ b/htdocs/core/lib/salaries.lib.php @@ -34,7 +34,7 @@ function salaries_prepare_head($object) $head = array(); $head[$h][0] = DOL_URL_ROOT.'/salaries/card.php?id='.$object->id; - $head[$h][1] = $langs->trans("Salary"); + $head[$h][1] = $langs->trans("Salary"); $head[$h][2] = 'card'; $h++; diff --git a/htdocs/salaries/paiement_salary.php b/htdocs/salaries/paiement_salary.php index 81b1c5c42c9..1b5924ba7c4 100644 --- a/htdocs/salaries/paiement_salary.php +++ b/htdocs/salaries/paiement_salary.php @@ -37,8 +37,7 @@ $amounts = array(); // Security check $socid = 0; -if ($user->socid > 0) -{ +if ($user->socid > 0) { $socid = $user->socid; } @@ -47,61 +46,51 @@ if ($user->socid > 0) * Actions */ -if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'yes')) -{ +if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'yes')) { $error = 0; - if ($_POST["cancel"]) - { + if ($_POST["cancel"]) { $loc = DOL_URL_ROOT.'/salaries/card.php?id='.$chid; header("Location: ".$loc); exit; } - $datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + $datepaye = dol_mktime(12, 0, 0, GETPOST("remonth", 'int'), GETPOST("reday", 'int'), GETPOST("reyear", 'int')); - if (!$_POST["paiementtype"] > 0) - { + if (!(GETPOST("paiementtype", 'int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")), null, 'errors'); $error++; $action = 'create'; } - if ($datepaye == '') - { + if ($datepaye == '') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors'); $error++; $action = 'create'; } - if (!empty($conf->banque->enabled) && !($_POST["accountid"] > 0)) - { + if (!empty($conf->banque->enabled) && !(GETPOST("accountid", 'int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToCredit")), null, 'errors'); $error++; $action = 'create'; } - if (!$error) - { + if (!$error) { $paymentid = 0; // Read possible payments - foreach ($_POST as $key => $value) - { - if (substr($key, 0, 7) == 'amount_') - { + foreach ($_POST as $key => $value) { + if (substr($key, 0, 7) == 'amount_') { $other_chid = substr($key, 7); $amounts[$other_chid] = price2num($_POST[$key]); } } - if (count($amounts) <= 0) - { + if (count($amounts) <= 0) { $error++; setEventMessages($langs->trans("ErrorNoPaymentDefined"), null, 'errors'); $action = 'create'; } - if (!$error) - { + if (!$error) { $db->begin(); // Create a line of payments @@ -114,36 +103,30 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'y $paiement->note = GETPOST("note", 'none'); $paiement->note_private = GETPOST("note", 'none'); - if (!$error) - { + if (!$error) { $paymentid = $paiement->create($user, (GETPOST('closepaidsalary') == 'on' ? 1 : 0)); - if ($paymentid < 0) - { + if ($paymentid < 0) { $error++; setEventMessages($paiement->error, null, 'errors'); $action = 'create'; } } - if (!$error) - { + if (!$error) { $result = $paiement->addPaymentToBank($user, 'payment_salary', '(SalaryPayment)', GETPOST('accountid', 'int'), '', ''); - if (!($result > 0)) - { + if (!($result > 0)) { $error++; setEventMessages($paiement->error, null, 'errors'); $action = 'create'; } } - if (!$error) - { + if (!$error) { $db->commit(); $loc = DOL_URL_ROOT.'/salaries/card.php?id='.$chid; header('Location: '.$loc); exit; - } - else { + } else { $db->rollback(); } } @@ -161,16 +144,14 @@ $form = new Form($db); // Formulaire de creation d'un paiement de charge -if ($action == 'create') -{ +if ($action == 'create') { $salary = new Salary($db); $salary->fetch($chid); $salary->accountid = $salary->fk_account ? $salary->fk_account : $salary->accountid; $salary->paiementtype = $salary->mode_reglement_id ? $salary->mode_reglement_id : $salary->paiementtype; $total = $salary->amount; - if (!empty($conf->use_javascript_ajax)) - { + if (!empty($conf->use_javascript_ajax)) { print "\n".'