Fix: reencoding preview tabs, Imagick is a class today

Fix: uniformize code
This commit is contained in:
Regis Houssin 2011-03-04 16:52:29 +00:00
parent a6e61492bc
commit 11a3b7f6eb
5 changed files with 355 additions and 479 deletions

View File

@ -36,9 +36,10 @@ $langs->load('propal');
$langs->load("bills"); $langs->load("bills");
$langs->load('compta'); $langs->load('compta');
$id = isset($_GET["id"])?$_GET["id"]:'';
// Security check // Security check
$socid=0;
$id = GETPOST("id");
$ref = GETPOST("ref");
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'propale', $id, 'propal'); $result = restrictedArea($user, 'propale', $id, 'propal');
@ -57,7 +58,7 @@ $html = new Form($db);
/* */ /* */
/* *************************************************************************** */ /* *************************************************************************** */
if ($_GET["id"] > 0) if ($id > 0 || ! empty($ref))
{ {
$object = new Propal($db); $object = new Propal($db);
@ -118,16 +119,16 @@ if ($_GET["id"] > 0)
/* /*
* Documents * Documents
*/ */
$propalref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);
$dir_output = $conf->propale->dir_output . "/"; $dir_output = $conf->propale->dir_output . "/";
$filepath = $dir_output . $propalref . "/"; $filepath = $dir_output . $objectref . "/";
$file = $filepath . $propalref . ".pdf"; $file = $filepath . $objectref . ".pdf";
$filedetail = $filepath . $propalref . "-detail.pdf"; $filedetail = $filepath . $objectref . "-detail.pdf";
$relativepath = "${propalref}/${propalref}.pdf"; $relativepath = "${objectref}/${objectref}.pdf";
$relativepathdetail = "${propalref}/${propalref}-detail.pdf"; $relativepathdetail = "${objectref}/${objectref}-detail.pdf";
// Chemin vers png apercus // Chemin vers png apercus
$relativepathimage = "${propalref}/${propalref}.pdf.png"; $relativepathimage = "${objectref}/${objectref}.pdf.png";
$fileimage = $file.".png"; // Si PDF d'1 page $fileimage = $file.".png"; // Si PDF d'1 page
$fileimagebis = $file.".png.0"; // Si PDF de plus d'1 page $fileimagebis = $file.".png.0"; // Si PDF de plus d'1 page

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -20,20 +20,19 @@
*/ */
/** /**
\file htdocs/commande/apercu.php * \file htdocs/commande/apercu.php
\ingroup commande * \ingroup commande
\brief Page de l'onglet apercu d'une commande * \brief Page de l'onglet apercu d'une commande
\version $Id$ * \version $Id$
*/ */
require("../main.inc.php"); require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/order.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/order.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
require_once(DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'); require_once(DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php');
if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'); if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php');
if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php"); if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php");
if (!$user->rights->commande->lire) accessforbidden();
$langs->load('orders'); $langs->load('orders');
$langs->load('propal'); $langs->load('propal');
$langs->load("bills"); $langs->load("bills");
@ -42,10 +41,10 @@ $langs->load('sendings');
// Security check // Security check
$socid=0; $socid=0;
$comid = isset($_GET["id"])?$_GET["id"]:''; $id = GETPOST("id");
$ref = GETPOST("ref");
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'commande',$comid,''); $result=restrictedArea($user,'commande',$id,'');
/* /*
@ -62,52 +61,30 @@ $html = new Form($db);
/* */ /* */
/* *************************************************************************** */ /* *************************************************************************** */
if ($_GET["id"] > 0) { if ($id > 0 || ! empty($ref))
$commande = new Commande($db);
if ( $commande->fetch($_GET["id"], $user->societe_id) > 0)
{ {
$soc = new Societe($db, $commande->socid); $object = new Commande($db);
$soc->fetch($commande->socid);
if ($object->fetch($id,$ref) > 0)
{
$soc = new Societe($db, $object->socid);
$soc->fetch($object->socid);
$head = commande_prepare_head($commande); $head = commande_prepare_head($object);
dol_fiche_head($head, 'preview', $langs->trans("CustomerOrder"), 0, 'order'); dol_fiche_head($head, 'preview', $langs->trans("CustomerOrder"), 0, 'order');
/*
* Commande
*/
$sql = 'SELECT s.nom, s.rowid, c.amount_ht, c.fk_projet, c.remise, c.tva, c.total_ttc, c.ref, c.fk_statut, c.date_commande as dp, c.note,';
$sql.= ' c.fk_user_author, c.fk_user_valid, c.fk_user_cloture, c.date_creation, c.date_valid, c.date_cloture';
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s';
$sql.= ', '.MAIN_DB_PREFIX.'commande as c';
$sql.= ' WHERE c.fk_soc = s.rowid';
$sql.= ' AND c.rowid = '.$commande->id;
if ($socid) $sql .= ' AND s.rowid = '.$socid;
$result = $db->query($sql);
if ($result)
{
if ($db->num_rows($result))
{
$obj = $db->fetch_object($result);
$societe = new Societe($db);
$societe->fetch($obj->rowid);
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref // Ref
print '<tr><td width="18%">'.$langs->trans("Ref")."</td>"; print '<tr><td width="18%">'.$langs->trans("Ref")."</td>";
print '<td colspan="2">'.$commande->ref.'</td>'; print '<td colspan="2">'.$object->ref.'</td>';
print '<td width="50%">'.$langs->trans("Source").' : '.$commande->getLabelSource(); print '<td width="50%">'.$langs->trans("Source").' : '.$object->getLabelSource();
if ($commande->source == 0) if ($object->source == 0)
{ {
// Propale // Propale
$propal = new Propal($db); $propal = new Propal($db);
$propal->fetch($commande->propale_id); $propal->fetch($object->propale_id);
print ' -> <a href="'.DOL_URL_ROOT.'/comm/propal.php?id='.$propal->id.'">'.$propal->ref.'</a>'; print ' -> <a href="'.DOL_URL_ROOT.'/comm/propal.php?id='.$propal->id.'">'.$propal->ref.'</a>';
} }
print "</td></tr>"; print "</td></tr>";
@ -120,7 +97,7 @@ if ($_GET["id"] > 0) {
print '</tr></table>'; print '</tr></table>';
print '</td>'; print '</td>';
print '<td colspan="2">'; print '<td colspan="2">';
print $commande->ref_client; print $object->ref_client;
print '</td>'; print '</td>';
$nbrow=6; $nbrow=6;
print '<td rowspan="'.$nbrow.'" valign="top">'; print '<td rowspan="'.$nbrow.'" valign="top">';
@ -128,16 +105,16 @@ if ($_GET["id"] > 0) {
/* /*
* Documents * Documents
*/ */
$commanderef = dol_sanitizeFileName($commande->ref); $objectref = dol_sanitizeFileName($object->ref);
$dir_output = $conf->commande->dir_output . "/"; $dir_output = $conf->commande->dir_output . "/";
$filepath = $dir_output . $commanderef . "/"; $filepath = $dir_output . $objectref . "/";
$file = $filepath . $commanderef . ".pdf"; $file = $filepath . $objectref . ".pdf";
$filedetail = $filepath . $commanderef . "-detail.pdf"; $filedetail = $filepath . $objectref . "-detail.pdf";
$relativepath = "${commanderef}/${commanderef}.pdf"; $relativepath = "${objectref}/${objectref}.pdf";
$relativepathdetail = "${commanderef}/${commanderef}-detail.pdf"; $relativepathdetail = "${objectref}/${objectref}-detail.pdf";
// Chemin vers png aper<65>us // Chemin vers png apercus
$relativepathimage = "${commanderef}/${commanderef}.pdf.png"; $relativepathimage = "${objectref}/${objectref}.pdf.png";
$fileimage = $file.".png"; // Si PDF d'1 page $fileimage = $file.".png"; // Si PDF d'1 page
$fileimagebis = $file.".png.0"; // Si PDF de plus d'1 page $fileimagebis = $file.".png.0"; // Si PDF de plus d'1 page
@ -152,16 +129,18 @@ if ($_GET["id"] > 0) {
print "<tr $bc[$var]><td>".$langs->trans("Order")." PDF</td>"; print "<tr $bc[$var]><td>".$langs->trans("Order")." PDF</td>";
print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=commande&file='.urlencode($relativepath).'">'.$commande->ref.'.pdf</a></td>'; print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=commande&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_size(dol_filesize($file)).'</td>';
print '<td align="right">'.dol_print_date(dol_filemtime($file),'dayhour').'</td>'; print '<td align="right">'.dol_print_date(dol_filemtime($file),'dayhour').'</td>';
print '</tr>'; print '</tr>';
// Si fichier detail PDF existe // Si fichier detail PDF existe
if (file_exists($filedetail)) { // commande d<>taill<6C>e suppl<70>mentaire // TODO obsolete ?
if (file_exists($filedetail))
{
print "<tr $bc[$var]><td>Commande detaillee</td>"; print "<tr $bc[$var]><td>Commande detaillee</td>";
print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=commande&file='.urlencode($relativepathdetail).'">'.$commande->ref.'-detail.pdf</a></td>'; print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=commande&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_size(dol_filesize($filedetail)).'</td>';
print '<td align="right">'.dol_print_date(dol_filemtime($filedetail),'dayhour').'</td>'; print '<td align="right">'.dol_print_date(dol_filemtime($filedetail),'dayhour').'</td>';
print '</tr>'; print '</tr>';
@ -173,23 +152,11 @@ if ($_GET["id"] > 0) {
{ {
if (class_exists("Imagick")) if (class_exists("Imagick"))
{ {
$handle = imagick_readimage( $file ) ; $ret = dol_convert_file($file);
if ( imagick_iserror( $handle ) ) if ($ret < 0) $error++;
{
$reason = imagick_failedreason( $handle ) ;
$description = imagick_faileddescription( $handle ) ;
print "handle failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n";
} }
imagick_convert( $handle, "PNG" ) ; else
if ( imagick_iserror( $handle ) )
{ {
$reason = imagick_failedreason( $handle ) ;
$description = imagick_faileddescription( $handle ) ;
print "handle failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n";
}
imagick_writeimages( $handle, $file .".png");
} else {
$langs->load("other"); $langs->load("other");
print '<font class="error">'.$langs->trans("ErrorNoImagickReadimage").'</font>'; print '<font class="error">'.$langs->trans("ErrorNoImagickReadimage").'</font>';
} }
@ -198,52 +165,49 @@ if ($_GET["id"] > 0) {
print "</td></tr>"; print "</td></tr>";
// Client // Client
print "<tr><td>".$langs->trans("Customer")."</td>"; print "<tr><td>".$langs->trans("Customer")."</td>";
print '<td colspan="2">'; print '<td colspan="2">';
print '<a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$societe->id.'">'.$societe->nom.'</a>'; print '<a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a>';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Statut // Statut
print '<tr><td>'.$langs->trans("Status").'</td>'; print '<tr><td>'.$langs->trans("Status").'</td>';
print "<td colspan=\"2\">".$commande->getLibStatut(4)."</td>\n"; print "<td colspan=\"2\">".$object->getLibStatut(4)."</td>\n";
print '</tr>'; print '</tr>';
// Date // Date
print '<tr><td>'.$langs->trans("Date").'</td>'; print '<tr><td>'.$langs->trans("Date").'</td>';
print "<td colspan=\"2\">".dol_print_date($commande->date,"daytext")."</td>\n"; print "<td colspan=\"2\">".dol_print_date($object->date,"daytext")."</td>\n";
print '</tr>'; print '</tr>';
// ligne 6 // ligne 6
// partie Gauche // partie Gauche
print '<tr><td height="10" nowrap>'.$langs->trans('GlobalDiscount').'</td>'; print '<tr><td height="10" nowrap>'.$langs->trans('GlobalDiscount').'</td>';
print '<td colspan="2">'.$commande->remise_percent.'%</td>'; print '<td colspan="2">'.$object->remise_percent.'%</td>';
print '</tr>'; print '</tr>';
// ligne 7 // ligne 7
// partie Gauche // partie Gauche
print '<tr><td height="10">'.$langs->trans('AmountHT').'</td>'; print '<tr><td height="10">'.$langs->trans('AmountHT').'</td>';
print '<td align="right" colspan="1"><b>'.price($commande->total_ht).'</b></td>'; print '<td align="right" colspan="1"><b>'.price($object->total_ht).'</b></td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
print '</table>'; print '</table>';
} }
} else { else
dol_print_error($db); {
} // Object not found
} else { print $langs->trans("ErrorOrderNotFound",$id);
// Commande non trouv<75>e
print $langs->trans("ErrorPropalNotFound",$_GET["id"]);
} }
} }
// Si fichier png PDF d'1 page trouv<EFBFBD> // Si fichier png PDF d'1 page trouve
if (file_exists($fileimage)) if (file_exists($fileimage))
{ {
print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercucommande&file='.urlencode($relativepathimage).'">'; print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercucommande&file='.urlencode($relativepathimage).'">';
} }
// Si fichier png PDF de plus d'1 page trouv<EFBFBD> // Si fichier png PDF de plus d'1 page trouve
elseif (file_exists($fileimagebis)) elseif (file_exists($fileimagebis))
{ {
$multiple = $relativepathimage . "."; $multiple = $relativepathimage . ".";
@ -259,11 +223,8 @@ elseif (file_exists($fileimagebis))
} }
} }
print '</div>'; print '</div>';
$db->close(); $db->close();
llxFooter('$Date$ - $Revision$'); llxFooter('$Date$ - $Revision$');

View File

@ -1,7 +1,8 @@
<?php <?php
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 <EFBFBD>ric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -21,38 +22,33 @@
*/ */
/** /**
\file htdocs/compta/facture/apercu.php * \file htdocs/compta/facture/apercu.php
\ingroup facture * \ingroup facture
\brief Page de l'onglet apercu d'une facture * \brief Page de l'onglet apercu d'une facture
\version $Revision$ * \version $Revision$
*/ */
require("../../main.inc.php"); require("../../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
require_once(DOL_DOCUMENT_ROOT.'/lib/invoice.lib.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/invoice.lib.php');
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php"); if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php");
if (!$user->rights->facture->lire)
accessforbidden();
$langs->load("bills"); $langs->load("bills");
// Security check
// S<>curit<69> acc<63>s client $socid=0;
if ($user->societe_id > 0) $id = GETPOST("id");
{ $ref = GETPOST("ref");
$action = ''; if ($user->societe_id) $socid=$user->societe_id;
$socid = $user->societe_id; $result = restrictedArea($user, 'facture', $id);
}
/* /*
* View * View
*/ */
$now=gmmktime(); $now=dol_now();
llxHeader('',$langs->trans("Bill"),'Facture'); llxHeader('',$langs->trans("Bill"),'Facture');
@ -64,20 +60,22 @@ $html = new Form($db);
/* */ /* */
/* *************************************************************************** */ /* *************************************************************************** */
if ($_GET["facid"] > 0) if ($id > 0 || ! empty($ref))
{ {
$fac = New Facture($db); $object = New Facture($db);
if ( $fac->fetch($_GET["facid"], $user->societe_id) > 0)
if ($object->fetch($id,$ref) > 0)
{ {
$soc = new Societe($db, $fac->socid); $soc = new Societe($db, $object->socid);
$soc->fetch($fac->socid); $soc->fetch($object->socid);
$author = new User($db); $author = new User($db);
if ($fac->user_author) if ($object->user_author)
{ {
$author->fetch($fac->user_author); $author->fetch($object->user_author);
} }
$head = facture_prepare_head($fac); $head = facture_prepare_head($object);
dol_fiche_head($head, 'preview', $langs->trans("InvoiceCustomer"), 0, 'bill'); dol_fiche_head($head, 'preview', $langs->trans("InvoiceCustomer"), 0, 'bill');
@ -88,7 +86,7 @@ if ($_GET["facid"] > 0)
$rowspan=3; $rowspan=3;
// Reference // Reference
print '<tr><td width="20%">'.$langs->trans('Ref').'</td><td colspan="5">'.$fac->ref.'</td></tr>'; print '<tr><td width="20%">'.$langs->trans('Ref').'</td><td colspan="5">'.$object->ref.'</td></tr>';
// Societe // Societe
print '<tr><td>'.$langs->trans("Company").'</td>'; print '<tr><td>'.$langs->trans("Company").'</td>';
@ -97,36 +95,22 @@ if ($_GET["facid"] > 0)
// Dates // Dates
print '<tr><td>'.$langs->trans("Date").'</td>'; print '<tr><td>'.$langs->trans("Date").'</td>';
print '<td colspan="3">'.dol_print_date($fac->date,"daytext").'</td>'; print '<td colspan="3">'.dol_print_date($object->date,"daytext").'</td>';
print '<td>'.$langs->trans("DateMaxPayment").'</td><td>' . dol_print_date($fac->date_lim_reglement,"daytext"); print '<td>'.$langs->trans("DateMaxPayment").'</td><td>' . dol_print_date($object->date_lim_reglement,"daytext");
if ($fac->paye == 0 && $fac->date_lim_reglement < ($now - $conf->facture->client->warning_delay)) print img_warning($langs->trans("Late")); if ($object->paye == 0 && $object->date_lim_reglement < ($now - $conf->facture->client->warning_delay)) print img_warning($langs->trans("Late"));
print "</td></tr>"; print "</td></tr>";
// Conditions et modes de r<EFBFBD>glement // Conditions et modes de reglement
print '<tr><td>'.$langs->trans("PaymentConditions").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("PaymentConditions").'</td><td colspan="3">';
$html->form_conditions_reglement($_SERVER["PHP_SELF"]."?facid=$fac->id",$fac->cond_reglement_id,"none"); $html->form_conditions_reglement($_SERVER["PHP_SELF"]."?facid=$object->id",$object->cond_reglement_id,"none");
print '</td>'; print '</td>';
print '<td width="25%">'.$langs->trans("PaymentMode").'</td><td width="25%">'; print '<td width="25%">'.$langs->trans("PaymentMode").'</td><td width="25%">';
$html->form_modes_reglement($_SERVER["PHP_SELF"]."?facid=$fac->id",$fac->mode_reglement_id,"none"); $html->form_modes_reglement($_SERVER["PHP_SELF"]."?facid=$object->id",$object->mode_reglement_id,"none");
print '</td></tr>'; print '</td></tr>';
// Remise globale // Remise globale
print '<tr><td>'.$langs->trans('GlobalDiscount').'</td>'; print '<tr><td>'.$langs->trans('GlobalDiscount').'</td>';
/* print '<td colspan="3">'.$object->remise_percent.'%</td>';
if ($fac->brouillon == 1 && $user->rights->facture->creer)
{
print '<form action="facture.php?facid='.$fac->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setremise">';
print '<td colspan="3"><input type="text" name="remise" size="1" value="'.$fac->remise_percent.'">% ';
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'"></td>';
print '</form>';
}
else
{
*/
print '<td colspan="3">'.$fac->remise_percent.'%</td>';
// }
$nbrows=5; $nbrows=5;
if ($conf->projet->enabled) $nbrows++; if ($conf->projet->enabled) $nbrows++;
@ -135,20 +119,19 @@ if ($_GET["facid"] > 0)
/* /*
* Documents * Documents
*/ */
$facref = dol_sanitizeFileName($fac->ref); $objectref = dol_sanitizeFileName($object->ref);
$dir_output = $conf->facture->dir_output . "/"; $dir_output = $conf->facture->dir_output . "/";
$filepath = $dir_output . $facref . "/"; $filepath = $dir_output . $objectref . "/";
$file = $filepath . $facref . ".pdf"; $file = $filepath . $objectref . ".pdf";
$filedetail = $filepath . $facref . "-detail.pdf"; $filedetail = $filepath . $objectref . "-detail.pdf";
$relativepath = "${facref}/${facref}.pdf"; $relativepath = "${objectref}/${objectref}.pdf";
$relativepathdetail = "${facref}/${facref}-detail.pdf"; $relativepathdetail = "${objectref}/${objectref}-detail.pdf";
// Chemin vers png aper<EFBFBD>us // Chemin vers png apercus
$relativepathimage = "${facref}/${facref}.pdf.png"; $relativepathimage = "${obejctref}/${objectref}.pdf.png";
$fileimage = $file.".png"; // Si PDF d'1 page $fileimage = $file.".png"; // Si PDF d'1 page
$fileimagebis = $file.".png.0"; // Si PDF de plus d'1 page $fileimagebis = $file.".png.0"; // Si PDF de plus d'1 page
$var=true; $var=true;
// Si fichier PDF existe // Si fichier PDF existe
@ -160,7 +143,7 @@ if ($_GET["facid"] > 0)
print "<tr $bc[$var]><td>".$langs->trans("Bill")." PDF</td>"; print "<tr $bc[$var]><td>".$langs->trans("Bill")." PDF</td>";
print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=facture&file='.urlencode($relativepath).'">'.$fac->ref.'.pdf</a></td>'; print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=facture&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_size(dol_filesize($file)). '</td>';
print '<td align="right">'.dol_print_date(dol_filemtime($file),'dayhour').'</td>'; print '<td align="right">'.dol_print_date(dol_filemtime($file),'dayhour').'</td>';
print '</tr>'; print '</tr>';
@ -168,9 +151,9 @@ if ($_GET["facid"] > 0)
// Si fichier detail PDF existe // Si fichier detail PDF existe
if (file_exists($filedetail)) // facture detaillee supplementaire if (file_exists($filedetail)) // facture detaillee supplementaire
{ {
print "<tr $bc[$var]><td>Facture d<EFBFBD>taill<EFBFBD>e</td>"; print "<tr $bc[$var]><td>Facture detaillee</td>";
print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=facture&file='.urlencode($relativepathdetail).'">'.$fac->ref.'-detail.pdf</a></td>'; print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=facture&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_size(dol_filesize($filedetail)).'</td>';
print '<td align="right">'.dol_print_date(dol_filemtime($filedetail),'dayhour').'</td>'; print '<td align="right">'.dol_print_date(dol_filemtime($filedetail),'dayhour').'</td>';
print '</tr>'; print '</tr>';
@ -183,26 +166,8 @@ if ($_GET["facid"] > 0)
{ {
if (class_exists("Imagick")) if (class_exists("Imagick"))
{ {
$handle = imagick_readimage( $file ) ; $ret = dol_convert_file($file);
if ( imagick_iserror( $handle ) ) if ($ret < 0) $error++;
{
$reason = imagick_failedreason( $handle ) ;
$description = imagick_faileddescription( $handle ) ;
print "handle failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n";
}
imagick_convert( $handle, "PNG" ) ;
if ( imagick_iserror( $handle ) )
{
$reason = imagick_failedreason( $handle ) ;
$description = imagick_faileddescription( $handle ) ;
print "handle failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n";
}
imagick_writeimages( $handle, $file .".png");
} }
else else
{ {
@ -215,16 +180,16 @@ if ($_GET["facid"] > 0)
print "</td></tr>"; print "</td></tr>";
print '<tr><td>'.$langs->trans("AmountHT").'</td>'; print '<tr><td>'.$langs->trans("AmountHT").'</td>';
print '<td align="right" colspan="2"><b>'.price($fac->total_ht).'</b></td>'; print '<td align="right" colspan="2"><b>'.price($object->total_ht).'</b></td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountVAT').'</td><td align="right" colspan="2" nowrap>'.price($fac->total_tva).'</td>'; print '<tr><td>'.$langs->trans('AmountVAT').'</td><td align="right" colspan="2" nowrap>'.price($object->total_tva).'</td>';
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>'; print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td align="right" colspan="2" nowrap>'.price($fac->total_ttc).'</td>'; print '<tr><td>'.$langs->trans('AmountTTC').'</td><td align="right" colspan="2" nowrap>'.price($object->total_ttc).'</td>';
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>'; print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
// Statut // Statut
print '<tr><td>'.$langs->trans('Status').'</td><td align="left" colspan="3">'.($fac->getLibStatut()).'</td></tr>'; print '<tr><td>'.$langs->trans('Status').'</td><td align="left" colspan="3">'.($object->getLibStatut()).'</td></tr>';
// Projet // Projet
if ($conf->projet->enabled) if ($conf->projet->enabled)
@ -232,11 +197,11 @@ if ($_GET["facid"] > 0)
$langs->load("projects"); $langs->load("projects");
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("Project").'</td><td colspan="3">'; print '<td>'.$langs->trans("Project").'</td><td colspan="3">';
if ($fac->fk_project > 0) if ($object->fk_project > 0)
{ {
$project = New Project($db); $project = New Project($db);
$project->fetch($fac->fk_project); $project->fetch($object->fk_project);
print '<a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$fac->fk_project.'">'.$project->title.'</a>'; print '<a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$object->fk_project.'">'.$project->title.'</a>';
} }
else else
{ {
@ -250,17 +215,17 @@ if ($_GET["facid"] > 0)
} }
else else
{ {
// Facture non trouv<EFBFBD>e // Facture non trouvee
print $langs->trans("ErrorBillNotFound",$_GET["facid"]); print $langs->trans("ErrorBillNotFound",$_GET["facid"]);
} }
} }
// Si fichier png PDF d'1 page trouv<EFBFBD> // Si fichier png PDF d'1 page trouve
if (file_exists($fileimage)) if (file_exists($fileimage))
{ {
print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercufacture&file='.urlencode($relativepathimage).'">'; print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercufacture&file='.urlencode($relativepathimage).'">';
} }
// Si fichier png PDF de plus d'1 page trouv<EFBFBD> // Si fichier png PDF de plus d'1 page trouve
elseif (file_exists($fileimagebis)) elseif (file_exists($fileimagebis))
{ {
$multiple = $relativepathimage . "."; $multiple = $relativepathimage . ".";
@ -276,10 +241,8 @@ elseif (file_exists($fileimagebis))
} }
} }
print '</div>'; print '</div>';
$db->close(); $db->close();
llxFooter('$Date$ - $Revision$'); llxFooter('$Date$ - $Revision$');

View File

@ -27,76 +27,61 @@
require('../../main.inc.php'); require('../../main.inc.php');
require_once(DOL_DOCUMENT_ROOT."/lib/prelevement.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/prelevement.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
require_once DOL_DOCUMENT_ROOT."/compta/prelevement/class/bon-prelevement.class.php"; require_once DOL_DOCUMENT_ROOT."/compta/prelevement/class/bon-prelevement.class.php";
$langs->load("bills"); $langs->load("bills");
$langs->load("categories"); $langs->load("categories");
/* // Security check
* Securite acces client $socid=0;
*/ $id = GETPOST("id");
if (!$user->rights->prelevement->bons->lire) accessforbidden(); $ref = GETPOST("ref");
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'prelevement', $id);
llxHeader('','Bon de prelevement'); llxHeader('','Bon de prelevement');
$html = new Form($db); $html = new Form($db);
if ($_GET["id"]) if ($id > 0 || ! empty($ref))
{ {
$bon = new BonPrelevement($db,""); $object = new BonPrelevement($db,"");
if ($bon->fetch($_GET["id"]) == 0) if ($object->fetch($id) == 0)
{ {
$head = prelevement_prepare_head($bon); $head = prelevement_prepare_head($object);
dol_fiche_head($head, 'preview', 'Prelevement : '. $bon->ref); dol_fiche_head($head, 'preview', 'Prelevement : '. $object->ref);
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td>'.$bon->ref.'</td></tr>'; print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td>'.$object->ref.'</td></tr>';
print '<tr><td width="20%">'.$langs->trans("Amount").'</td><td>'.price($bon->amount).'</td></tr>'; print '<tr><td width="20%">'.$langs->trans("Amount").'</td><td>'.price($object->amount).'</td></tr>';
print '<tr><td width="20%">'.$langs->trans("File").'</td><td>'; print '<tr><td width="20%">'.$langs->trans("File").'</td><td>';
$relativepath = 'bon/'.$bon->ref; $relativepath = 'bon/'.$object->ref;
print '<a href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$bon->ref.'</a>'; print '<a href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$object->ref.'</a>';
print '</td></tr>'; print '</td></tr>';
print '</table><br>'; print '</table><br>';
$fileimage = $conf->prelevement->dir_output.'/receipts/'.$bon->ref.'.ps.png.0'; $fileimage = $conf->prelevement->dir_output.'/receipts/'.$object->ref.'.ps.png.0';
$fileps = $conf->prelevement->dir_output.'/receipts/'.$bon->ref.'.ps'; $fileps = $conf->prelevement->dir_output.'/receipts/'.$object->ref.'.ps';
// Conversion du PDF en image png si fichier png non existant // Conversion du PDF en image png si fichier png non existant
if (!file_exists($fileimage)) if (!file_exists($fileimage))
{ {
print $fileimage;
if (class_exists("Imagick")) if (class_exists("Imagick"))
{ {
$ret = dol_convert_file($file);
$handle = imagick_readimage( $fileps ) ; if ($ret < 0) $error++;
if ( imagick_iserror( $handle ) )
{
$reason = imagick_failedreason( $handle ) ;
$description = imagick_faileddescription( $handle ) ;
print "handle failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n";
}
imagick_convert( $handle, "PNG" ) ;
if ( imagick_iserror( $handle ) )
{
$reason = imagick_failedreason( $handle ) ;
$description = imagick_faileddescription( $handle ) ;
print "handle failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n";
}
imagick_writeimage( $handle, $fileps .".png");
} }
else else
{ {
print "Les fonctions <i>imagick</i> ne sont pas disponibles sur ce PHP"; $langs->load("other");
print '<font class="error">'.$langs->trans("ErrorNoImagickReadimage").'</font>';
} }
} }

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -27,17 +27,19 @@
require("../main.inc.php"); require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/fichinter.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/fichinter.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
require_once(DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'); require_once(DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php');
if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php"); if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php");
$langs->load('interventions'); $langs->load('interventions');
$fichinterid = isset($_GET["id"])?$_GET["id"]:'';
// Security check // Security check
$socid=0;
$id = GETPOST("id");
$ref = GETPOST("ref");
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'ficheinter', $fichinterid, 'fichinter'); $result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
llxHeader(); llxHeader();
@ -49,46 +51,26 @@ $html = new Form($db);
/* */ /* */
/* *************************************************************************** */ /* *************************************************************************** */
if ($_GET["id"] > 0) { if ($id > 0 || ! empty($ref))
$fichinter = new Fichinter($db);
if ( $fichinter->fetch($_GET["id"], $user->societe_id) > 0)
{ {
$soc = new Societe($db, $fichinter->socid); $object = new Fichinter($db);
$soc->fetch($fichinter->socid);
if ($object->fetch($id,$ref) > 0)
{
$soc = new Societe($db, $object->socid);
$soc->fetch($object->socid);
$head = fichinter_prepare_head($fichinter); $head = fichinter_prepare_head($object);
dol_fiche_head($head, 'preview', $langs->trans("InterventionCard"), 0, 'intervention'); dol_fiche_head($head, 'preview', $langs->trans("InterventionCard"), 0, 'intervention');
/* /*
* Fiche intervention * Fiche intervention
*/ */
$sql = 'SELECT s.nom, s.rowid, fi.fk_projet, fi.ref, fi.description, fi.fk_statut, fi.datei as di,';
$sql.= ' fi.fk_user_author, fi.fk_user_valid, fi.datec, fi.date_valid';
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'fichinter as fi';
$sql.= ' WHERE fi.fk_soc = s.rowid';
$sql.= ' AND fi.rowid = '.$fichinter->id;
$sql.= ' AND fi.entity = '.$conf->entity;
if ($socid) $sql .= ' AND s.rowid = '.$socid;
$result = $db->query($sql);
if ($result)
{
if ($db->num_rows($result))
{
$obj = $db->fetch_object($result);
$societe = new Societe($db);
$societe->fetch($obj->rowid);
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref // Ref
print '<tr><td width="18%">'.$langs->trans("Ref")."</td>"; print '<tr><td width="18%">'.$langs->trans("Ref")."</td>";
print '<td colspan="2">'.$fichinter->ref.'</td>'; print '<td colspan="2">'.$object->ref.'</td>';
$nbrow=4; $nbrow=4;
print '<td rowspan="'.$nbrow.'" valign="top" width="50%">'; print '<td rowspan="'.$nbrow.'" valign="top" width="50%">';
@ -96,16 +78,16 @@ if ($_GET["id"] > 0) {
/* /*
* Documents * Documents
*/ */
$fichinterref = dol_sanitizeFileName($fichinter->ref); $objectref = dol_sanitizeFileName($object->ref);
$dir_output = $conf->ficheinter->dir_output . "/"; $dir_output = $conf->ficheinter->dir_output . "/";
$filepath = $dir_output . $fichinterref . "/"; $filepath = $dir_output . $objectref . "/";
$file = $filepath . $fichinterref . ".pdf"; $file = $filepath . $objectref . ".pdf";
$filedetail = $filepath . $fichinterref . "-detail.pdf"; $filedetail = $filepath . $objectref . "-detail.pdf";
$relativepath = "${fichinterref}/${fichinterref}.pdf"; $relativepath = "${objectref}/${objectref}.pdf";
$relativepathdetail = "${fichinterref}/${fichinterref}-detail.pdf"; $relativepathdetail = "${objectref}/${objectref}-detail.pdf";
// Chemin vers png apercus // Chemin vers png apercus
$relativepathimage = "${fichinterref}/${fichinterref}.pdf.png"; $relativepathimage = "${objectref}/${objectref}.pdf.png";
$fileimage = $file.".png"; // Si PDF d'1 page $fileimage = $file.".png"; // Si PDF d'1 page
$fileimagebis = $file.".png.0"; // Si PDF de plus d'1 page $fileimagebis = $file.".png.0"; // Si PDF de plus d'1 page
@ -120,16 +102,17 @@ if ($_GET["id"] > 0) {
print "<tr $bc[$var]><td>".$langs->trans("Intervention")." PDF</td>"; print "<tr $bc[$var]><td>".$langs->trans("Intervention")." PDF</td>";
print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=ficheinter&file='.urlencode($relativepath).'">'.$fichinter->ref.'.pdf</a></td>'; print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=ficheinter&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_size(dol_filesize($file)).'</td>';
print '<td align="right">'.dol_print_date(dol_filemtime($file),'dayhour').'</td>'; print '<td align="right">'.dol_print_date(dol_filemtime($file),'dayhour').'</td>';
print '</tr>'; print '</tr>';
// Si fichier detail PDF existe // Si fichier detail PDF existe
if (file_exists($filedetail)) { // fichinter d<>taill<6C>e suppl<70>mentaire if (file_exists($filedetail))
print "<tr $bc[$var]><td>Fiche d'intervention d<>taill<6C>e</td>"; {
print "<tr $bc[$var]><td>Fiche d'intervention detaillee</td>";
print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=ficheinter&file='.urlencode($relativepathdetail).'">'.$fichinter->ref.'-detail.pdf</a></td>'; print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=ficheinter&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_size(dol_filesize($filedetail)).'</td>';
print '<td align="right">'.dol_print_date(dol_filemtime($filedetail),'dayhour').'</td>'; print '<td align="right">'.dol_print_date(dol_filemtime($filedetail),'dayhour').'</td>';
print '</tr>'; print '</tr>';
@ -141,23 +124,11 @@ if ($_GET["id"] > 0) {
{ {
if (class_exists("Imagick")) if (class_exists("Imagick"))
{ {
$handle = imagick_readimage( $file ) ; $ret = dol_convert_file($file);
if ( imagick_iserror( $handle ) ) if ($ret < 0) $error++;
{
$reason = imagick_failedreason( $handle ) ;
$description = imagick_faileddescription( $handle ) ;
print "handle failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n";
} }
imagick_convert( $handle, "PNG" ) ; else
if ( imagick_iserror( $handle ) )
{ {
$reason = imagick_failedreason( $handle ) ;
$description = imagick_faileddescription( $handle ) ;
print "handle failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n";
}
imagick_writeimages( $handle, $file .".png");
} else {
$langs->load("other"); $langs->load("other");
print '<font class="error">'.$langs->trans("ErrorNoImagickReadimage").'</font>'; print '<font class="error">'.$langs->trans("ErrorNoImagickReadimage").'</font>';
} }
@ -166,41 +137,38 @@ if ($_GET["id"] > 0) {
print "</td></tr>"; print "</td></tr>";
// Client // Client
print "<tr><td>".$langs->trans("Customer")."</td>"; print "<tr><td>".$langs->trans("Customer")."</td>";
print '<td colspan="2">'; print '<td colspan="2">';
print '<a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$societe->id.'">'.$societe->nom.'</a>'; print '<a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a>';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Statut // Statut
print '<tr><td>'.$langs->trans("Status").'</td>'; print '<tr><td>'.$langs->trans("Status").'</td>';
print "<td colspan=\"2\">".$fichinter->getLibStatut(4)."</td>\n"; print "<td colspan=\"2\">".$object->getLibStatut(4)."</td>\n";
print '</tr>'; print '</tr>';
// Date // Date
print '<tr><td>'.$langs->trans("Date").'</td>'; print '<tr><td>'.$langs->trans("Date").'</td>';
print "<td colspan=\"2\">".dol_print_date($fichinter->date,"daytext")."</td>\n"; print "<td colspan=\"2\">".dol_print_date($object->date,"daytext")."</td>\n";
print '</tr>'; print '</tr>';
print '</table>'; print '</table>';
} }
} else { else
dol_print_error($db); {
} // Object not found
} else { print $langs->trans("ErrorFichinterNotFound",$id);
// Intervention non trouv<75>e
print $langs->trans("ErrorFichinterNotFound",$_GET["id"]);
} }
} }
// Si fichier png PDF d'1 page trouv<EFBFBD> // Si fichier png PDF d'1 page trouve
if (file_exists($fileimage)) if (file_exists($fileimage))
{ {
print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercufichinter&file='.urlencode($relativepathimage).'">'; print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercufichinter&file='.urlencode($relativepathimage).'">';
} }
// Si fichier png PDF de plus d'1 page trouv<EFBFBD> // Si fichier png PDF de plus d'1 page trouve
elseif (file_exists($fileimagebis)) elseif (file_exists($fileimagebis))
{ {
$multiple = $relativepathimage . "."; $multiple = $relativepathimage . ".";
@ -216,10 +184,8 @@ elseif (file_exists($fileimagebis))
} }
} }
print '</div>'; print '</div>';
$db->close(); $db->close();
llxFooter('$Date$ - $Revision$'); llxFooter('$Date$ - $Revision$');