Fix: reencoding preview tabs, Imagick is a class today
Fix: uniformize code
This commit is contained in:
parent
a6e61492bc
commit
11a3b7f6eb
@ -36,9 +36,10 @@ $langs->load('propal');
|
||||
$langs->load("bills");
|
||||
$langs->load('compta');
|
||||
|
||||
$id = isset($_GET["id"])?$_GET["id"]:'';
|
||||
|
||||
// Security check
|
||||
$socid=0;
|
||||
$id = GETPOST("id");
|
||||
$ref = GETPOST("ref");
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$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);
|
||||
|
||||
@ -118,16 +119,16 @@ if ($_GET["id"] > 0)
|
||||
/*
|
||||
* Documents
|
||||
*/
|
||||
$propalref = dol_sanitizeFileName($object->ref);
|
||||
$objectref = dol_sanitizeFileName($object->ref);
|
||||
$dir_output = $conf->propale->dir_output . "/";
|
||||
$filepath = $dir_output . $propalref . "/";
|
||||
$file = $filepath . $propalref . ".pdf";
|
||||
$filedetail = $filepath . $propalref . "-detail.pdf";
|
||||
$relativepath = "${propalref}/${propalref}.pdf";
|
||||
$relativepathdetail = "${propalref}/${propalref}-detail.pdf";
|
||||
$filepath = $dir_output . $objectref . "/";
|
||||
$file = $filepath . $objectref . ".pdf";
|
||||
$filedetail = $filepath . $objectref . "-detail.pdf";
|
||||
$relativepath = "${objectref}/${objectref}.pdf";
|
||||
$relativepathdetail = "${objectref}/${objectref}-detail.pdf";
|
||||
|
||||
// Chemin vers png apercus
|
||||
$relativepathimage = "${propalref}/${propalref}.pdf.png";
|
||||
$relativepathimage = "${objectref}/${objectref}.pdf.png";
|
||||
$fileimage = $file.".png"; // Si PDF d'1 page
|
||||
$fileimagebis = $file.".png.0"; // Si PDF de plus d'1 page
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,20 +20,19 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/commande/apercu.php
|
||||
\ingroup commande
|
||||
\brief Page de l'onglet apercu d'une commande
|
||||
\version $Id$
|
||||
*/
|
||||
* \file htdocs/commande/apercu.php
|
||||
* \ingroup commande
|
||||
* \brief Page de l'onglet apercu d'une commande
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
require("../main.inc.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');
|
||||
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 (!$user->rights->commande->lire) accessforbidden();
|
||||
|
||||
$langs->load('orders');
|
||||
$langs->load('propal');
|
||||
$langs->load("bills");
|
||||
@ -42,10 +41,10 @@ $langs->load('sendings');
|
||||
|
||||
// Security check
|
||||
$socid=0;
|
||||
$comid = isset($_GET["id"])?$_GET["id"]:'';
|
||||
$id = GETPOST("id");
|
||||
$ref = GETPOST("ref");
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$result=restrictedArea($user,'commande',$comid,'');
|
||||
|
||||
$result=restrictedArea($user,'commande',$id,'');
|
||||
|
||||
|
||||
/*
|
||||
@ -62,208 +61,170 @@ $html = new Form($db);
|
||||
/* */
|
||||
/* *************************************************************************** */
|
||||
|
||||
if ($_GET["id"] > 0) {
|
||||
$commande = new Commande($db);
|
||||
if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$object = new Commande($db);
|
||||
|
||||
if ( $commande->fetch($_GET["id"], $user->societe_id) > 0)
|
||||
{
|
||||
$soc = new Societe($db, $commande->socid);
|
||||
$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');
|
||||
|
||||
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>";
|
||||
|
||||
// Ref cde client
|
||||
print '<tr><td>';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td 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">';
|
||||
|
||||
/*
|
||||
* Commande
|
||||
* Documents
|
||||
*/
|
||||
$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;
|
||||
$objectref = dol_sanitizeFileName($object->ref);
|
||||
$dir_output = $conf->commande->dir_output . "/";
|
||||
$filepath = $dir_output . $objectref . "/";
|
||||
$file = $filepath . $objectref . ".pdf";
|
||||
$filedetail = $filepath . $objectref . "-detail.pdf";
|
||||
$relativepath = "${objectref}/${objectref}.pdf";
|
||||
$relativepathdetail = "${objectref}/${objectref}-detail.pdf";
|
||||
|
||||
$result = $db->query($sql);
|
||||
// Chemin vers png apercus
|
||||
$relativepathimage = "${objectref}/${objectref}.pdf.png";
|
||||
$fileimage = $file.".png"; // Si PDF d'1 page
|
||||
$fileimagebis = $file.".png.0"; // Si PDF de plus d'1 page
|
||||
|
||||
if ($result)
|
||||
$var=true;
|
||||
|
||||
// Si fichier PDF existe
|
||||
if (file_exists($file))
|
||||
{
|
||||
if ($db->num_rows($result))
|
||||
$encfile = urlencode($file);
|
||||
print_titre($langs->trans("Documents"));
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print "<tr $bc[$var]><td>".$langs->trans("Order")." PDF</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_date(dol_filemtime($file),'dayhour').'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Si fichier detail PDF existe
|
||||
// TODO obsolete ?
|
||||
if (file_exists($filedetail))
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
print "<tr $bc[$var]><td>Commande detaillee</td>";
|
||||
|
||||
$societe = new Societe($db);
|
||||
$societe->fetch($obj->rowid);
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="18%">'.$langs->trans("Ref")."</td>";
|
||||
print '<td colspan="2">'.$commande->ref.'</td>';
|
||||
print '<td width="50%">'.$langs->trans("Source").' : '.$commande->getLabelSource();
|
||||
if ($commande->source == 0)
|
||||
{
|
||||
// Propale
|
||||
$propal = new Propal($db);
|
||||
$propal->fetch($commande->propale_id);
|
||||
print ' -> <a href="'.DOL_URL_ROOT.'/comm/propal.php?id='.$propal->id.'">'.$propal->ref.'</a>';
|
||||
}
|
||||
print "</td></tr>";
|
||||
|
||||
// Ref cde client
|
||||
print '<tr><td>';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
|
||||
print $langs->trans('RefCustomer').'</td><td align="left">';
|
||||
print '</td>';
|
||||
print '</tr></table>';
|
||||
print '</td>';
|
||||
print '<td colspan="2">';
|
||||
print $commande->ref_client;
|
||||
print '</td>';
|
||||
$nbrow=6;
|
||||
print '<td rowspan="'.$nbrow.'" valign="top">';
|
||||
|
||||
/*
|
||||
* Documents
|
||||
*/
|
||||
$commanderef = dol_sanitizeFileName($commande->ref);
|
||||
$dir_output = $conf->commande->dir_output . "/";
|
||||
$filepath = $dir_output . $commanderef . "/";
|
||||
$file = $filepath . $commanderef . ".pdf";
|
||||
$filedetail = $filepath . $commanderef . "-detail.pdf";
|
||||
$relativepath = "${commanderef}/${commanderef}.pdf";
|
||||
$relativepathdetail = "${commanderef}/${commanderef}-detail.pdf";
|
||||
|
||||
// Chemin vers png aper<65>us
|
||||
$relativepathimage = "${commanderef}/${commanderef}.pdf.png";
|
||||
$fileimage = $file.".png"; // Si PDF d'1 page
|
||||
$fileimagebis = $file.".png.0"; // Si PDF de plus d'1 page
|
||||
|
||||
$var=true;
|
||||
|
||||
// Si fichier PDF existe
|
||||
if (file_exists($file))
|
||||
{
|
||||
$encfile = urlencode($file);
|
||||
print_titre($langs->trans("Documents"));
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
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 align="right">'.dol_print_size(dol_filesize($file)).'</td>';
|
||||
print '<td align="right">'.dol_print_date(dol_filemtime($file),'dayhour').'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Si fichier detail PDF existe
|
||||
if (file_exists($filedetail)) { // commande d<>taill<6C>e suppl<70>mentaire
|
||||
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 align="right">'.dol_print_size(dol_filesize($filedetail)).'</td>';
|
||||
print '<td align="right">'.dol_print_date(dol_filemtime($filedetail),'dayhour').'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
print "</table>\n";
|
||||
|
||||
// Conversion du PDF en image png si fichier png non existant
|
||||
if (! file_exists($fileimage) && ! file_exists($fileimagebis))
|
||||
{
|
||||
if (class_exists("Imagick"))
|
||||
{
|
||||
$handle = imagick_readimage( $file ) ;
|
||||
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_writeimages( $handle, $file .".png");
|
||||
} else {
|
||||
$langs->load("other");
|
||||
print '<font class="error">'.$langs->trans("ErrorNoImagickReadimage").'</font>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print "</td></tr>";
|
||||
|
||||
|
||||
// Client
|
||||
print "<tr><td>".$langs->trans("Customer")."</td>";
|
||||
print '<td colspan="2">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$societe->id.'">'.$societe->nom.'</a>';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans("Status").'</td>';
|
||||
print "<td colspan=\"2\">".$commande->getLibStatut(4)."</td>\n";
|
||||
print '</tr>';
|
||||
|
||||
// Date
|
||||
print '<tr><td>'.$langs->trans("Date").'</td>';
|
||||
print "<td colspan=\"2\">".dol_print_date($commande->date,"daytext")."</td>\n";
|
||||
print '</tr>';
|
||||
|
||||
// ligne 6
|
||||
// partie Gauche
|
||||
print '<tr><td height="10" nowrap>'.$langs->trans('GlobalDiscount').'</td>';
|
||||
print '<td colspan="2">'.$commande->remise_percent.'%</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_date(dol_filemtime($filedetail),'dayhour').'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// ligne 7
|
||||
// partie Gauche
|
||||
print '<tr><td height="10">'.$langs->trans('AmountHT').'</td>';
|
||||
print '<td align="right" colspan="1"><b>'.price($commande->total_ht).'</b></td>';
|
||||
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
|
||||
print '</table>';
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
print "</table>\n";
|
||||
|
||||
// Conversion du PDF en image png si fichier png non existant
|
||||
if (! file_exists($fileimage) && ! file_exists($fileimagebis))
|
||||
{
|
||||
if (class_exists("Imagick"))
|
||||
{
|
||||
$ret = dol_convert_file($file);
|
||||
if ($ret < 0) $error++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("other");
|
||||
print '<font class="error">'.$langs->trans("ErrorNoImagickReadimage").'</font>';
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Commande non trouv<75>e
|
||||
print $langs->trans("ErrorPropalNotFound",$_GET["id"]);
|
||||
|
||||
print "</td></tr>";
|
||||
|
||||
// Client
|
||||
print "<tr><td>".$langs->trans("Customer")."</td>";
|
||||
print '<td colspan="2">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a>';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans("Status").'</td>';
|
||||
print "<td colspan=\"2\">".$object->getLibStatut(4)."</td>\n";
|
||||
print '</tr>';
|
||||
|
||||
// Date
|
||||
print '<tr><td>'.$langs->trans("Date").'</td>';
|
||||
print "<td colspan=\"2\">".dol_print_date($object->date,"daytext")."</td>\n";
|
||||
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->monnaie).'</td></tr>';
|
||||
print '</table>';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Object not found
|
||||
print $langs->trans("ErrorOrderNotFound",$id);
|
||||
}
|
||||
}
|
||||
|
||||
// Si fichier png PDF d'1 page trouv<75>
|
||||
// Si fichier png PDF d'1 page trouve
|
||||
if (file_exists($fileimage))
|
||||
{
|
||||
{
|
||||
print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercucommande&file='.urlencode($relativepathimage).'">';
|
||||
}
|
||||
// Si fichier png PDF de plus d'1 page trouv<75>
|
||||
}
|
||||
// Si fichier png PDF de plus d'1 page trouve
|
||||
elseif (file_exists($fileimagebis))
|
||||
{
|
||||
$multiple = $relativepathimage . ".";
|
||||
|
||||
for ($i = 0; $i < 20; $i++)
|
||||
{
|
||||
$multiple = $relativepathimage . ".";
|
||||
|
||||
for ($i = 0; $i < 20; $i++)
|
||||
$preview = $multiple.$i;
|
||||
|
||||
if (file_exists($dir_output.$preview))
|
||||
{
|
||||
$preview = $multiple.$i;
|
||||
|
||||
if (file_exists($dir_output.$preview))
|
||||
{
|
||||
print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercucommande&file='.urlencode($preview).'"><p>';
|
||||
}
|
||||
print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercucommande&file='.urlencode($preview).'"><p>';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
/* 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) 2005-2011 Regis Houssin <regis@dolibarr.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
|
||||
@ -21,38 +22,33 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/compta/facture/apercu.php
|
||||
\ingroup facture
|
||||
\brief Page de l'onglet apercu d'une facture
|
||||
\version $Revision$
|
||||
*/
|
||||
* \file htdocs/compta/facture/apercu.php
|
||||
* \ingroup facture
|
||||
* \brief Page de l'onglet apercu d'une facture
|
||||
* \version $Revision$
|
||||
*/
|
||||
|
||||
require("../../main.inc.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/files.lib.php");
|
||||
if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php");
|
||||
|
||||
|
||||
if (!$user->rights->facture->lire)
|
||||
accessforbidden();
|
||||
|
||||
$langs->load("bills");
|
||||
|
||||
|
||||
// S<>curit<69> acc<63>s client
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
// Security check
|
||||
$socid=0;
|
||||
$id = GETPOST("id");
|
||||
$ref = GETPOST("ref");
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$result = restrictedArea($user, 'facture', $id);
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$now=gmmktime();
|
||||
$now=dol_now();
|
||||
|
||||
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);
|
||||
if ( $fac->fetch($_GET["facid"], $user->societe_id) > 0)
|
||||
$object = New Facture($db);
|
||||
|
||||
if ($object->fetch($id,$ref) > 0)
|
||||
{
|
||||
$soc = new Societe($db, $fac->socid);
|
||||
$soc->fetch($fac->socid);
|
||||
$soc = new Societe($db, $object->socid);
|
||||
$soc->fetch($object->socid);
|
||||
|
||||
$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');
|
||||
|
||||
|
||||
@ -88,7 +86,7 @@ if ($_GET["facid"] > 0)
|
||||
$rowspan=3;
|
||||
|
||||
// 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
|
||||
print '<tr><td>'.$langs->trans("Company").'</td>';
|
||||
@ -97,58 +95,43 @@ if ($_GET["facid"] > 0)
|
||||
|
||||
// Dates
|
||||
print '<tr><td>'.$langs->trans("Date").'</td>';
|
||||
print '<td colspan="3">'.dol_print_date($fac->date,"daytext").'</td>';
|
||||
print '<td>'.$langs->trans("DateMaxPayment").'</td><td>' . dol_print_date($fac->date_lim_reglement,"daytext");
|
||||
if ($fac->paye == 0 && $fac->date_lim_reglement < ($now - $conf->facture->client->warning_delay)) print img_warning($langs->trans("Late"));
|
||||
print '<td colspan="3">'.dol_print_date($object->date,"daytext").'</td>';
|
||||
print '<td>'.$langs->trans("DateMaxPayment").'</td><td>' . dol_print_date($object->date_lim_reglement,"daytext");
|
||||
if ($object->paye == 0 && $object->date_lim_reglement < ($now - $conf->facture->client->warning_delay)) print img_warning($langs->trans("Late"));
|
||||
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">';
|
||||
$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 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>';
|
||||
|
||||
// Remise globale
|
||||
print '<tr><td>'.$langs->trans('GlobalDiscount').'</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>';
|
||||
// }
|
||||
print '<td colspan="3">'.$object->remise_percent.'%</td>';
|
||||
|
||||
$nbrows=5;
|
||||
if ($conf->projet->enabled) $nbrows++;
|
||||
print '<td rowspan="'.$nbrows.'" colspan="2" valign="top">';
|
||||
print '<td rowspan="'.$nbrows.'" colspan="2" valign="top">';
|
||||
|
||||
/*
|
||||
* Documents
|
||||
*/
|
||||
$facref = dol_sanitizeFileName($fac->ref);
|
||||
$objectref = dol_sanitizeFileName($object->ref);
|
||||
$dir_output = $conf->facture->dir_output . "/";
|
||||
$filepath = $dir_output . $facref . "/";
|
||||
$file = $filepath . $facref . ".pdf";
|
||||
$filedetail = $filepath . $facref . "-detail.pdf";
|
||||
$relativepath = "${facref}/${facref}.pdf";
|
||||
$relativepathdetail = "${facref}/${facref}-detail.pdf";
|
||||
$filepath = $dir_output . $objectref . "/";
|
||||
$file = $filepath . $objectref . ".pdf";
|
||||
$filedetail = $filepath . $objectref . "-detail.pdf";
|
||||
$relativepath = "${objectref}/${objectref}.pdf";
|
||||
$relativepathdetail = "${objectref}/${objectref}-detail.pdf";
|
||||
|
||||
// Chemin vers png aper<EFBFBD>us
|
||||
$relativepathimage = "${facref}/${facref}.pdf.png";
|
||||
// Chemin vers png apercus
|
||||
$relativepathimage = "${obejctref}/${objectref}.pdf.png";
|
||||
$fileimage = $file.".png"; // Si PDF d'1 page
|
||||
$fileimagebis = $file.".png.0"; // Si PDF de plus d'1 page
|
||||
|
||||
|
||||
$var=true;
|
||||
|
||||
// Si fichier PDF existe
|
||||
@ -160,7 +143,7 @@ if ($_GET["facid"] > 0)
|
||||
|
||||
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_date(dol_filemtime($file),'dayhour').'</td>';
|
||||
print '</tr>';
|
||||
@ -168,9 +151,9 @@ if ($_GET["facid"] > 0)
|
||||
// Si fichier detail PDF existe
|
||||
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_date(dol_filemtime($filedetail),'dayhour').'</td>';
|
||||
print '</tr>';
|
||||
@ -179,35 +162,17 @@ if ($_GET["facid"] > 0)
|
||||
print "</table>\n";
|
||||
|
||||
// Conversion du PDF en image png si fichier png non existant
|
||||
if (! file_exists($fileimage) && ! file_exists($fileimagebis))
|
||||
{
|
||||
if (class_exists("Imagick"))
|
||||
{
|
||||
$handle = imagick_readimage( $file ) ;
|
||||
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_writeimages( $handle, $file .".png");
|
||||
if (! file_exists($fileimage) && ! file_exists($fileimagebis))
|
||||
{
|
||||
if (class_exists("Imagick"))
|
||||
{
|
||||
$ret = dol_convert_file($file);
|
||||
if ($ret < 0) $error++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("other");
|
||||
print '<font class="error">'.$langs->trans("ErrorNoImagickReadimage").'</font>';
|
||||
{
|
||||
$langs->load("other");
|
||||
print '<font class="error">'.$langs->trans("ErrorNoImagickReadimage").'</font>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -215,16 +180,16 @@ if ($_GET["facid"] > 0)
|
||||
print "</td></tr>";
|
||||
|
||||
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 '<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 '<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>';
|
||||
|
||||
// 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
|
||||
if ($conf->projet->enabled)
|
||||
@ -232,11 +197,11 @@ if ($_GET["facid"] > 0)
|
||||
$langs->load("projects");
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("Project").'</td><td colspan="3">';
|
||||
if ($fac->fk_project > 0)
|
||||
if ($object->fk_project > 0)
|
||||
{
|
||||
$project = New Project($db);
|
||||
$project->fetch($fac->fk_project);
|
||||
print '<a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$fac->fk_project.'">'.$project->title.'</a>';
|
||||
$project->fetch($object->fk_project);
|
||||
print '<a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$object->fk_project.'">'.$project->title.'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -250,36 +215,34 @@ if ($_GET["facid"] > 0)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Facture non trouv<EFBFBD>e
|
||||
// Facture non trouvee
|
||||
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))
|
||||
{
|
||||
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))
|
||||
{
|
||||
$multiple = $relativepathimage . ".";
|
||||
|
||||
for ($i = 0; $i < 20; $i++)
|
||||
{
|
||||
$multiple = $relativepathimage . ".";
|
||||
|
||||
for ($i = 0; $i < 20; $i++)
|
||||
$preview = $multiple.$i;
|
||||
|
||||
if (file_exists($dir_output.$preview))
|
||||
{
|
||||
$preview = $multiple.$i;
|
||||
|
||||
if (file_exists($dir_output.$preview))
|
||||
{
|
||||
print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercufacture&file='.urlencode($preview).'"><p>';
|
||||
}
|
||||
print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercufacture&file='.urlencode($preview).'"><p>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
print '</div>';
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
|
||||
@ -27,76 +27,61 @@
|
||||
|
||||
require('../../main.inc.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";
|
||||
|
||||
$langs->load("bills");
|
||||
$langs->load("categories");
|
||||
|
||||
/*
|
||||
* Securite acces client
|
||||
*/
|
||||
if (!$user->rights->prelevement->bons->lire) accessforbidden();
|
||||
// Security check
|
||||
$socid=0;
|
||||
$id = GETPOST("id");
|
||||
$ref = GETPOST("ref");
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$result = restrictedArea($user, 'prelevement', $id);
|
||||
|
||||
|
||||
llxHeader('','Bon de prelevement');
|
||||
|
||||
$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);
|
||||
dol_fiche_head($head, 'preview', 'Prelevement : '. $bon->ref);
|
||||
$head = prelevement_prepare_head($object);
|
||||
dol_fiche_head($head, 'preview', 'Prelevement : '. $object->ref);
|
||||
|
||||
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("Amount").'</td><td>'.price($bon->amount).'</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($object->amount).'</td></tr>';
|
||||
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&modulepart=prelevement&file='.urlencode($relativepath).'">'.$bon->ref.'</a>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/document.php?type=text/plain&modulepart=prelevement&file='.urlencode($relativepath).'">'.$object->ref.'</a>';
|
||||
|
||||
print '</td></tr>';
|
||||
print '</table><br>';
|
||||
|
||||
$fileimage = $conf->prelevement->dir_output.'/receipts/'.$bon->ref.'.ps.png.0';
|
||||
$fileps = $conf->prelevement->dir_output.'/receipts/'.$bon->ref.'.ps';
|
||||
$fileimage = $conf->prelevement->dir_output.'/receipts/'.$object->ref.'.ps.png.0';
|
||||
$fileps = $conf->prelevement->dir_output.'/receipts/'.$object->ref.'.ps';
|
||||
|
||||
// Conversion du PDF en image png si fichier png non existant
|
||||
if (!file_exists($fileimage))
|
||||
{
|
||||
print $fileimage;
|
||||
if (class_exists("Imagick"))
|
||||
{
|
||||
|
||||
$handle = imagick_readimage( $fileps ) ;
|
||||
|
||||
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");
|
||||
$ret = dol_convert_file($file);
|
||||
if ($ret < 0) $error++;
|
||||
}
|
||||
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>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -27,17 +27,19 @@
|
||||
|
||||
require("../main.inc.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');
|
||||
if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php");
|
||||
|
||||
$langs->load('interventions');
|
||||
|
||||
$fichinterid = isset($_GET["id"])?$_GET["id"]:'';
|
||||
|
||||
// Security check
|
||||
$socid=0;
|
||||
$id = GETPOST("id");
|
||||
$ref = GETPOST("ref");
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$result = restrictedArea($user, 'ficheinter', $fichinterid, 'fichinter');
|
||||
|
||||
$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
|
||||
|
||||
llxHeader();
|
||||
|
||||
@ -49,158 +51,124 @@ $html = new Form($db);
|
||||
/* */
|
||||
/* *************************************************************************** */
|
||||
|
||||
if ($_GET["id"] > 0) {
|
||||
$fichinter = new Fichinter($db);
|
||||
if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$object = new Fichinter($db);
|
||||
|
||||
if ( $fichinter->fetch($_GET["id"], $user->societe_id) > 0)
|
||||
if ($object->fetch($id,$ref) > 0)
|
||||
{
|
||||
$soc = new Societe($db, $fichinter->socid);
|
||||
$soc->fetch($fichinter->socid);
|
||||
$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');
|
||||
|
||||
|
||||
/*
|
||||
* 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)
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="18%">'.$langs->trans("Ref")."</td>";
|
||||
print '<td colspan="2">'.$object->ref.'</td>';
|
||||
|
||||
$nbrow=4;
|
||||
print '<td rowspan="'.$nbrow.'" valign="top" width="50%">';
|
||||
|
||||
/*
|
||||
* Documents
|
||||
*/
|
||||
$objectref = dol_sanitizeFileName($object->ref);
|
||||
$dir_output = $conf->ficheinter->dir_output . "/";
|
||||
$filepath = $dir_output . $objectref . "/";
|
||||
$file = $filepath . $objectref . ".pdf";
|
||||
$filedetail = $filepath . $objectref . "-detail.pdf";
|
||||
$relativepath = "${objectref}/${objectref}.pdf";
|
||||
$relativepathdetail = "${objectref}/${objectref}-detail.pdf";
|
||||
|
||||
// Chemin vers png apercus
|
||||
$relativepathimage = "${objectref}/${objectref}.pdf.png";
|
||||
$fileimage = $file.".png"; // Si PDF d'1 page
|
||||
$fileimagebis = $file.".png.0"; // Si PDF de plus d'1 page
|
||||
|
||||
$var=true;
|
||||
|
||||
// Si fichier PDF existe
|
||||
if (file_exists($file))
|
||||
{
|
||||
if ($db->num_rows($result))
|
||||
$encfile = urlencode($file);
|
||||
print_titre($langs->trans("Documents"));
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print "<tr $bc[$var]><td>".$langs->trans("Intervention")." PDF</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_date(dol_filemtime($file),'dayhour').'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Si fichier detail PDF existe
|
||||
if (file_exists($filedetail))
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
$societe = new Societe($db);
|
||||
$societe->fetch($obj->rowid);
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="18%">'.$langs->trans("Ref")."</td>";
|
||||
print '<td colspan="2">'.$fichinter->ref.'</td>';
|
||||
|
||||
$nbrow=4;
|
||||
print '<td rowspan="'.$nbrow.'" valign="top" width="50%">';
|
||||
|
||||
/*
|
||||
* Documents
|
||||
*/
|
||||
$fichinterref = dol_sanitizeFileName($fichinter->ref);
|
||||
$dir_output = $conf->ficheinter->dir_output . "/";
|
||||
$filepath = $dir_output . $fichinterref . "/";
|
||||
$file = $filepath . $fichinterref . ".pdf";
|
||||
$filedetail = $filepath . $fichinterref . "-detail.pdf";
|
||||
$relativepath = "${fichinterref}/${fichinterref}.pdf";
|
||||
$relativepathdetail = "${fichinterref}/${fichinterref}-detail.pdf";
|
||||
|
||||
// Chemin vers png apercus
|
||||
$relativepathimage = "${fichinterref}/${fichinterref}.pdf.png";
|
||||
$fileimage = $file.".png"; // Si PDF d'1 page
|
||||
$fileimagebis = $file.".png.0"; // Si PDF de plus d'1 page
|
||||
|
||||
$var=true;
|
||||
|
||||
// Si fichier PDF existe
|
||||
if (file_exists($file))
|
||||
{
|
||||
$encfile = urlencode($file);
|
||||
print_titre($langs->trans("Documents"));
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
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 align="right">'.dol_print_size(dol_filesize($file)).'</td>';
|
||||
print '<td align="right">'.dol_print_date(dol_filemtime($file),'dayhour').'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Si fichier detail PDF existe
|
||||
if (file_exists($filedetail)) { // fichinter d<>taill<6C>e suppl<70>mentaire
|
||||
print "<tr $bc[$var]><td>Fiche d'intervention d<>taill<6C>e</td>";
|
||||
|
||||
print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=ficheinter&file='.urlencode($relativepathdetail).'">'.$fichinter->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>';
|
||||
}
|
||||
print "</table>\n";
|
||||
|
||||
// Conversion du PDF en image png si fichier png non existant
|
||||
if (! file_exists($fileimage) && ! file_exists($fileimagebis))
|
||||
{
|
||||
if (class_exists("Imagick"))
|
||||
{
|
||||
$handle = imagick_readimage( $file ) ;
|
||||
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_writeimages( $handle, $file .".png");
|
||||
} else {
|
||||
$langs->load("other");
|
||||
print '<font class="error">'.$langs->trans("ErrorNoImagickReadimage").'</font>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print "</td></tr>";
|
||||
|
||||
|
||||
// Client
|
||||
print "<tr><td>".$langs->trans("Customer")."</td>";
|
||||
print '<td colspan="2">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$societe->id.'">'.$societe->nom.'</a>';
|
||||
print '</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).'">'.$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>';
|
||||
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans("Status").'</td>';
|
||||
print "<td colspan=\"2\">".$fichinter->getLibStatut(4)."</td>\n";
|
||||
print '</tr>';
|
||||
|
||||
// Date
|
||||
print '<tr><td>'.$langs->trans("Date").'</td>';
|
||||
print "<td colspan=\"2\">".dol_print_date($fichinter->date,"daytext")."</td>\n";
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
print "</table>\n";
|
||||
|
||||
// Conversion du PDF en image png si fichier png non existant
|
||||
if (! file_exists($fileimage) && ! file_exists($fileimagebis))
|
||||
{
|
||||
if (class_exists("Imagick"))
|
||||
{
|
||||
$ret = dol_convert_file($file);
|
||||
if ($ret < 0) $error++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("other");
|
||||
print '<font class="error">'.$langs->trans("ErrorNoImagickReadimage").'</font>';
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Intervention non trouv<75>e
|
||||
print $langs->trans("ErrorFichinterNotFound",$_GET["id"]);
|
||||
|
||||
print "</td></tr>";
|
||||
|
||||
// Client
|
||||
print "<tr><td>".$langs->trans("Customer")."</td>";
|
||||
print '<td colspan="2">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a>';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans("Status").'</td>';
|
||||
print "<td colspan=\"2\">".$object->getLibStatut(4)."</td>\n";
|
||||
print '</tr>';
|
||||
|
||||
// Date
|
||||
print '<tr><td>'.$langs->trans("Date").'</td>';
|
||||
print "<td colspan=\"2\">".dol_print_date($object->date,"daytext")."</td>\n";
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Object not found
|
||||
print $langs->trans("ErrorFichinterNotFound",$id);
|
||||
}
|
||||
}
|
||||
|
||||
// Si fichier png PDF d'1 page trouv<75>
|
||||
// Si fichier png PDF d'1 page trouve
|
||||
if (file_exists($fileimage))
|
||||
{
|
||||
print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercufichinter&file='.urlencode($relativepathimage).'">';
|
||||
}
|
||||
// Si fichier png PDF de plus d'1 page trouv<75>
|
||||
// Si fichier png PDF de plus d'1 page trouve
|
||||
elseif (file_exists($fileimagebis))
|
||||
{
|
||||
$multiple = $relativepathimage . ".";
|
||||
@ -216,10 +184,8 @@ elseif (file_exists($fileimagebis))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
print '</div>';
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user