FIX : autofill payment salary amount + several fixes
This commit is contained in:
parent
a906b1437c
commit
368bad1943
@ -73,23 +73,23 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'y
|
||||
$action = 'create';
|
||||
}
|
||||
|
||||
// Read possible payments
|
||||
foreach ($_POST as $key => $value) {
|
||||
if (substr($key, 0, 7) == 'amount_') {
|
||||
$other_chid = substr($key, 7);
|
||||
$amounts[$other_chid] = price2num(GETPOST($key));
|
||||
}
|
||||
}
|
||||
|
||||
if ($amounts[key($amounts)] <= 0) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors');
|
||||
$action = 'create';
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$paymentid = 0;
|
||||
|
||||
// Read possible payments
|
||||
foreach ($_POST as $key => $value) {
|
||||
if (substr($key, 0, 7) == 'amount_') {
|
||||
$other_chid = substr($key, 7);
|
||||
$amounts[$other_chid] = price2num(GETPOST($key));
|
||||
}
|
||||
}
|
||||
|
||||
if (count($amounts) <= 0) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorNoPaymentDefined"), null, 'errors');
|
||||
$action = 'create';
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$db->begin();
|
||||
|
||||
|
||||
@ -234,7 +234,7 @@ $help_url = '';
|
||||
$title = $langs->trans('Salaries');
|
||||
|
||||
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.admin, u.salary as current_salary, u.fk_soc as fk_soc, u.statut as status,";
|
||||
$sql .= " s.rowid, s.fk_account, s.paye, s.fk_user, s.amount, s.salary, s.label, s.datesp, s.dateep, ps.fk_typepayment as paymenttype, ";
|
||||
$sql .= " s.rowid, s.fk_account, s.paye, s.fk_user, s.amount, s.salary, s.label, s.datesp, s.dateep, s.fk_typepayment as paymenttype, ";
|
||||
$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 .= " pst.code as payment_code,";
|
||||
$sql .= " SUM(ps.amount) as alreadypayed";
|
||||
@ -279,7 +279,7 @@ if ($search_type_id) {
|
||||
$sql .= " AND s.fk_typepayment=".$search_type_id;
|
||||
}
|
||||
$sql .= " GROUP BY u.rowid, u.lastname, u.firstname, u.login, u.email, u.admin, u.salary, u.fk_soc, u.statut,";
|
||||
$sql .= " s.rowid, s.fk_account, s.paye, s.fk_user, s.amount, s.salary, s.label, s.datesp, s.dateep, ps.fk_typepayment, s.fk_bank,";
|
||||
$sql .= " s.rowid, s.fk_account, s.paye, s.fk_user, s.amount, s.salary, s.label, s.datesp, s.dateep, s.fk_typepayment, s.fk_bank,";
|
||||
$sql .= " ba.rowid, ba.ref, ba.number, ba.account_number, ba.fk_accountancy_journal, ba.label,";
|
||||
$sql .= " pst.code";
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
|
||||
@ -74,23 +74,23 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'y
|
||||
$action = 'create';
|
||||
}
|
||||
|
||||
// Read possible payments
|
||||
foreach ($_POST as $key => $value) {
|
||||
if (substr($key, 0, 7) == 'amount_') {
|
||||
$other_chid = substr($key, 7);
|
||||
$amounts[$other_chid] = price2num($_POST[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($amounts[key($amounts)] <= 0) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors');
|
||||
$action = 'create';
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$paymentid = 0;
|
||||
|
||||
// Read possible payments
|
||||
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) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorNoPaymentDefined"), null, 'errors');
|
||||
$action = 'create';
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$db->begin();
|
||||
|
||||
@ -271,12 +271,13 @@ if ($action == 'create') {
|
||||
if ($sumpaid < $objp->amount) {
|
||||
$namef = "amount_".$objp->id;
|
||||
$nameRemain = "remain_".$objp->id;
|
||||
/* Disabled, we autofil the amount with remain to pay by default
|
||||
if (!empty($conf->use_javascript_ajax)) {
|
||||
print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmount' data-rowid='".$namef."' data-value='".($objp->amount - $sumpaid)."'");
|
||||
}
|
||||
} */
|
||||
$remaintopay = $objp->amount - $sumpaid;
|
||||
print '<input type=hidden class="sum_remain" name="'.$nameRemain.'" value="'.$remaintopay.'">';
|
||||
print '<input type="text" size="8" name="'.$namef.'" id="'.$namef.'">';
|
||||
print '<input type="text" size="8" name="'.$namef.'" id="'.$namef.'" value="'.$remaintopay.'">';
|
||||
} else {
|
||||
print '-';
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user