dolibarr/htdocs/compta/prelevement/bon.php

105 lines
3.2 KiB
PHP
Raw Normal View History

2012-08-22 23:27:53 +02:00
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
2012-02-29 18:56:54 +01:00
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
2005-03-11 17:40:17 +01:00
*
* 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
2005-03-11 17:40:17 +01:00
* (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
2011-08-01 00:21:57 +02:00
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2005-03-11 17:40:17 +01:00
*/
2010-03-16 00:54:37 +01:00
2005-03-11 17:40:17 +01:00
/**
2010-04-29 10:38:58 +02:00
* \file htdocs/compta/prelevement/bon.php
* \ingroup prelevement
* \brief Fiche apercu du bon de prelevement
*/
2005-03-11 17:40:17 +01:00
require('../../main.inc.php');
require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
2013-06-05 16:24:32 +02:00
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$langs->load("banks");
$langs->load("categories");
2005-03-11 17:40:17 +01:00
$langs->load("bills");
2010-07-27 00:03:50 +02:00
$langs->load("categories");
// Security check
$socid=0;
2012-02-27 22:26:22 +01:00
$id = GETPOST('id','int');
2012-02-29 18:56:54 +01:00
$ref = GETPOST('ref','alpha');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'prelevement', $id);
2005-04-05 16:45:06 +02:00
2005-03-11 17:40:17 +01:00
2010-04-29 10:38:58 +02:00
llxHeader('','Bon de prelevement');
2005-03-11 17:40:17 +01:00
$form = new Form($db);
2005-03-11 17:40:17 +01:00
if ($id > 0 || ! empty($ref))
2005-03-11 17:40:17 +01:00
{
$object = new BonPrelevement($db,"");
2005-03-11 17:40:17 +01:00
if ($object->fetch($id) == 0)
2005-03-11 17:40:17 +01:00
{
2012-08-05 14:37:45 +02:00
$head = prelevement_prepare_head($object);
dol_fiche_head($head, 'preview', 'Prelevement : '. $object->ref);
2005-03-11 17:40:17 +01:00
2010-11-18 18:10:31 +01:00
print '<table class="border" width="100%">';
2005-03-11 17:40:17 +01:00
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>';
2010-11-18 18:10:31 +01:00
print '<tr><td width="20%">'.$langs->trans("File").'</td><td>';
2005-03-11 17:40:17 +01:00
$relativepath = 'bon/'.$object->ref;
2005-03-11 17:40:17 +01:00
2013-04-20 20:30:18 +02:00
print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$object->ref.'</a>';
2005-03-11 17:40:17 +01:00
2010-11-18 18:10:31 +01:00
print '</td></tr>';
print '</table><br>';
2005-03-11 17:40:17 +01:00
$fileimage = $conf->prelevement->dir_output.'/receipts/'.$object->ref.'.ps.png.0';
$fileps = $conf->prelevement->dir_output.'/receipts/'.$object->ref.'.ps';
2005-03-11 17:40:17 +01:00
2010-11-18 18:10:31 +01:00
// Conversion du PDF en image png si fichier png non existant
if (!file_exists($fileimage))
2005-03-11 17:40:17 +01:00
{
if (class_exists("Imagick"))
2010-11-18 18:10:31 +01:00
{
$ret = dol_convert_file($file);
if ($ret < 0) $error++;
2010-11-18 18:10:31 +01:00
}
else
{
$langs->load("errors");
print '<font class="error">'.$langs->trans("ErrorNoImagickReadimage").'</font>';
2010-11-18 18:10:31 +01:00
}
2005-03-11 17:40:17 +01:00
}
2010-03-16 00:54:37 +01:00
2010-11-18 18:10:31 +01:00
if (file_exists($fileimage))
2005-03-11 17:40:17 +01:00
{
2010-11-18 18:10:31 +01:00
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=prelevement&file='.urlencode(basename($fileimage)).'">';
2010-03-16 00:54:37 +01:00
2005-03-11 17:40:17 +01:00
}
}
2010-11-18 18:10:31 +01:00
else
{
dol_print_error($db);
2005-03-11 17:40:17 +01:00
}
}
print "</div>";
llxFooter();
2005-03-11 17:40:17 +01:00
?>