forked from Wavyzz/dolibarr
ER: Review & add a totalVAT in pdf
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2015 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -23,9 +24,9 @@
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/expensereport/modules_expensereport.php';
|
||||
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php');
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
|
||||
@@ -252,7 +253,7 @@ class pdf_standard extends ModeleExpenseReport
|
||||
$tab_height = 110;
|
||||
$tab_height_newpage = 110;
|
||||
|
||||
// Affiche notes
|
||||
// Show notes
|
||||
$notetoshow=empty($object->note_public)?'':$object->note_public;
|
||||
if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
|
||||
{
|
||||
@@ -340,9 +341,10 @@ class pdf_standard extends ModeleExpenseReport
|
||||
$pdf->MultiCell($this->posxtva-$this->posxprojet-1, 3,$object->lines[$i]->projet_ref, 0, 'C');
|
||||
|
||||
// VAT Rate
|
||||
$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
$pdf->SetXY($this->posxtva, $curY);
|
||||
$pdf->MultiCell($this->posxup-$this->posxtva-1, 3,vatrate($object->lines[$i]->tva_taux,true), 0, 'R');
|
||||
$pdf->MultiCell($this->posxup-$this->posxtva-1, 3,$vat_rate, 0, 'R');
|
||||
|
||||
// Unit price
|
||||
$pdf->SetFont('','', $default_font_size - 1);
|
||||
@@ -438,6 +440,13 @@ class pdf_standard extends ModeleExpenseReport
|
||||
$pdf->SetXY(160, $posy);
|
||||
$pdf->MultiCell($this->page_largeur - $this->marge_gauche - 160, 5, price($object->total_ht), 1, 'R');
|
||||
$pdf->SetFillColor(248,248,248);
|
||||
|
||||
$posy+=5;
|
||||
$pdf->SetXY(100, $posy);
|
||||
$pdf->SetTextColor(0,0,60);
|
||||
$pdf->MultiCell(60, 5, $outputlangs->transnoentities("TotalVAT"), 1,'L');
|
||||
$pdf->SetXY(160, $posy);
|
||||
$pdf->MultiCell($this->page_largeur - $this->marge_gauche - 160, 5, price($object->total_tva),1, 'R');
|
||||
|
||||
$posy+=5;
|
||||
$pdf->SetXY(100, $posy);
|
||||
@@ -766,7 +775,7 @@ class pdf_standard extends ModeleExpenseReport
|
||||
// Unit price
|
||||
$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
|
||||
$pdf->SetXY($this->posxup-1, $tab_top+1);
|
||||
$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("UP"),'','C');
|
||||
$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceU"),'','C');
|
||||
|
||||
// Quantity
|
||||
$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
|
||||
|
||||
@@ -879,7 +879,7 @@ if ($action == "addline")
|
||||
$tmp = calcul_price_total($qty, $up, 0, $vatrate, 0, 0, 0, 'TTC', 0, $type);
|
||||
|
||||
$object_ligne->total_ttc = $tmp[2];
|
||||
$object_ligne->tva_taux = GETPOST('vatrate');
|
||||
$object_ligne->tva_tx = GETPOST('vatrate');
|
||||
$object_ligne->total_ht = $tmp[0];
|
||||
$object_ligne->total_tva = $tmp[1];
|
||||
|
||||
@@ -1008,9 +1008,9 @@ if ($action == "updateligne" )
|
||||
|
||||
|
||||
/*
|
||||
* Generer ou regenerer le document PDF
|
||||
* Generate or regenerate the PDF document
|
||||
*/
|
||||
if ($action == 'builddoc') // En get ou en post
|
||||
if ($action == 'builddoc') // GET or POST
|
||||
{
|
||||
$depl = new ExpenseReport($db, 0, $_GET['id']);
|
||||
$depl->fetch($id);
|
||||
@@ -1639,7 +1639,7 @@ else
|
||||
$formproject->select_projects(-1, $objp->fk_projet,'fk_projet', 0, 0, 0, 1);
|
||||
print '</td>';
|
||||
|
||||
// Sélect type
|
||||
// Select type
|
||||
print '<td style="text-align:center;">';
|
||||
select_type_fees_id($objp->type_fees_code,'fk_c_type_fees');
|
||||
print '</td>';
|
||||
@@ -1649,17 +1649,17 @@ else
|
||||
print '<textarea class="flat_ndf" name="comments" class="centpercent">'.$objp->comments.'</textarea>';
|
||||
print '</td>';
|
||||
|
||||
// Sélection TVA
|
||||
// Select VAT
|
||||
print '<td style="text-align:right;">';
|
||||
print $form->load_tva('fk_c_tva', (isset($_POST["fk_c_tva"])?$_POST["fk_c_tva"]:$objp->tva_taux), $mysoc, '');
|
||||
print $form->load_tva('fk_c_tva', (isset($_POST["fk_c_tva"])?$_POST["fk_c_tva"]:$objp->tva_tx), $mysoc, '');
|
||||
print '</td>';
|
||||
|
||||
// Prix unitaire
|
||||
// Unit price
|
||||
print '<td style="text-align:right;">';
|
||||
print '<input type="text" size="6" name="value_unit" value="'.$objp->value_unit.'" />';
|
||||
print '</td>';
|
||||
|
||||
// Quantité
|
||||
// Quantity
|
||||
print '<td style="text-align:right;">';
|
||||
print '<input type="text" size="4" name="qty" value="'.$objp->qty.'" />';
|
||||
print '</td>';
|
||||
@@ -1744,7 +1744,7 @@ else
|
||||
print '</select>';
|
||||
print '</td>';
|
||||
|
||||
// Prix unitaire
|
||||
// Unit price
|
||||
print '<td style="text-align:right;">';
|
||||
print '<input type="text" size="6" name="value_unit" value="'.GETPOST('value_unit').'">';
|
||||
print '</td>';
|
||||
@@ -1805,7 +1805,7 @@ if ($action != 'create' && $action != 'edit')
|
||||
{
|
||||
if ($object->fk_user_author == $user->id)
|
||||
{
|
||||
// Modifier
|
||||
// Modify
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$id.'">'.$langs->trans('Modify').'</a>';
|
||||
|
||||
// Validate
|
||||
@@ -1816,7 +1816,7 @@ if ($action != 'create' && $action != 'edit')
|
||||
|
||||
if ($user->rights->expensereport->supprimer)
|
||||
{
|
||||
// Supprimer
|
||||
// Delete
|
||||
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>';
|
||||
}
|
||||
}
|
||||
@@ -1831,7 +1831,7 @@ if ($action != 'create' && $action != 'edit')
|
||||
{
|
||||
if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid)
|
||||
{
|
||||
// Modifier
|
||||
// Modify
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$id.'">'.$langs->trans('Modify').'</a>';
|
||||
|
||||
// Brouillonner (le statut refusée est identique à brouillon)
|
||||
@@ -1841,7 +1841,7 @@ if ($action != 'create' && $action != 'edit')
|
||||
|
||||
if ($user->rights->expensereport->supprimer)
|
||||
{
|
||||
// Supprimer
|
||||
// Delete
|
||||
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>';
|
||||
}
|
||||
}
|
||||
@@ -1874,9 +1874,9 @@ if ($action != 'create' && $action != 'edit')
|
||||
{
|
||||
//if($object->fk_user_validator==$user->id)
|
||||
//{
|
||||
// Valider
|
||||
// Validate
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=validate&id='.$id.'">'.$langs->trans('Approve').'</a>';
|
||||
// Refuser
|
||||
// Deny
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=refuse&id='.$id.'">'.$langs->trans('Deny').'</a>';
|
||||
//}
|
||||
|
||||
@@ -1888,7 +1888,7 @@ if ($action != 'create' && $action != 'edit')
|
||||
|
||||
if($user->rights->expensereport->supprimer)
|
||||
{
|
||||
// Supprimer
|
||||
// Delete
|
||||
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>';
|
||||
}
|
||||
}
|
||||
@@ -1899,7 +1899,7 @@ if ($action != 'create' && $action != 'edit')
|
||||
*/
|
||||
if ($user->rights->expensereport->to_paid && $object->fk_statut == 5)
|
||||
{
|
||||
// Payer
|
||||
// Pay
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=paid&id='.$id.'">'.$langs->trans('TO_PAID').'</a>';
|
||||
|
||||
// Cancel
|
||||
@@ -1910,7 +1910,7 @@ if ($action != 'create' && $action != 'edit')
|
||||
|
||||
if($user->rights->expensereport->supprimer)
|
||||
{
|
||||
// Supprimer
|
||||
// Delete
|
||||
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>';
|
||||
}
|
||||
}
|
||||
@@ -1922,11 +1922,11 @@ if ($action != 'create' && $action != 'edit')
|
||||
*/
|
||||
if ($user->rights->expensereport->approve && $user->rights->expensereport->to_paid && $object->fk_statut==6)
|
||||
{
|
||||
// Annuler
|
||||
// Cancel
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=cancel&id='.$id.'">'.$langs->trans('Cancel').'</a>';
|
||||
if($user->rights->expensereport->supprimer)
|
||||
{
|
||||
// Supprimer
|
||||
// Delete
|
||||
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>';
|
||||
}
|
||||
}
|
||||
@@ -1944,7 +1944,7 @@ if ($action != 'create' && $action != 'edit')
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=brouillonner&id='.$id.'">'.$langs->trans('ReOpen').'</a>';
|
||||
}
|
||||
|
||||
// Supprimer
|
||||
// Delete
|
||||
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>';
|
||||
|
||||
}
|
||||
@@ -1959,7 +1959,7 @@ print '</div>';
|
||||
print '<div style="width:50%">';
|
||||
|
||||
/*
|
||||
* Documents generes
|
||||
* Generate documents
|
||||
*/
|
||||
if($user->rights->expensereport->export && $object->fk_statut>0 && $action != 'edit')
|
||||
{
|
||||
|
||||
@@ -540,7 +540,7 @@ class ExpenseReport extends CommonObject
|
||||
$line->total_ttc=120;
|
||||
$line->qty=1;
|
||||
$line->fk_c_tva=20;
|
||||
$line->tva_taux=20;
|
||||
$line->tva_tx=20;
|
||||
$line->value_unit=120;
|
||||
$line->fk_expensereport=0;
|
||||
$line->type_fees_code='TRA';
|
||||
@@ -761,7 +761,7 @@ class ExpenseReport extends CommonObject
|
||||
|
||||
$deplig->type_fees_code = $objp->code_type_fees;
|
||||
$deplig->type_fees_libelle = $objp->libelle_type_fees;
|
||||
$deplig->tva_taux = $objp->taux_tva;
|
||||
$deplig->tva_tx = $objp->vatrate;
|
||||
$deplig->projet_ref = $objp->ref_projet;
|
||||
$deplig->projet_title = $objp->title_projet;
|
||||
|
||||
@@ -1207,7 +1207,7 @@ class ExpenseReport extends CommonObject
|
||||
$this->db->begin();
|
||||
|
||||
// Select du taux de tva par rapport au code
|
||||
$sql = "SELECT t.taux as taux_tva";
|
||||
$sql = "SELECT t.taux as vatrate";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t";
|
||||
$sql.= " WHERE t.rowid = ".$c_tva;
|
||||
$result = $this->db->query($sql);
|
||||
@@ -1217,7 +1217,7 @@ class ExpenseReport extends CommonObject
|
||||
$total_ttc = $qty*$value_unit;
|
||||
$total_ttc = number_format($total_ttc,2,'.','');
|
||||
|
||||
$tx_tva = $objp_tva->taux_tva/100;
|
||||
$tx_tva = $objp_tva->vatrate/100;
|
||||
$tx_tva = $tx_tva + 1;
|
||||
$total_ht = $total_ttc/$tx_tva;
|
||||
$total_ht = number_format($total_ht,2,'.','');
|
||||
@@ -1239,7 +1239,7 @@ class ExpenseReport extends CommonObject
|
||||
$ligne->total_ht = $total_ht;
|
||||
$ligne->total_tva = $total_tva;
|
||||
$ligne->total_ttc = $total_ttc;
|
||||
$ligne->tva_taux = $objp_tva->taux_tva;
|
||||
$ligne->tva_tx = $objp_tva->vatrate;
|
||||
$ligne->rowid = $rowid;
|
||||
|
||||
// Select des infos sur le type fees
|
||||
@@ -1487,7 +1487,7 @@ class ExpenseReportLine
|
||||
var $projet_ref;
|
||||
var $projet_title;
|
||||
|
||||
var $tva_taux;
|
||||
var $tva_tx;
|
||||
|
||||
var $total_ht;
|
||||
var $total_tva;
|
||||
@@ -1512,7 +1512,7 @@ class ExpenseReportLine
|
||||
function fetch($rowid)
|
||||
{
|
||||
$sql = 'SELECT fde.rowid, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_projet, fde.date,';
|
||||
$sql.= ' fde.fk_c_tva as tva_taux, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,';
|
||||
$sql.= ' fde.fk_c_tva as tva_tx, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,';
|
||||
$sql.= ' ctf.code as type_fees_code, ctf.label as type_fees_libelle,';
|
||||
$sql.= ' pjt.rowid as projet_id, pjt.title as projet_title, pjt.ref as projet_ref';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_det as fde';
|
||||
@@ -1539,7 +1539,7 @@ class ExpenseReportLine
|
||||
$this->type_fees_libelle = $objp->type_fees_libelle;
|
||||
$this->projet_ref = $objp->projet_ref;
|
||||
$this->projet_title = $objp->projet_title;
|
||||
$this->tva_taux = $objp->tva_taux;
|
||||
$this->tva_tx = $objp->tva_tx;
|
||||
$this->total_ht = $objp->total_ht;
|
||||
$this->total_tva = $objp->total_tva;
|
||||
$this->total_ttc = $objp->total_ttc;
|
||||
|
||||
Reference in New Issue
Block a user