Skip to content

Commit

Permalink
Merge pull request #2111 from frederic34/patch-13
Browse files Browse the repository at this point in the history
Update Invoice Preview to be like order and propal preview
  • Loading branch information
eldy committed Nov 27, 2014
2 parents e6d200d + bc58641 commit f01c5d0
Showing 1 changed file with 48 additions and 70 deletions.
118 changes: 48 additions & 70 deletions htdocs/compta/facture/apercu.php
Expand Up @@ -3,7 +3,8 @@
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Frederic France <frederic.france@free.fr>
*
* 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
Expand All @@ -21,9 +22,9 @@
*/

/**
* \file htdocs/compta/facture/apercu.php
* \ingroup facture
* \brief Page de l'onglet apercu d'une facture
* \file htdocs/compta/facture/apercu.php
* \ingroup facture
* \brief Preview Tab of invoice
*/

require '../../main.inc.php';
Expand Down Expand Up @@ -67,45 +68,35 @@
$soc = new Societe($db);
$soc->fetch($object->socid);

$author = new User($db);
if ($object->user_author)
{
$author->fetch($object->user_author);
}

$head = facture_prepare_head($object);
dol_fiche_head($head, 'preview', $langs->trans("InvoiceCustomer"), 0, 'bill');


$totalpaye = $object->getSommePaiement();

/*
* Facture
* Invoice
*/
print '<table class="border" width="100%">';
$rowspan=3;

// Ref
print '<tr><td width="20%">'.$langs->trans('Ref').'</td><td colspan="5">'.$object->ref.'</td></tr>';
print '<tr><td width="25%">'.$langs->trans('Ref').'</td>';
print '<td colspan="5">'.$object->ref.'</td>';
print '</tr>';

// Ref customer
print '<tr><td width="20%">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('RefCustomer');
print '</td>';
print '</tr></table>';
print '</td>';
print '<td colspan="5">';
print $object->ref_client;
print '</td></tr>';
print '<tr><td>'.$langs->trans('RefCustomer').'</td>';
print '<td colspan="5">'.$object->ref_client.'</td>';
print '</tr>';

// Societe
// Thirdparty
print '<tr><td>'.$langs->trans("Company").'</td>';
print '<td colspan="5">'.$soc->getNomUrl(1,'compta').'</td>';
print '</tr>';

// Type
print '<tr><td>'.$langs->trans('Type').'</td><td colspan="5">';
print '<tr><td>'.$langs->trans('Type').'</td>';
print '<td colspan="5">';
print $object->getLibType();
if ($object->type == Facture::TYPE_REPLACEMENT)
{
Expand Down Expand Up @@ -141,14 +132,15 @@
$facthatreplace->fetch($objectidnext);
print ' ('.$langs->transnoentities("ReplacedByInvoice",$facthatreplace->getNomUrl(1)).')';
}
print '</td></tr>';
print '</td>';
print '</tr>';

// Relative and absolute discounts
$addabsolutediscount=' <a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$soc->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'?facid='.$object->id.'">'.$langs->trans("AddGlobalDiscount").'</a>';
$addcreditnote=' <a href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&socid='.$soc->id.'&type=2&backtopage='.urlencode($_SERVER["PHP_SELF"]).'?facid='.$object->id.'">'.$langs->trans("AddCreditNote").'</a>';

print '<tr><td>'.$langs->trans('Discounts');
print '</td><td colspan="5">';
print '<tr><td>'.$langs->trans('Discounts').'</td>';
print '<td colspan="5">';
if ($soc->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_percent);
else print $langs->trans("CompanyHasNoRelativeDiscount");

Expand Down Expand Up @@ -187,7 +179,7 @@
}
else
{
if ($absolute_creditnote > 0) // If not linke will be added later
if ($absolute_creditnote > 0) // If not linked will be added later
{
if ($object->statut == 0 && $object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT) print ' - '.$addabsolutediscount.'<br>';
else print '.';
Expand Down Expand Up @@ -230,41 +222,17 @@
print $addabsolutediscount;
//print ' &nbsp; - &nbsp; '.$addcreditnote; // We disbale link to credit note
}*/
print '</td></tr>';
print '</td>';
print '</tr>';

// Dates
print '<tr><td>'.$langs->trans("Date").'</td>';
print '<td colspan="5">'.dol_print_date($object->date,"daytext").'</td>';
print "</tr>";

// Date payment term
print '<tr><td>'.$langs->trans('DateMaxPayment').'</td>';
print '<td colspan="5">';
if ($object->type != Facture::TYPE_CREDIT_NOTE)
{
print dol_print_date($object->date_lim_reglement,'daytext');
if ($object->date_lim_reglement < ($now - $conf->facture->client->warning_delay) && ! $object->paye && $object->statut == 1 && ! $object->am) print img_warning($langs->trans('Late'));
}
else
{
print '&nbsp;';
}
print '</td></tr>';
print '<td>'.dol_print_date($object->date,"daytext").'</td>';

// Conditions reglement
print '<tr><td>'.$langs->trans("PaymentConditionsShort").'</td><td colspan="5">';
$form->form_conditions_reglement($_SERVER["PHP_SELF"]."?facid=$object->id",$object->cond_reglement_id,"none");
print '</td>';
print '</td></tr>';

// Mode de reglement
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td colspan="3">';
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id,$object->mode_reglement_id,'none');
print '</td>';

$nbrows=5;
if (! empty($conf->projet->enabled)) $nbrows++;
print '<td rowspan="'.$nbrows.'" colspan="2" valign="top">';
// Right part with $rowspan lines
$rowspan=5;
if (! empty($conf->projet->enabled)) $rowspan++;
print '<td rowspan="'.$rowspan.'" valign="top" width="50%">';

/*
* Documents
Expand All @@ -278,7 +246,7 @@
$relativepathdetail = $objectref.'/'.$objectref.'-detail.pdf';

// Define path to preview pdf file (preview precompiled "file.ext" are "file.ext_preview.png")
$fileimage = $file.'_preview.png'; // If PDF has 1 page
$fileimage = $file.'_preview.png'; // If PDF has 1 page
$fileimagebis = $file.'_preview-0.pdf.png'; // If PDF has more than one page
$relativepathimage = $relativepath.'_preview.png';

Expand Down Expand Up @@ -330,25 +298,30 @@

// Total HT
print '<tr><td>'.$langs->trans("AmountHT").'</td>';
print '<td align="right" class="nowrap"><b>' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . '</b></td></tr>';
print '<td align="right" class="nowrap"><b>' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . '</b></td>';
print '</tr>';

// Total VAT
print '<tr><td>'.$langs->trans('AmountVAT').'</td>';
print '<td align="right" class="nowrap"><b>' . price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency) . '</b></td></tr>';
print '<td align="right" class="nowrap"><b>' . price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency) . '</b></td>';
print '</tr>';

// Total TTC
print '<tr><td>'.$langs->trans('AmountTTC').'</td>';
print '<td align="right" class="nowrap"><b>' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . '</b></td></tr>';
print '<td align="right" class="nowrap"><b>' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . '</b></td>';
print '</tr>';

// Statut
print '<tr><td>'.$langs->trans('Status').'</td><td align="left" colspan="3">'.($object->getLibStatut(4,$totalpaye)).'</td></tr>';
print '<tr><td>'.$langs->trans('Status').'</td>';
print '<td align="left">'.($object->getLibStatut(4,$totalpaye)).'</td>';
print '</tr>';

// Projet
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
print '<tr>';
print '<td>'.$langs->trans("Project").'</td><td colspan="3">';
print '<tr><td>'.$langs->trans("Project").'</td>';
print '<td>';
if ($object->fk_project > 0)
{
$project = New Project($db);
Expand All @@ -369,14 +342,17 @@
else
{
// Facture non trouvee
print $langs->trans("ErrorBillNotFound",$_GET["facid"]);
print $langs->trans("ErrorBillNotFound",$id);
}
}

print '<table class="border" width="100%">';
print '<tr><td>';
print '<div class="photolist">';
// Si fichier png PDF d'1 page trouve
if (file_exists($fileimage))
{
print '<img style="background: #FFF" src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercufacture&file='.urlencode($relativepathimage).'">';
print '<img class="photo photowithmargin" src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercufacture&amp;file='.urlencode($relativepathimage).'">';
}
// Si fichier png PDF de plus d'1 page trouve
elseif (file_exists($fileimagebis))
Expand All @@ -389,11 +365,13 @@

if (file_exists($dir_output.$preview))
{
print '<img style="background: #FFF" src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercufacture&file='.urlencode($preview).'"><p>';
print '<img class="photo photowithmargin" src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercufacture&amp;file='.urlencode($preview).'"><p>';
}
}
}

print '</div>';
print '</td></tr>';
print '</table>';

llxFooter();

Expand Down

0 comments on commit f01c5d0

Please sign in to comment.