diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 6dc25efef4f..8766aca3412 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1388,7 +1388,7 @@ else if ($ret == 'html') print '
'; } - print ''; + print '
'; $linkback = ''.$langs->trans("BackToList").''; @@ -1431,7 +1431,7 @@ else * Payments */ $sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount,"; - $sql.= "c.code as type_code,c.libelle as paiement_type"; + $sql.= "c.code as type_code,c.libelle as payment_type"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_expensereport as p"; $sql.= ", ".MAIN_DB_PREFIX."c_paiement as c "; $sql.= ", ".MAIN_DB_PREFIX."expensereport as e"; @@ -1464,18 +1464,18 @@ else print "'; print '\n"; - $labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->paiement_type; - print "\n"; - print '\n"; + $labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->payment_type; + print "\n"; + print '\n"; print ""; - $totalpaid += $objp->total_ttc; + $totalpaid += $objp->amount; $i++; } if ($object->paid == 0) { print "\n"; - print "\n"; + print "\n"; $remaintopay = $object->total_ttc - $totalpaid; @@ -1863,8 +1863,6 @@ else } - - /* * Barre d'actions */ @@ -1978,7 +1976,7 @@ if ($action != 'create' && $action != 'edit') * ET user à droit de "to_paid" * Afficher : "Annuler" / "Payer" / "Supprimer" */ - if ($user->rights->expensereport->approve && $user->rights->expensereport->to_paid && round($remaintopay) == 0 && $object->paid == 0 && $object->fk_statut == 5) + if ($user->rights->expensereport->to_paid && $object->fk_statut == 5) { // Pay if ($remaintopay == 0) @@ -1987,7 +1985,7 @@ if ($action != 'create' && $action != 'edit') } else { - print '
' . $langs->trans('DoPayment') . '
'; + print '
' . $langs->trans('DoPayment') . '
'; } print 'id.'">'.$langs->trans('TO_PAID').''; @@ -1996,10 +1994,10 @@ if ($action != 'create' && $action != 'edit') { print 'id.'">'.$langs->trans('Cancel').''; } - + + // Delete if($user->rights->expensereport->supprimer) { - // Delete print 'id.'">'.$langs->trans('Delete').''; } } diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 98a6aea00e7..7dede6d11a9 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -50,12 +50,13 @@ class ExpenseReport extends CommonObject var $status; var $fk_statut; // -- 1=draft, 2=validated (attente approb), 4=canceled, 5=approved, 6=payed, 99=denied var $fk_c_paiement; + var $paid; var $user_author_infos; var $user_validator_infos; - var $libelle_paiement; - var $libelle_statut; + var $modepayment; + var $modepaymentid; var $code_paiement; var $code_statut; @@ -107,6 +108,7 @@ class ExpenseReport extends CommonObject $this->total_ht = 0; $this->total_ttc = 0; $this->total_tva = 0; + $this->modepaymentid = 0; // List of language codes for status $this->statuts_short = array(0 => 'Draft', 2 => 'Validated', 4 => 'Canceled', 5 => 'Approved', 6 => 'Paid', 99 => 'Refused'); @@ -142,6 +144,7 @@ class ExpenseReport extends CommonObject $sql.= ",fk_user_validator"; $sql.= ",fk_statut"; $sql.= ",fk_c_paiement"; + $sql.= ",paid"; $sql.= ",note_public"; $sql.= ",note_private"; $sql.= ") VALUES("; @@ -155,7 +158,8 @@ class ExpenseReport extends CommonObject $sql.= ", ".($user->id > 0 ? $user->id:"null"); $sql.= ", ".($this->fk_user_validator > 0 ? $this->fk_user_validator:"null"); $sql.= ", ".($this->fk_statut > 1 ? $this->fk_statut:0); - $sql.= ", ".($this->fk_c_paiement > 0 ? $this->fk_c_paiement:"null"); + $sql.= ", ".($this->modepaymentid?$this->modepaymentid:"null"); + $sql.= ", 0"; $sql.= ", ".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null"); $sql.= ", ".($this->note_private?"'".$this->db->escape($this->note_private)."'":"null"); $sql.= ")"; @@ -325,9 +329,10 @@ class ExpenseReport extends CommonObject if ($this->fk_user_validator > 0) $user_approver->fetch($this->fk_user_validator); $this->user_validator_infos = dolGetFirstLastname($user_approver->firstname, $user_approver->lastname); - $this->fk_statut = $obj->status; - $this->status = $obj->status; - $this->fk_c_paiement = $obj->fk_c_paiement; + $this->fk_statut = $obj->status; + $this->status = $obj->status; + $this->fk_c_paiement = $obj->fk_c_paiement; + $this->paid = $obj->paid; if ($this->fk_statut==5 || $this->fk_statut==6) { diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index c7e152466fe..51a196057cf 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -42,7 +42,7 @@ class PaymentExpenseReport extends CommonObject var $datep=''; var $amount; // Total amount of payment var $amounts=array(); // Array of amounts - var $fk_typepayment; + var $paymenttype; var $num_payment; var $note; var $fk_bank; @@ -84,7 +84,7 @@ class PaymentExpenseReport extends CommonObject // Clean parameters if (isset($this->fk_expensereport)) $this->fk_expensereport=trim($this->fk_expensereport); if (isset($this->amount)) $this->amount=trim($this->amount); - if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment); + if (isset($this->fk_typepayment)) $this->paymenttype=trim($this->paymenttype); if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment); if (isset($this->note)) $this->note=trim($this->note); if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank); @@ -109,7 +109,7 @@ class PaymentExpenseReport extends CommonObject if ($totalamount != 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_expensereport (fk_expensereport, datec, datep, amount,"; - $sql.= " fk_typepayment, num_payment, note, fk_user_creat, fk_bank)"; + $sql.= " fk_c_typepayment, num_payment, note, fk_user_creat, fk_bank)"; $sql.= " VALUES ($this->chid, '".$this->db->idate($now)."',"; $sql.= " '".$this->db->idate($this->datepaid)."',"; $sql.= " ".$totalamount.","; diff --git a/htdocs/expensereport/payment/card.php b/htdocs/expensereport/payment/card.php index 8d4ce687cfc..5b62b138356 100644 --- a/htdocs/expensereport/payment/card.php +++ b/htdocs/expensereport/payment/card.php @@ -196,7 +196,7 @@ print '
"; print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''.dol_print_date($db->jdate($objp->dp),'day')."".$labeltype.' '.$object->num_payment."'.price($objp->total_ttc)." ".$langs->trans("Currency".$conf->currency)."".$labeltype.' '.$object->num_payment."'.price($objp->amount)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("AlreadyPaid")." :".price($totalpaid)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("AmountExpected")." :".price($object->amount)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("AmountExpected")." :".price($object->total_ttc)." ".$langs->trans("Currency".$conf->currency)."
'; */ $disable_delete = 0; -$sql = 'SELECT er.rowid as did, er.paid, er.amount as er_amount, per.amount'; +$sql = 'SELECT er.rowid as did, er.paid, er.total_ttc, per.amount'; $sql.= ' FROM '.MAIN_DB_PREFIX.'payment_expensereport as per,'.MAIN_DB_PREFIX.'expensereport as er'; $sql.= ' WHERE per.fk_expensereport = er.rowid'; $sql.= ' AND er.entity = '.$conf->entity; @@ -234,7 +234,7 @@ if ($resql) print $expensereport->getNomUrl(1); print "\n"; // Expected to pay - print ''.price($objp->d_amount).''; + print ''.price($objp->total_ttc).''; // Status print ''.$expensereport->getLibStatut(4,$objp->amount).''; // Amount paid diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php index e8c2ef8a26e..8a8d29aa8cf 100644 --- a/htdocs/expensereport/payment/payment.php +++ b/htdocs/expensereport/payment/payment.php @@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $langs->load("bills"); -$chid=GETPOST("rowid"); +$chid=GETPOST("id"); $action=GETPOST('action'); $amounts = array(); @@ -50,7 +50,7 @@ if ($action == 'add_payment') if ($_POST["cancel"]) { - $loc = DOL_URL_ROOT.'/expensereport/card.php?rowid='.$chid; + $loc = DOL_URL_ROOT.'/expensereport/card.php?id='.$chid; header("Location: ".$loc); exit; } @@ -129,7 +129,7 @@ if ($action == 'add_payment') if (! $error) { $db->commit(); - $loc = DOL_URL_ROOT.'/expensereport/card.php?rowid='.$chid; + $loc = DOL_URL_ROOT.'/expensereport/card.php?id='.$chid; header('Location: '.$loc); exit; } @@ -160,7 +160,7 @@ if (GETPOST("action") == 'create') $expensereport = new ExpenseReport($db); $expensereport->fetch($chid); - $total = $expensereport->amount; + $total = $expensereport->total_ttc; print_fiche_titre($langs->trans("DoPayment")); @@ -171,7 +171,7 @@ if (GETPOST("action") == 'create') print '
'; print ''; - print ''; + print ''; print ''; print ''; @@ -181,9 +181,9 @@ if (GETPOST("action") == 'create') print ''.$langs->trans("ExpenseReport").''; - print ''.$langs->trans("Ref").''.$chid.''; - print ''.$langs->trans("Date")."".dol_print_date($expensereport->date,'day')."\n"; - print ''.$langs->trans("Amount")."".price($expensereport->amount,0,$outputlangs,1,-1,-1,$conf->currency).''; + print ''.$langs->trans("Ref").''.$expensereport->ref.''; + print ''.$langs->trans("Period").''.get_date_range($expensereport->date_debut,$expensereport->date_fin,"",$langs,0).''; + print ''.$langs->trans("Amount").''.price($expensereport->total_ttc,0,$outputlangs,1,-1,-1,$conf->currency).''; $sql = "SELECT sum(p.amount) as total"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_expensereport as p"; @@ -215,7 +215,7 @@ if (GETPOST("action") == 'create') print ''; print ''; - print ''.$langs->trans('AccountToCredit').''; + print ''.$langs->trans('AccountToDebit').''; print ''; $form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$expensereport->accountid, "accountid", 0, '',1); // Show open bank account list print ''; @@ -261,14 +261,14 @@ if (GETPOST("action") == 'create') print ""; - print ''.price($objp->amount).""; + print ''.price($objp->total_ttc).""; print ''.price($sumpaid).""; - print ''.price($objp->amount - $sumpaid).""; + print ''.price($objp->total_ttc - $sumpaid).""; print ''; - if ($sumpaid < $objp->amount) + if ($sumpaid < $objp->total_ttc) { $namef = "amount_".$objp->id; print ''; diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index be91c24cb92..1bd3a473fd1 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -243,6 +243,7 @@ CREATE TABLE llx_expensereport ( fk_user_paid integer DEFAULT NULL, fk_statut integer NOT NULL, -- 1=brouillon, 2=validé (attente approb), 4=annulé, 5=approuvé, 6=payed, 99=refusé fk_c_paiement integer DEFAULT NULL, + paid smallint default 0 NOT NULL, note_public text, note_private text, detail_refuse varchar(255) DEFAULT NULL, diff --git a/htdocs/install/mysql/tables/llx_expensereport.sql b/htdocs/install/mysql/tables/llx_expensereport.sql index 657d8f9e278..879623b6b7e 100755 --- a/htdocs/install/mysql/tables/llx_expensereport.sql +++ b/htdocs/install/mysql/tables/llx_expensereport.sql @@ -46,6 +46,7 @@ CREATE TABLE llx_expensereport ( fk_user_paid integer DEFAULT NULL, fk_statut integer NOT NULL, -- 1=brouillon, 2=validé (attente approb), 4=annulé, 5=approuvé, 6=payed, 99=refusé fk_c_paiement integer DEFAULT NULL, + paid smallint default 0 NOT NULL, note_public text, note_private text, detail_refuse varchar(255) DEFAULT NULL,