This commit is contained in:
aspangaro 2015-06-17 07:19:25 +02:00
parent 2979815223
commit 8d0e7261f5
7 changed files with 41 additions and 36 deletions

View File

@ -1388,7 +1388,7 @@ else
if ($ret == 'html') print '<br>';
}
print '<table class="border centpercent">';
print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/expensereport/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
@ -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 "<tr ".$bc[$var]."><td>";
print '<a href="'.DOL_URL_ROOT.'/expensereport/payment/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.'</a></td>';
print '<td>'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n";
$labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->paiement_type;
print "<td>".$labeltype.' '.$object->num_payment."</td>\n";
print '<td align="right">'.price($objp->total_ttc)."</td><td>&nbsp;".$langs->trans("Currency".$conf->currency)."</td>\n";
$labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->payment_type;
print "<td>".$labeltype.' '.$object->num_payment."</td>\n";
print '<td align="right">'.price($objp->amount)."</td><td>&nbsp;".$langs->trans("Currency".$conf->currency)."</td>\n";
print "</tr>";
$totalpaid += $objp->total_ttc;
$totalpaid += $objp->amount;
$i++;
}
if ($object->paid == 0)
{
print "<tr><td colspan=\"2\" align=\"right\">".$langs->trans("AlreadyPaid")." :</td><td align=\"right\"><b>".price($totalpaid)."</b></td><td>&nbsp;".$langs->trans("Currency".$conf->currency)."</td></tr>\n";
print "<tr><td colspan=\"2\" align=\"right\">".$langs->trans("AmountExpected")." :</td><td align=\"right\" bgcolor=\"#d0d0d0\">".price($object->amount)."</td><td bgcolor=\"#d0d0d0\">&nbsp;".$langs->trans("Currency".$conf->currency)."</td></tr>\n";
print "<tr><td colspan=\"2\" align=\"right\">".$langs->trans("AmountExpected")." :</td><td align=\"right\" bgcolor=\"#d0d0d0\">".price($object->total_ttc)."</td><td bgcolor=\"#d0d0d0\">&nbsp;".$langs->trans("Currency".$conf->currency)."</td></tr>\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 '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/expensereport/payment/payment.php?rowid=' . $object->id . '&amp;action=create">' . $langs->trans('DoPayment') . '</a></div>';
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/expensereport/payment/payment.php?id=' . $object->id . '&amp;action=create">' . $langs->trans('DoPayment') . '</a></div>';
}
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=paid&id='.$object->id.'">'.$langs->trans('TO_PAID').'</a>';
@ -1996,10 +1994,10 @@ if ($action != 'create' && $action != 'edit')
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=cancel&id='.$object->id.'">'.$langs->trans('Cancel').'</a>';
}
// Delete
if($user->rights->expensereport->supprimer)
{
// Delete
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$object->id.'">'.$langs->trans('Delete').'</a>';
}
}

View File

@ -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)
{

View File

@ -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.",";

View File

@ -196,7 +196,7 @@ print '</table>';
*/
$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 "</td>\n";
// Expected to pay
print '<td align="right">'.price($objp->d_amount).'</td>';
print '<td align="right">'.price($objp->total_ttc).'</td>';
// Status
print '<td align="center">'.$expensereport->getLibStatut(4,$objp->amount).'</td>';
// Amount paid

View File

@ -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 '<form name="add_payment" action="'.$_SERVER['PHP_SELF'].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="rowid" value="'.$chid.'">';
print '<input type="hidden" name="id" value="'.$chid.'">';
print '<input type="hidden" name="chid" value="'.$chid.'">';
print '<input type="hidden" name="action" value="add_payment">';
@ -181,9 +181,9 @@ if (GETPOST("action") == 'create')
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("ExpenseReport").'</td>';
print '<tr><td>'.$langs->trans("Ref").'</td><td colspan="2"><a href="'.DOL_URL_ROOT.'/expensereport/card.php?rowid='.$chid.'">'.$chid.'</a></td></tr>';
print '<tr><td>'.$langs->trans("Date")."</td><td colspan=\"2\">".dol_print_date($expensereport->date,'day')."</td></tr>\n";
print '<tr><td>'.$langs->trans("Amount")."</td><td colspan=\"2\">".price($expensereport->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
print '<tr><td>'.$langs->trans("Ref").'</td><td colspan="2"><a href="'.DOL_URL_ROOT.'/expensereport/card.php?id='.$chid.'">'.$expensereport->ref.'</a></td></tr>';
print '<tr><td>'.$langs->trans("Period").'</td><td colspan="2">'.get_date_range($expensereport->date_debut,$expensereport->date_fin,"",$langs,0).'</td></tr>';
print '<tr><td>'.$langs->trans("Amount").'</td><td colspan="2">'.price($expensereport->total_ttc,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
$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 '</tr>';
print '<tr>';
print '<td class="fieldrequired">'.$langs->trans('AccountToCredit').'</td>';
print '<td class="fieldrequired">'.$langs->trans('AccountToDebit').'</td>';
print '<td colspan="2">';
$form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$expensereport->accountid, "accountid", 0, '',1); // Show open bank account list
print '</td></tr>';
@ -261,14 +261,14 @@ if (GETPOST("action") == 'create')
print "<tr ".$bc[$var].">";
print '<td align="right">'.price($objp->amount)."</td>";
print '<td align="right">'.price($objp->total_ttc)."</td>";
print '<td align="right">'.price($sumpaid)."</td>";
print '<td align="right">'.price($objp->amount - $sumpaid)."</td>";
print '<td align="right">'.price($objp->total_ttc - $sumpaid)."</td>";
print '<td align="center">';
if ($sumpaid < $objp->amount)
if ($sumpaid < $objp->total_ttc)
{
$namef = "amount_".$objp->id;
print '<input type="text" size="8" name="'.$namef.'">';

View File

@ -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,

View File

@ -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,