From 75fa3cf6439a25266d721ac0468eb6a69d21d3a0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 12 Aug 2022 15:45:27 +0200 Subject: [PATCH] Debug v16 --- .../class/accountingjournal.class.php | 2 +- htdocs/compta/bank/class/account.class.php | 4 +-- htdocs/expensereport/card.php | 10 ++++--- .../class/paymentexpensereport.class.php | 14 +++++---- htdocs/expensereport/payment/payment.php | 30 +++++++++++-------- htdocs/holiday/view_log.php | 1 + 6 files changed, 37 insertions(+), 24 deletions(-) diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index d805838566f..c8948b05012 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -281,7 +281,7 @@ class AccountingJournal extends CommonObject } $label_link = $this->code; - if ($withlabel) { + if ($withlabel && !empty($this->label)) { $label_link .= ' - '.($nourl ? '' : '').$langs->transnoentities($this->label).($nourl ? '' : ''); } diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 21a082e9491..4c728adbfc8 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -618,7 +618,7 @@ class Account extends CommonObject $this->error = $this->db->lasterror(); $this->db->rollback(); - return -3; + return -4; } } @@ -630,7 +630,7 @@ class Account extends CommonObject $this->errors = $accline->errors; $this->db->rollback(); - return -2; + return -5; } } diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index c714ad452c1..1da36a72e32 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1950,7 +1950,7 @@ if ($action == 'create') { // Payments already done (from payment on this expensereport) $sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,"; - $sql .= "c.code as p_code, c.libelle as payment_type,"; + $sql .= "c.code as payment_code, c.libelle as payment_type,"; $sql .= "ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal"; $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."payment_expensereport as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; @@ -1969,18 +1969,20 @@ if ($action == 'create') { $objp = $db->fetch_object($resql); $paymentexpensereportstatic->id = $objp->rowid; - $paymentexpensereportstatic->datepaye = $db->jdate($objp->dp); + $paymentexpensereportstatic->datep = $db->jdate($objp->dp); $paymentexpensereportstatic->ref = $objp->rowid; $paymentexpensereportstatic->num_payment = $objp->num_payment; - $paymentexpensereportstatic->payment_code = $objp->payment_code; + $paymentexpensereportstatic->type_code = $objp->payment_code; + $paymentexpensereportstatic->type_label = $objp->payment_type; print ''; print ''; print $paymentexpensereportstatic->getNomUrl(1); print ''; print ''.dol_print_date($db->jdate($objp->dp), 'day')."\n"; - $labeltype = $langs->trans("PaymentType".$objp->p_code) != ("PaymentType".$objp->p_code) ? $langs->trans("PaymentType".$objp->p_code) : $objp->payment_type; + $labeltype = $langs->trans("PaymentType".$objp->payment_code) != ("PaymentType".$objp->payment_code) ? $langs->trans("PaymentType".$objp->payment_code) : $objp->payment_type; print "".$labeltype.' '.$objp->num_payment."\n"; + // Bank account if (!empty($conf->banque->enabled)) { $bankaccountstatic->id = $objp->baid; $bankaccountstatic->ref = $objp->baref; diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index 5f9e9f17e6f..f7ff6cf7e9c 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -137,14 +137,17 @@ class PaymentExpenseReport extends CommonObject if (isset($this->note_public)) { $this->note_public = trim($this->note_public); } + if (isset($this->note_private)) { + $this->note_private = trim($this->note_private); + } if (isset($this->fk_bank)) { - $this->fk_bank = trim($this->fk_bank); + $this->fk_bank = ((int) $this->fk_bank); } if (isset($this->fk_user_creat)) { - $this->fk_user_creat = trim($this->fk_user_creat); + $this->fk_user_creat = ((int) $this->fk_user_creat); } if (isset($this->fk_user_modif)) { - $this->fk_user_modif = trim($this->fk_user_modif); + $this->fk_user_modif = ((int) $this->fk_user_modif); } $totalamount = 0; @@ -170,7 +173,7 @@ class PaymentExpenseReport extends CommonObject $sql .= " '".$this->db->idate($this->datepaid)."',"; $sql .= " ".price2num($totalamount).","; $sql .= " ".((int) $this->fk_typepayment).", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note_public)."', ".((int) $user->id).","; - $sql .= " 0)"; + $sql .= " 0)"; // fk_bank is ID of transaction into ll_bank dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); @@ -540,7 +543,7 @@ class PaymentExpenseReport extends CommonObject ); // Update fk_bank in llx_paiement. - // On connait ainsi le paiement qui a genere l'ecriture bancaire + // So we wil know the payment that have generated the bank transaction if ($bank_line_id > 0) { $result = $this->update_fk_bank($bank_line_id); if ($result <= 0) { @@ -585,6 +588,7 @@ class PaymentExpenseReport extends CommonObject } } else { $this->error = $acc->error; + $this->errors = $acc->errors; $error++; } } diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php index 185b3cdc139..1c2cead08ea 100644 --- a/htdocs/expensereport/payment/payment.php +++ b/htdocs/expensereport/payment/payment.php @@ -75,6 +75,7 @@ if ($action == 'add_payment') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors'); $error++; } + if (!empty($conf->banque->enabled) && !($accountid > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToDebit")), null, 'errors'); $error++; @@ -87,14 +88,16 @@ if ($action == 'add_payment') { // Read possible payments foreach ($_POST as $key => $value) { if (substr($key, 0, 7) == 'amount_') { - $amounts[$expensereport->fk_user_author] = price2num(GETPOST($key)); - $total += price2num(GETPOST($key)); + if (GETPOST($key)) { + $amounts[$expensereport->fk_user_author] = price2num(GETPOST($key)); + $total += price2num(GETPOST($key)); + } } } if (count($amounts) <= 0) { $error++; - $errmsg = 'ErrorNoPaymentDefined'; + setEventMessages('ErrorNoPaymentDefined', null, 'errors'); } if (!$error) { @@ -109,6 +112,7 @@ if ($action == 'add_payment') { $payment->fk_typepayment = GETPOST("fk_typepayment", 'int'); $payment->num_payment = GETPOST("num_payment", 'alphanothtml'); $payment->note_public = GETPOST("note_public", 'restricthtml'); + $payment->fk_bank = $accountid; if (!$error) { $paymentid = $payment->create($user); @@ -120,7 +124,7 @@ if ($action == 'add_payment') { if (!$error) { $result = $payment->addPaymentToBank($user, 'payment_expensereport', '(ExpenseReportPayment)', $accountid, '', ''); - if (!$result > 0) { + if ($result <= 0) { setEventMessages($payment->error, $payment->errors, 'errors'); $error++; } @@ -202,7 +206,7 @@ if ($action == 'create' || empty($action)) { print ''."\n"; print ''; - print ''; + print ''; $sql = "SELECT sum(p.amount) as total"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_expensereport as p, ".MAIN_DB_PREFIX."expensereport as e"; @@ -214,8 +218,8 @@ if ($action == 'create' || empty($action)) { $sumpaid = $obj->total; $db->free($resql); } - print ''; - print ''; + print ''; + print ''; print '
'.$langs->trans("Period").''.get_date_range($expensereport->date_debut, $expensereport->date_fin, "", $langs, 0).'
'.$langs->trans("Amount").''.price($expensereport->total_ttc, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans("Amount").''.price($expensereport->total_ttc, 0, $langs, 1, -1, -1, $conf->currency).'
'.$langs->trans("AlreadyPaid").''.price($sumpaid, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans("RemainderToPay").''.price($total - $sumpaid, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans("AlreadyPaid").''.price($sumpaid, 0, $langs, 1, -1, -1, $conf->currency).'
'.$langs->trans("RemainderToPay").''.price($total - $sumpaid, 0, $langs, 1, -1, -1, $conf->currency).'
'; @@ -223,6 +227,8 @@ if ($action == 'create' || empty($action)) { print dol_get_fiche_end(); + print '
'; + print dol_get_fiche_head(); print ''."\n"; @@ -243,7 +249,8 @@ if ($action == 'create' || empty($action)) { print ''; print ''; print ''; } @@ -277,7 +284,7 @@ if ($action == 'create' || empty($action)) { print ''; print "\n"; - $total = 0; + $total_ttc = 0; $totalrecu = 0; while ($i < $num) { @@ -298,7 +305,7 @@ if ($action == 'create' || empty($action)) { } $remaintopay = $objp->total_ttc - $sumpaid; // autofill remainder amount print ''; // autofill remainder amount - print ''; + print ''; } else { print '-'; } @@ -306,9 +313,8 @@ if ($action == 'create' || empty($action)) { print "\n"; - $total += $objp->total; $total_ttc += $objp->total_ttc; - $totalrecu += $objp->am; + $totalrecu += $sumpaid; $i++; } if ($i > 1) { diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php index 8396444719e..ea71deb4d26 100644 --- a/htdocs/holiday/view_log.php +++ b/htdocs/holiday/view_log.php @@ -489,6 +489,7 @@ while ($i < min($num, $limit)) { // Type if (!empty($arrayfields['cpl.fk_type']['checked'])) { + $label = ''; if (!empty($alltypeleaves[$holidaylogstatic->type])) { if ($alltypeleaves[$holidaylogstatic->type]['code'] && $langs->trans($alltypeleaves[$holidaylogstatic->type]['code']) != $alltypeleaves[$holidaylogstatic->type]['code']) { $label = $langs->trans($alltypeleaves[$holidaylogstatic->type]['code']);
'.$langs->trans('AccountToDebit').''; - $form->select_comptes(GETPOSTISSET("accountid") ? GETPOST("accountid", "int") : $expensereport->accountid, "accountid", 0, '', 2); // Show open bank account list + print img_picto('', 'bank_account', 'class="pictofixedwidth"'); + $form->select_comptes(GETPOSTISSET("accountid") ? GETPOST("accountid", "int") : 0, "accountid", 0, '', 2); // Show open bank account list print '
'.$langs->trans("Amount").'