Merge pull request #2108 from frederic34/patch-14

Update Order Preview
This commit is contained in:
Laurent Destailleur 2014-11-27 21:50:21 +01:00
commit d4ac3c96dd

View File

@ -3,7 +3,8 @@
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004-2011 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
@ -22,21 +23,17 @@
/**
* \file htdocs/commande/apercu.php
* \ingroup commande
* \brief Page de l'onglet apercu d'une commande
* \brief Preview tab of order
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
$langs->load('orders');
$langs->load('propal');
$langs->load("bills");
$langs->load('compta');
$langs->load('sendings');
// Security check
$socid=0;
@ -47,19 +44,11 @@ $result=restrictedArea($user,'commande',$id,'');
/*
* View
* View Mode
*/
llxHeader('',$langs->trans('Order'),'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes');
$form = new Form($db);
/* *************************************************************************** */
/* */
/* Mode fiche */
/* */
/* *************************************************************************** */
if ($id > 0 || ! empty($ref))
{
$object = new Commande($db);
@ -70,40 +59,46 @@ if ($id > 0 || ! empty($ref))
$soc->fetch($object->socid);
$head = commande_prepare_head($object);
$head = commande_prepare_head($object);
dol_fiche_head($head, 'preview', $langs->trans("CustomerOrder"), 0, 'order');
print '<table class="border" width="100%">';
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="18%">'.$langs->trans("Ref")."</td>";
print '<td colspan="2">'.$object->ref.'</td>';
print '<td width="50%">'.$langs->trans("Source").' : '.$object->getLabelSource();
if ($object->source == 0)
{
// Propale
$propal = new Propal($db);
$propal->fetch($object->propale_id);
print ' -> <a href="'.DOL_URL_ROOT.'/comm/propal.php?id='.$propal->id.'">'.$propal->ref.'</a>';
}
print "</td></tr>";
print '<tr><td width="25%">'.$langs->trans("Ref")."</td>";
print '<td colspan="5">'.$object->ref.'</td></tr>';
// Ref cde client
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td class="nowrap">';
print $langs->trans('RefCustomer').'</td><td align="left">';
print '</td>';
print '</tr></table>';
print '</td>';
print '<td colspan="2">';
print $object->ref_client;
print '</td>';
$nbrow=6;
print '<td rowspan="'.$nbrow.'" valign="top">';
print '<tr><td>'.$langs->trans('RefCustomer').'</td>';
print '<td colspan="5">'.$object->ref_client.'</td>';
print '</tr>';
/*
* Documents
*/
// Client
print '<tr><td>'.$langs->trans("Customer").'</td>';
print '<td colspan="5">'.$soc->getNomUrl(1).'</td>';
print '</tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td>';
print '<td colspan="5">'.$object->getLibStatut(4).'</td>';
print '</tr>';
// Discount - left part
print '<tr><td>'.$langs->trans('Discounts').'</td>';
print '<td colspan="5">'.$object->remise_percent.'%</td>';
print '</tr>';
// Date - left part
print '<tr><td>'.$langs->trans("Date").'</td>';
print '<td colspan="3">'.dol_print_date($object->date,"daytext").'</td>';
// Right part with $rowspan lines
$rowspan=4;
print '<td rowspan="'.$rowspan.'" valign="top" width="50%">';
/*
* Documents
*/
$objectref = dol_sanitizeFileName($object->ref);
$dir_output = $conf->commande->dir_output . "/";
$filepath = $dir_output . $objectref . "/";
@ -119,16 +114,16 @@ if ($id > 0 || ! empty($ref))
$var=true;
// Si fichier PDF existe
// if PDF file exist
if (file_exists($file))
{
$encfile = urlencode($file);
print_titre($langs->trans("Documents"));
print '<table class="border" width="100%">';
print '<table class="nobordernopadding" width="100%">';
print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Documents").'</td></tr>';
print "<tr ".$bc[$var]."><td>".$langs->trans("Order")." PDF</td>";
print '<td><a data-ajax="false" href="'.DOL_URL_ROOT . '/document.php?modulepart=commande&file='.urlencode($relativepath).'">'.$object->ref.'.pdf</a></td>';
print '<td><a data-ajax="false" href="'.DOL_URL_ROOT . '/document.php?modulepart=commande&amp;file='.urlencode($relativepath).'">'.$object->ref.'.pdf</a></td>';
print '<td align="right">'.dol_print_size(dol_filesize($file)).'</td>';
print '<td align="right">'.dol_print_date(dol_filemtime($file),'dayhour').'</td>';
print '</tr>';
@ -139,7 +134,7 @@ if ($id > 0 || ! empty($ref))
{
print "<tr ".$bc[$var]."><td>Commande detaillee</td>";
print '<td><a data-ajax="false" href="'.DOL_URL_ROOT . '/document.php?modulepart=commande&file='.urlencode($relativepathdetail).'">'.$object->ref.'-detail.pdf</a></td>';
print '<td><a data-ajax="false" href="'.DOL_URL_ROOT . '/document.php?modulepart=commande&amp;file='.urlencode($relativepathdetail).'">'.$object->ref.'-detail.pdf</a></td>';
print '<td align="right">'.dol_print_size(dol_filesize($filedetail)).'</td>';
print '<td align="right">'.dol_print_date(dol_filemtime($filedetail),'dayhour').'</td>';
print '</tr>';
@ -162,37 +157,24 @@ if ($id > 0 || ! empty($ref))
}
}
print "</td></tr>";
print '</td></tr>';
// Client
print "<tr><td>".$langs->trans("Customer")."</td>";
print '<td colspan="2">';
print '<a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$soc->id.'">'.$soc->getNomUrl(1).'</a>';
print '</td>';
// Total HT - left part
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>';
print '</tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td>';
print "<td colspan=\"2\">".$object->getLibStatut(4)."</td>\n";
// Total VAT - left part
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>';
print '</tr>';
// Date
print '<tr><td>'.$langs->trans("Date").'</td>';
print "<td colspan=\"2\">".dol_print_date($object->date,"daytext")."</td>\n";
print '</tr>';
// Total TTC - left part
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>';
print '</tr>';
// ligne 6
// partie Gauche
print '<tr><td height="10" nowrap>'.$langs->trans('GlobalDiscount').'</td>';
print '<td colspan="2">'.$object->remise_percent.'%</td>';
print '</tr>';
// ligne 7
// partie Gauche
print '<tr><td height="10">'.$langs->trans('AmountHT').'</td>';
print '<td align="right" colspan="1"><b>'.price($object->total_ht).'</b></td>';
print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>';
print '</table>';
print '</table>';
dol_fiche_end();
}
@ -203,10 +185,13 @@ if ($id > 0 || ! empty($ref))
}
}
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=apercucommande&file='.urlencode($relativepathimage).'">';
print '<img class="photo photowithmargin" src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercucommande&amp;file='.urlencode($relativepathimage).'">';
}
// Si fichier png PDF de plus d'1 page trouve
elseif (file_exists($fileimagebis))
@ -219,10 +204,13 @@ elseif (file_exists($fileimagebis))
if (file_exists($dir_output.$preview))
{
print '<img style="background: #FFF" src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercucommande&file='.urlencode($preview).'"><p>';
print '<img class="photo photowithmargin" src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercucommande&amp;file='.urlencode($preview).'"><p>';
}
}
}
print '</div>';
print '</td></tr>';
print '</table>';
llxFooter();