Merge branch 'aspangaro-develop-ER_badge' into develop

This commit is contained in:
Laurent Destailleur 2015-05-15 02:44:56 +02:00
commit 17b736c8ce
3 changed files with 62 additions and 55 deletions

View File

@ -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,16 +24,16 @@
*/
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';
/**
* Classe permettant de generer les factures au modele Crabe
* Class to generate expense report based on standard model
*/
class pdf_standard extends ModeleExpenseReport
{
@ -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))
{
@ -308,7 +309,7 @@ class pdf_standard extends ModeleExpenseReport
$showpricebeforepagebreak=1;
// Piece comptable
// Accountancy piece
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell($this->posxcomment-$this->posxpiece-1, 3, $this->posxpiece-1, $curY, $piece_comptable, 0, 1);
@ -334,17 +335,18 @@ class pdf_standard extends ModeleExpenseReport
$pdf->SetXY($this->posxtype, $curY);
$pdf->MultiCell($this->posxprojet-$this->posxtype-1, 3,$outputlangs->transnoentities($object->lines[$i]->type_fees_code), 0, 'C');
// Projet
// Project
$pdf->SetFont('','', $default_font_size - 1);
$pdf->SetXY($this->posxprojet, $curY);
$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]->vatrate,true), 0, 'R');
$pdf->MultiCell($this->posxup-$this->posxtva-1, 3,$vat_rate, 0, 'R');
// UP
// Unit price
$pdf->SetFont('','', $default_font_size - 1);
$pdf->SetXY($this->posxup, $curY);
$pdf->MultiCell($this->posxqty-$this->posxup-1, 3,price($object->lines[$i]->value_unit), 0, 'R');
@ -354,7 +356,7 @@ class pdf_standard extends ModeleExpenseReport
$pdf->SetXY($this->posxqty, $curY);
$pdf->MultiCell($this->postotalttc-$this->posxqty, 3,$object->lines[$i]->qty, 0, 'C');
// TotalTTC
// Total with all taxes
$pdf->SetFont('','', $default_font_size - 1);
$pdf->SetXY($this->postotalttc-2, $curY);
$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalttc, 3, price($object->lines[$i]->total_ttc), 0, 'R');
@ -439,6 +441,13 @@ class pdf_standard extends ModeleExpenseReport
$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);
$pdf->SetFont('','B', 10);
@ -507,7 +516,7 @@ class pdf_standard extends ModeleExpenseReport
pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
*/
// Filligrane brouillon
// Draft watermark
if ($object->fk_statut==1 && ! empty($conf->global->EXPENSEREPORT_FREE_TEXT))
{
pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->EXPENSEREPORT_FREE_TEXT);
@ -551,25 +560,25 @@ class pdf_standard extends ModeleExpenseReport
$pdf->SetFont('','', $default_font_size -1);
// Réf complète
// Ref complete
$posy+=8;
$pdf->SetXY($posx,$posy);
$pdf->SetTextColor(0,0,60);
$pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("Ref")." : " . $object->ref, '', 'L');
// Date début période
// Date start period
$posy+=5;
$pdf->SetXY($posx,$posy);
$pdf->SetTextColor(0,0,60);
$pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("DateStart")." : " . ($object->date_debut>0?dol_print_date($object->date_debut,"day",false,$outpulangs):''), '', 'L');
// Date fin période
// Date end period
$posy+=5;
$pdf->SetXY($posx,$posy);
$pdf->SetTextColor(0,0,60);
$pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("DateEnd")." : " . ($object->date_fin>0?dol_print_date($object->date_fin,"day",false,$outpulangs):''), '', 'L');
// Statut NDF
// Status Expense Report
$posy+=6;
$pdf->SetXY($posx,$posy);
$pdf->SetFont('','B',18);
@ -581,7 +590,7 @@ class pdf_standard extends ModeleExpenseReport
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->address);
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->zip).' '.$outputlangs->convToOutputCharset($this->emetteur->town);
$carac_emetteur .= "\n";
// Tel
// Phone
if ($this->emetteur->phone) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone")." : ".$outputlangs->convToOutputCharset($this->emetteur->phone);
// Fax
if ($this->emetteur->fax) $carac_emetteur .= ($carac_emetteur ? ($this->emetteur->tel ? " - " : "\n") : '' ).$outputlangs->transnoentities("Fax")." : ".$outputlangs->convToOutputCharset($this->emetteur->fax);
@ -734,46 +743,46 @@ class pdf_standard extends ModeleExpenseReport
$pdf->SetFont('','',8);
//Piece comptable
// Accountancy piece
$pdf->SetXY($this->posxpiece-1, $tab_top+1);
$pdf->MultiCell($this->posxdesc-$this->posxpiece-1,1,'','','R');
//Comments
// Comments
$pdf->line($this->posxdesc-1, $tab_top, $this->posxdesc-1, $tab_top + $tab_height);
$pdf->SetXY($this->posxdesc-1, $tab_top+1);
$pdf->MultiCell($this->posxdate-$this->posxdesc-1,1,$outputlangs->transnoentities("Description"),'','L');
//Date
// Date
$pdf->line($this->posxdate-1, $tab_top, $this->posxdate-1, $tab_top + $tab_height);
$pdf->SetXY($this->posxdate-1, $tab_top+1);
$pdf->MultiCell($this->posxtype-$this->posxdate-1,2, $outputlangs->transnoentities("Date"),'','C');
//Type
// Type
$pdf->line($this->posxtype-1, $tab_top, $this->posxtype-1, $tab_top + $tab_height);
$pdf->SetXY($this->posxtype-1, $tab_top+1);
$pdf->MultiCell($this->posxprojet-$this->posxtype-1,2, $outputlangs->transnoentities("Type"),'','C');
// Projet
// Project
$pdf->line($this->posxprojet-1, $tab_top, $this->posxprojet-1, $tab_top + $tab_height);
$pdf->SetXY($this->posxprojet-1, $tab_top+1);
$pdf->MultiCell($this->posxtva-$this->posxprojet-1,2, $outputlangs->transnoentities("Project"),'','C');
//TVA
// VAT
$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
$pdf->SetXY($this->posxtva-1, $tab_top+1);
$pdf->MultiCell($this->posxup-$this->posxtva-1,2, $outputlangs->transnoentities("VAT"),'','C');
//PU
// 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');
//QTY
// Quantity
$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
$pdf->SetXY($this->posxqty-1, $tab_top+1);
$pdf->MultiCell($this->postotalttc-$this->posxqty,2, $outputlangs->transnoentities("Qty"),'','R');
//TOTALTTC
// Total with all taxes
$pdf->line($this->postotalttc, $tab_top, $this->postotalttc, $tab_top + $tab_height);
$pdf->SetXY($this->postotalttc-1, $tab_top+1);
$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalttc, 2, $outputlangs->transnoentities("TotalTTC"),'','R');

View File

@ -828,9 +828,8 @@ if ($action == "addline")
$object_ligne->fk_c_type_fees = GETPOST('fk_c_type_fees');
$vatrate=GETPOST('vatrate');
$object_ligne->fk_c_tva = $vatrate;
$object_ligne->vatrate = $vatrate;
$object_ligne->fk_c_tva = GETPOST('fk_c_tva');
$object_ligne->vatrate = GETPOST('vatrate');
$object_ligne->fk_projet = $fk_projet;
@ -878,8 +877,8 @@ if ($action == "addline")
$type = 0; // TODO What if service
$tmp = calcul_price_total($qty, $up, 0, $vatrate, 0, 0, 0, 'TTC', 0, $type);
$object_ligne->total_ttc = $tmp[2];
$object_ligne->vatrate = GETPOST('vatrate');
$object_ligne->total_ttc = $tmp[2];
$object_ligne->total_ht = $tmp[0];
$object_ligne->total_tva = $tmp[1];
@ -950,8 +949,8 @@ if ($action == "updateligne" )
$rowid = $_POST['rowid'];
$type_fees_id = GETPOST('fk_c_type_fees');
$c_tva=GETPOST('vatrate');
$object_ligne->fk_c_tva = $c_tva;
$object_ligne->fk_c_tva = GETPOST('fk_c_tva');
$object_ligne->vatrate = GETPOST('vatrate');
$projet_id = $fk_projet;
$comments = GETPOST('comments');
$qty = GETPOST('qty');
@ -1008,9 +1007,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);
@ -1528,7 +1527,7 @@ else
// Fetch Lines of current expense report
$sql = 'SELECT fde.rowid, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_projet, fde.date,';
$sql.= ' fde.fk_c_tva as vatrate, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,';
$sql.= ' fde.fk_c_tva as fk_c_tva, fde.tva_tx as vatrate, 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';
@ -1639,7 +1638,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>';
@ -1651,7 +1650,7 @@ else
// VAT
print '<td style="text-align:right;">';
print $form->load_tva('fk_c_tva', (isset($_POST["fk_c_tva"])?$_POST["fk_c_tva"]:$objp->vatrate), $mysoc, '');
print $form->load_tva('vatrate', (isset($_POST["vatrate"])?$_POST["vatrate"]:$objp->vatrate), $mysoc, '');
print '</td>';
// Unit price
@ -1659,7 +1658,7 @@ else
print '<input type="text" size="6" name="value_unit" value="'.$objp->value_unit.'" />';
print '</td>';
// Qty
// Quantity
print '<td style="text-align:right;">';
print '<input type="text" size="4" name="qty" value="'.$objp->qty.'" />';
print '</td>';
@ -1744,7 +1743,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 +1804,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 +1815,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 +1830,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 +1840,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 +1873,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 +1887,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 +1898,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 +1909,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 +1921,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 +1943,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 +1958,7 @@ print '</div>';
print '<div style="width:50%">';
/*
* Documents generes
* Generate documents
*/
if($user->rights->expensereport->export && $object->fk_statut>0 && $action != 'edit')
{

View File

@ -539,7 +539,6 @@ class ExpenseReport extends CommonObject
$line->total_tva=20;
$line->total_ttc=120;
$line->qty=1;
$line->fk_c_tva=20;
$line->vatrate=20;
$line->value_unit=120;
$line->fk_expensereport=0;
@ -1207,7 +1206,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 +1216,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,'.','');