* Copyright (C) 2004 Eric Seigne * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2014 Frederic France * * 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 * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/comm/propal/apercu.php * \ingroup propal * \brief Preview tab of propal */ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $langs->load('propal'); $langs->load("bills"); $langs->load('compta'); // Security check $socid=0; $id = GETPOST('id','int'); $ref = GETPOST("ref"); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'propal', $id); /* * View Mode */ llxHeader(); if ($id > 0 || ! empty($ref)) { $object = new Propal($db); if ($object->fetch($id,$ref) > 0) { $soc = new Societe($db); $soc->fetch($object->socid); $head = propal_prepare_head($object); dol_fiche_head($head, 'preview', $langs->trans('Proposal'), 0, 'propal'); /* * Propal */ print ''; // Ref print ''; print ''; print ''; // Ref client print ''; print ''; print ''; // Thirdparty print ''; print ''; print ''; // Status print ''; print ''; print ''; // Discount print ''; print ''; // Date print ''; print ''; // Right part with $rowspan lines $rowspan=4; print ''; print ''; // Total HT - left part print ''; print ''; print ''; // Total VAT - left part print ''; print ''; print ''; // Total TTC - left part print ''; print ''; print ''; print '
'.$langs->trans('Ref').''.$object->ref.'
'.$langs->trans('RefCustomer').''.$object->ref_client.'
'.$langs->trans('Company').''.$soc->getNomUrl(1).'
'.$langs->trans("Status").''.$object->getLibStatut(4).'
'.$langs->trans('Discounts').''; if ($soc->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_percent); else print $langs->trans("CompanyHasNoRelativeDiscount"); $absolute_discount=$soc->getAvailableDiscounts(); print '. '; if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->currency)); else print $langs->trans("CompanyHasNoAbsoluteDiscount"); print '.
'.$langs->trans('Date').''.dol_print_date($object->date,'daytext').''; /* * Documents */ $objectref = dol_sanitizeFileName($object->ref); $dir_output = $conf->propal->dir_output . "/"; $filepath = $dir_output . $objectref . "/"; $file = $filepath . $objectref . ".pdf"; $filedetail = $filepath . $objectref . "-detail.pdf"; $relativepath = $objectref.'/'.$objectref.'.pdf'; $relativepathdetail = $objectref.'/'.$objectref.'-detail.pdf'; // Define path to preview pdf file (preview precompiled "file.ext" are "file.ext_preview.png") $fileimage = $file.'_preview.png'; // If PDF has 1 page $fileimagebis = $file.'_preview-0.pdf.png'; // If PDF has more than one page $relativepathimage = $relativepath.'_preview.png'; $var=true; // Si fichier PDF existe if (file_exists($file)) { $encfile = urlencode($file); print ''; print ''; print ''; print ''; print ''; print ''; print ''; print "
'.$langs->trans("Documents").'
'.$langs->trans("Proposal").' PDF'.$object->ref.'.pdf'.dol_print_size(dol_filesize($file)).''.dol_print_date(dol_filemtime($file),'dayhour').'
\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,'png',$fileimage); if ($ret < 0) $error++; } else { $langs->load("errors"); print ''.$langs->trans("ErrorNoImagickReadimage").''; } } } print '
'.$langs->trans('AmountHT').'' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . '
'.$langs->trans('AmountVAT').'' . price($object->total_tva, '', $langs, 0, - 1, - 1, $conf->currency) . '
'.$langs->trans('AmountTTC').'' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . '
'; dol_fiche_end(); } else { // Propal non trouvee print $langs->trans("ErrorPropalNotFound",$_GET["id"]); } } print ''; print ''; print '
'; print '
'; // Si fichier png PDF d'1 page trouve if (file_exists($fileimage)) { print ''; } // Si fichier png PDF de plus d'1 page trouve elseif (file_exists($fileimagebis)) { $multiple = preg_replace('/\.png/','',$relativepath) . "-"; for ($i = 0; $i < 20; $i++) { $preview = $multiple.$i.'.png'; if (file_exists($dir_output.$preview)) { print '

'; } } } print '

'; print '
'; llxFooter(); $db->close();