Update work on expensereport card
This commit is contained in:
parent
d92eab49de
commit
2979815223
@ -36,9 +36,11 @@ 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/modules/expensereport/modules_expensereport.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 . '/core/class/doleditor.class.php';
|
||||
|
||||
$langs->load("trips");
|
||||
$langs->load("bills");
|
||||
|
||||
$action=GETPOST('action');
|
||||
$cancel=GETPOST('cancel');
|
||||
@ -1391,13 +1393,13 @@ else
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/expensereport/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td>';
|
||||
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="2">';
|
||||
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', '');
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("Period").'</td>';
|
||||
print '<td>';
|
||||
print '<td colspan="2">';
|
||||
print get_date_range($object->date_debut,$object->date_fin,'',$langs,0);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
@ -1405,25 +1407,90 @@ else
|
||||
{
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("ModePaiement").'</td>';
|
||||
print '<td>'.$object->libelle_paiement.'</td>';
|
||||
print '<td colspan="2">'.$object->libelle_paiement.'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
// Status
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("Statut").'</td>';
|
||||
print '<td>'.$object->getLibStatut(4).'</td>';
|
||||
print '<td colspan="2">'.$object->getLibStatut(4).'</td>';
|
||||
print '</tr>';
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("NotePublic").'</td>';
|
||||
print '<td>'.$object->note_public.'</td>';
|
||||
print '<td colspan="2">'.$object->note_public.'</td>';
|
||||
print '</tr>';
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("NotePrivate").'</td>';
|
||||
print '<td>'.$object->note_private.'</td>';
|
||||
print '<td colspan="2">'.$object->note_private.'</td>';
|
||||
print '</tr>';
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("AmountHT").'</td>';
|
||||
print '<td>'.price($object->total_ht).'</td>';
|
||||
print '<td rowspan="7" valign="top">';
|
||||
/*
|
||||
* 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.= " FROM ".MAIN_DB_PREFIX."payment_expensereport as p";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."c_paiement as c ";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."expensereport as e";
|
||||
$sql.= " WHERE e.rowid = '".$id."'";
|
||||
$sql.= " AND p.fk_expensereport = e.rowid";
|
||||
$sql.= " AND e.entity = ".$conf->entity;
|
||||
$sql.= " AND p.fk_typepayment = c.id";
|
||||
$sql.= " ORDER BY dp";
|
||||
|
||||
//print $sql;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0; $total = 0;
|
||||
print '<table class="nobordernopadding" 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)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
$var=!$var;
|
||||
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> ".$langs->trans("Currency".$conf->currency)."</td>\n";
|
||||
print "</tr>";
|
||||
$totalpaid += $objp->total_ttc;
|
||||
$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> ".$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\"> ".$langs->trans("Currency".$conf->currency)."</td></tr>\n";
|
||||
|
||||
$remaintopay = $object->total_ttc - $totalpaid;
|
||||
|
||||
print "<tr><td colspan=\"2\" align=\"right\">".$langs->trans("RemainderToPay")." :</td>";
|
||||
print "<td align=\"right\" bgcolor=\"#f0f0f0\"><b>".price($remaintopay)."</b></td><td bgcolor=\"#f0f0f0\"> ".$langs->trans("Currency".$conf->currency)."</td></tr>\n";
|
||||
}
|
||||
print "</table>";
|
||||
$db->free($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
print "</td>";
|
||||
|
||||
print '</tr>';
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("AmountVAT").'</td>';
|
||||
@ -1643,7 +1710,7 @@ else
|
||||
{
|
||||
//modif ligne!!!!!
|
||||
print '<tr '.$bc[$var].'>';
|
||||
// Sélection date
|
||||
// Select date
|
||||
print '<td style="text-align:center;">';
|
||||
$form->select_date($objp->date,'date');
|
||||
print '</td>';
|
||||
@ -1872,9 +1939,9 @@ if ($action != 'create' && $action != 'edit')
|
||||
|
||||
/* Si l'état est "En attente d'approbation"
|
||||
* ET user à droit de "approve"
|
||||
* ET fk_user_validator == user courant
|
||||
* Afficher : "Valider" / "Refuser" / "Supprimer"
|
||||
*/
|
||||
* ET fk_user_validator == user courant
|
||||
* Afficher : "Valider" / "Refuser" / "Supprimer"
|
||||
*/
|
||||
if ($object->fk_statut == 2)
|
||||
{
|
||||
if ($object->fk_user_author == $user->id)
|
||||
@ -1906,14 +1973,22 @@ if ($action != 'create' && $action != 'edit')
|
||||
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$object->id.'">'.$langs->trans('Delete').'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Si l'état est "A payer"
|
||||
* ET user à droit de "to_paid"
|
||||
* Afficher : "Annuler" / "Payer" / "Supprimer"
|
||||
*/
|
||||
if ($user->rights->expensereport->to_paid && $object->fk_statut == 5)
|
||||
* Afficher : "Annuler" / "Payer" / "Supprimer"
|
||||
*/
|
||||
if ($user->rights->expensereport->approve && $user->rights->expensereport->to_paid && round($remaintopay) == 0 && $object->paid == 0 && $object->fk_statut == 5)
|
||||
{
|
||||
// Pay
|
||||
if ($remaintopay == 0)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><span class="butActionRefused" title="' . $langs->trans("DisabledBecauseRemainderToPayIsZero") . '">' . $langs->trans('DoPayment') . '</span></div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/expensereport/payment/payment.php?rowid=' . $object->id . '&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>';
|
||||
|
||||
// Cancel
|
||||
@ -1931,9 +2006,9 @@ if ($action != 'create' && $action != 'edit')
|
||||
|
||||
/* Si l'état est "Payée"
|
||||
* ET user à droit "approve"
|
||||
* ET user à droit "to_paid"
|
||||
* Afficher : "Annuler"
|
||||
*/
|
||||
* ET user à droit "to_paid"
|
||||
* Afficher : "Annuler"
|
||||
*/
|
||||
if ($user->rights->expensereport->approve && $user->rights->expensereport->to_paid && $object->fk_statut==6)
|
||||
{
|
||||
// Cancel
|
||||
|
||||
Loading…
Reference in New Issue
Block a user