Review payment part on expense report card
This commit is contained in:
parent
570f9aaa9e
commit
48477e00fd
@ -2,7 +2,7 @@
|
|||||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
||||||
* Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro@zendsi.com>
|
* Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||||
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
|
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -37,9 +37,12 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/expensereport.lib.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/modules/expensereport/modules_expensereport.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/modules/expensereport/modules_expensereport.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/paymentexpensereport.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
|
||||||
|
if (! empty($conf->accounting->enabled)) {
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
|
||||||
|
}
|
||||||
|
|
||||||
$langs->load("trips");
|
$langs->load("trips");
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
@ -1079,7 +1082,6 @@ if (empty($reshook))
|
|||||||
|
|
||||||
$object_ligne->fk_projet = $fk_projet;
|
$object_ligne->fk_projet = $fk_projet;
|
||||||
|
|
||||||
|
|
||||||
if (! GETPOST('fk_c_type_fees') > 0)
|
if (! GETPOST('fk_c_type_fees') > 0)
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
@ -1278,6 +1280,8 @@ $form = new Form($db);
|
|||||||
$formfile = new FormFile($db);
|
$formfile = new FormFile($db);
|
||||||
$formproject = new FormProjets($db);
|
$formproject = new FormProjets($db);
|
||||||
$projecttmp = new Project($db);
|
$projecttmp = new Project($db);
|
||||||
|
$paymentexpensereportstatic=new PaymentExpenseReport($db);
|
||||||
|
$bankaccountstatic = new Account($db);
|
||||||
|
|
||||||
// Create
|
// Create
|
||||||
if ($action == 'create')
|
if ($action == 'create')
|
||||||
@ -1593,12 +1597,9 @@ else
|
|||||||
// Print form confirm
|
// Print form confirm
|
||||||
print $formconfirm;
|
print $formconfirm;
|
||||||
|
|
||||||
|
|
||||||
// Expense report card
|
// Expense report card
|
||||||
|
|
||||||
$linkback = '<a href="'.DOL_URL_ROOT.'/expensereport/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
|
$linkback = '<a href="'.DOL_URL_ROOT.'/expensereport/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
|
||||||
|
|
||||||
|
|
||||||
$morehtmlref='<div class="refidno">';
|
$morehtmlref='<div class="refidno">';
|
||||||
/*
|
/*
|
||||||
// Ref customer
|
// Ref customer
|
||||||
@ -1640,10 +1641,8 @@ else
|
|||||||
}*/
|
}*/
|
||||||
$morehtmlref.='</div>';
|
$morehtmlref.='</div>';
|
||||||
|
|
||||||
|
|
||||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
||||||
|
|
||||||
|
|
||||||
print '<div class="fichecenter">';
|
print '<div class="fichecenter">';
|
||||||
print '<div class="fichehalfleft">';
|
print '<div class="fichehalfleft">';
|
||||||
print '<div class="underbanner clearboth"></div>';
|
print '<div class="underbanner clearboth"></div>';
|
||||||
@ -1677,29 +1676,6 @@ else
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Amount
|
|
||||||
print '<tr>';
|
|
||||||
print '<td>'.$langs->trans("AmountHT").'</td>';
|
|
||||||
print '<td>'.price($object->total_ht).'</td>';
|
|
||||||
$rowspan = 5;
|
|
||||||
if ($object->fk_statut < 3) $rowspan++;
|
|
||||||
elseif($object->fk_statut == 4) $rowspan+=2;
|
|
||||||
else $rowspan+=2;
|
|
||||||
if ($object->fk_statut==99 || !empty($object->detail_refuse)) $rowspan+=2;
|
|
||||||
if($object->fk_statut==6) $rowspan+=2;
|
|
||||||
print "</td>";
|
|
||||||
print '</tr>';
|
|
||||||
|
|
||||||
print '<tr>';
|
|
||||||
print '<td>'.$langs->trans("AmountVAT").'</td>';
|
|
||||||
print '<td>'.price($object->total_tva).'</td>';
|
|
||||||
print '</tr>';
|
|
||||||
|
|
||||||
print '<tr>';
|
|
||||||
print '<td>'.$langs->trans("AmountTTC").'</td>';
|
|
||||||
print '<td>'.price($object->total_ttc).'</td>';
|
|
||||||
print '</tr>';
|
|
||||||
|
|
||||||
// Validation date
|
// Validation date
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td>'.$langs->trans("DATE_SAVE").'</td>';
|
print '<td>'.$langs->trans("DATE_SAVE").'</td>';
|
||||||
@ -1805,7 +1781,7 @@ else
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Other attributes
|
// Other attributes
|
||||||
$cols = 3;
|
$cols = 2;
|
||||||
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
|
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
@ -1813,14 +1789,62 @@ else
|
|||||||
print '</div>';
|
print '</div>';
|
||||||
print '<div class="fichehalfright">';
|
print '<div class="fichehalfright">';
|
||||||
print '<div class="ficheaddleft">';
|
print '<div class="ficheaddleft">';
|
||||||
//print '<div class="underbanner clearboth"></div>';
|
print '<div class="underbanner clearboth"></div>';
|
||||||
|
|
||||||
// List of payments
|
print '<table class="border centpercent">';
|
||||||
$sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount,";
|
|
||||||
$sql.= "c.code as type_code,c.libelle as payment_type";
|
// Amount
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."payment_expensereport as p";
|
print '<tr>';
|
||||||
|
print '<td class="titlefieldmiddle">'.$langs->trans("AmountHT").'</td>';
|
||||||
|
print '<td class="nowrap amountcard">'.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).'</td>';
|
||||||
|
$rowspan = 5;
|
||||||
|
if ($object->fk_statut < 3) $rowspan++;
|
||||||
|
elseif($object->fk_statut == 4) $rowspan+=2;
|
||||||
|
else $rowspan+=2;
|
||||||
|
if ($object->fk_statut==99 || !empty($object->detail_refuse)) $rowspan+=2;
|
||||||
|
if($object->fk_statut==6) $rowspan+=2;
|
||||||
|
print "</td>";
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
print '<tr>';
|
||||||
|
print '<td>'.$langs->trans("AmountVAT").'</td>';
|
||||||
|
print '<td class="nowrap amountcard">'.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).'</td>';
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
print '<tr>';
|
||||||
|
print '<td>'.$langs->trans("AmountTTC").'</td>';
|
||||||
|
print '<td class="nowrap amountcard">'.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'</td>';
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
// List of payments already done
|
||||||
|
$nbcols = 3;
|
||||||
|
if (! empty($conf->banque->enabled)) {
|
||||||
|
$nbrows ++;
|
||||||
|
$nbcols ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
print '<table class="noborder paymenttable" width="100%">';
|
||||||
|
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print '<td class="liste_titre">' . $langs->trans('Payments') . '</td>';
|
||||||
|
print '<td class="liste_titre">' . $langs->trans('Date') . '</td>';
|
||||||
|
print '<td class="liste_titre">' . $langs->trans('Type') . '</td>';
|
||||||
|
if (! empty($conf->banque->enabled)) {
|
||||||
|
print '<td class="liste_titre" align="right">' . $langs->trans('BankAccount') . '</td>';
|
||||||
|
}
|
||||||
|
print '<td class="liste_titre" align="right">' . $langs->trans('Amount') . '</td>';
|
||||||
|
print '<td class="liste_titre" width="18"> </td>';
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
// 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.= "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";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."c_paiement as c ";
|
$sql.= ", ".MAIN_DB_PREFIX."c_paiement as c ";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."expensereport as e";
|
$sql.= ", ".MAIN_DB_PREFIX."payment_expensereport as p";
|
||||||
|
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid';
|
||||||
|
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid';
|
||||||
$sql.= " WHERE e.rowid = '".$id."'";
|
$sql.= " WHERE e.rowid = '".$id."'";
|
||||||
$sql.= " AND p.fk_expensereport = e.rowid";
|
$sql.= " AND p.fk_expensereport = e.rowid";
|
||||||
$sql.= " AND e.entity = ".$conf->entity;
|
$sql.= " AND e.entity = ".$conf->entity;
|
||||||
@ -1832,26 +1856,41 @@ else
|
|||||||
{
|
{
|
||||||
$num = $db->num_rows($resql);
|
$num = $db->num_rows($resql);
|
||||||
$i = 0; $total = 0;
|
$i = 0; $total = 0;
|
||||||
print '<table class="noborder paymenttable" width="100%">';
|
|
||||||
print '<tr class="liste_titre">';
|
|
||||||
print '<td>'.$langs->trans("RefPayment").'</td>';
|
|
||||||
print '<td>'.$langs->trans("Date").'</td>';
|
|
||||||
print '<td>'.$langs->trans("Type").'</td>';
|
|
||||||
print '<td align="right">'.$langs->trans("Amount").'</td>';
|
|
||||||
print '<td> </td>';
|
|
||||||
print '</tr>';
|
|
||||||
|
|
||||||
$var=True;
|
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$objp = $db->fetch_object($resql);
|
$objp = $db->fetch_object($resql);
|
||||||
|
|
||||||
print "<tr ".$bc[$var]."><td>";
|
print '<tr class="oddseven"><td>';
|
||||||
print '<a href="'.DOL_URL_ROOT.'/expensereport/payment/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.'</a></td>';
|
$paymentexpensereportstatic->id = $objp->rowid;
|
||||||
|
$paymentexpensereportstatic->datepaye = $db->jdate($objp->dp);
|
||||||
|
$paymentexpensereportstatic->ref = $objp->rowid;
|
||||||
|
$paymentexpensereportstatic->num_paiement = $objp->num_paiement;
|
||||||
|
$paymentexpensereportstatic->payment_code = $objp->payment_code;
|
||||||
|
print $paymentexpensereportstatic->getNomUrl(1);
|
||||||
|
print '</td>';
|
||||||
print '<td>'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n";
|
print '<td>'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n";
|
||||||
$labeltype=$langs->trans("PaymentType".$objp->type_code)!=("PaymentType".$objp->type_code)?$langs->trans("PaymentType".$objp->type_code):$objp->fk_typepayment;
|
$labeltype=$langs->trans("PaymentType".$objp->p_code)!=("PaymentType".$objp->p_code)?$langs->trans("PaymentType".$objp->p_code):$objp->fk_typepayment;
|
||||||
print "<td>".$labeltype.' '.$objp->num_payment."</td>\n";
|
print "<td>".$labeltype.' '.$objp->num_payment."</td>\n";
|
||||||
print '<td align="right">'.price($objp->amount)."</td><td> ".$langs->trans("Currency".$conf->currency)."</td>\n";
|
if (! empty($conf->banque->enabled)) {
|
||||||
|
$bankaccountstatic->id = $objp->baid;
|
||||||
|
$bankaccountstatic->ref = $objp->baref;
|
||||||
|
$bankaccountstatic->label = $objp->baref;
|
||||||
|
$bankaccountstatic->number = $objp->banumber;
|
||||||
|
|
||||||
|
if (! empty($conf->accounting->enabled)) {
|
||||||
|
$bankaccountstatic->account_number = $objp->account_number;
|
||||||
|
|
||||||
|
$accountingjournal = new AccountingJournal($db);
|
||||||
|
$accountingjournal->fetch($objp->fk_accountancy_journal);
|
||||||
|
$bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0,1,1,'',1);
|
||||||
|
}
|
||||||
|
|
||||||
|
print '<td align="right">';
|
||||||
|
if ($bankaccountstatic->id)
|
||||||
|
print $bankaccountstatic->getNomUrl(1, 'transactions');
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
print '<td align="right">'.price($objp->amount)."</td>";
|
||||||
print "</tr>";
|
print "</tr>";
|
||||||
$totalpaid += $objp->amount;
|
$totalpaid += $objp->amount;
|
||||||
$i++;
|
$i++;
|
||||||
@ -1859,13 +1898,13 @@ else
|
|||||||
|
|
||||||
if ($object->paid == 0)
|
if ($object->paid == 0)
|
||||||
{
|
{
|
||||||
print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AlreadyPaid")." :</td><td align=\"right\">".price($totalpaid)."</td></tr>\n";
|
print '<tr><td colspan="' . $nbcols . '" align="right">'.$langs->trans("AlreadyPaid").':</td><td align="right">'.price($totalpaid).'</td></tr>';
|
||||||
print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AmountExpected")." :</td><td align=\"right\">".price($object->total_ttc)."</td></tr>\n";
|
print '<tr><td colspan="' . $nbcols . '" align="right">'.$langs->trans("AmountExpected").':</td><td align="right">'.price($object->total_ttc).'</td></tr>';
|
||||||
|
|
||||||
$remaintopay = $object->total_ttc - $totalpaid;
|
$remaintopay = $object->total_ttc - $totalpaid;
|
||||||
|
|
||||||
print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("RemainderToPay")." :</td>";
|
print '<tr><td colspan="' . $nbcols . '" align="right">'.$langs->trans("RemainderToPay").':</td>';
|
||||||
print '<td align="right"'.($remaintopay?' class="amountremaintopay"':'').'>'.price($remaintopay)."</td></tr>\n";
|
print '<td align="right"'.($remaintopay?' class="amountremaintopay"':'').'>'.price($remaintopay).'</td></tr>';
|
||||||
}
|
}
|
||||||
print "</table>";
|
print "</table>";
|
||||||
$db->free($resql);
|
$db->free($resql);
|
||||||
@ -1881,8 +1920,6 @@ else
|
|||||||
|
|
||||||
print '<div class="clearboth"></div><br>';
|
print '<div class="clearboth"></div><br>';
|
||||||
|
|
||||||
print '<br>';
|
|
||||||
|
|
||||||
// Fetch Lines of current expense report
|
// Fetch Lines of current expense report
|
||||||
$sql = 'SELECT fde.rowid, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_projet, fde.date,';
|
$sql = 'SELECT fde.rowid, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_projet, fde.date,';
|
||||||
$sql.= ' fde.tva_tx as vatrate, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,';
|
$sql.= ' fde.tva_tx as vatrate, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,';
|
||||||
@ -1905,7 +1942,6 @@ else
|
|||||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||||
print '<input type="hidden" name="fk_expensereport" value="'.$object->id.'" />';
|
print '<input type="hidden" name="fk_expensereport" value="'.$object->id.'" />';
|
||||||
|
|
||||||
|
|
||||||
print '<div class="div-table-responsive">';
|
print '<div class="div-table-responsive">';
|
||||||
print '<table id="tablelines" class="noborder" width="100%">';
|
print '<table id="tablelines" class="noborder" width="100%">';
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user