From 7f6ab748c5d040475d5aa0953822f7fd1ef2e585 Mon Sep 17 00:00:00 2001 From: arnaud Date: Fri, 3 Feb 2017 16:42:06 +0100 Subject: [PATCH] NEW add rapport file for supplier paiement --- .../rapport/pdf_paiement_fourn.class.php | 6 +- htdocs/fourn/facture/rapport.php | 171 ++++++++++++++++++ 2 files changed, 173 insertions(+), 4 deletions(-) create mode 100644 htdocs/fourn/facture/rapport.php diff --git a/htdocs/core/modules/rapport/pdf_paiement_fourn.class.php b/htdocs/core/modules/rapport/pdf_paiement_fourn.class.php index 4b4549d4b50..68b444b8e51 100644 --- a/htdocs/core/modules/rapport/pdf_paiement_fourn.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement_fourn.class.php @@ -1,7 +1,5 @@ - * Copyright (C) 2006-2014 Laurent Destailleur - * Copyright (C) 2015 Charles-Fr BENKE +/* Copyright (C) 2017 ATM-Consulting * * 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 @@ -19,7 +17,7 @@ */ /** - * \file htdocs/core/modules/rapport/pdf_paiement.class.php + * \file htdocs/core/modules/rapport/pdf_paiement_fourn.class.php * \ingroup banque * \brief File to build payment reports */ diff --git a/htdocs/fourn/facture/rapport.php b/htdocs/fourn/facture/rapport.php new file mode 100644 index 00000000000..e685421af19 --- /dev/null +++ b/htdocs/fourn/facture/rapport.php @@ -0,0 +1,171 @@ + + * + * 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/fourn/facture/rapport.php + * \ingroup fourn + * \brief Payment reports page + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/rapport/pdf_paiement_fourn.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + +// Security check +$socid=''; +if (! empty($user->societe_id)) $socid=$user->societe_id; +$result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture'); + +$action=GETPOST('action'); + +$socid=0; +if ($user->societe_id > 0) +{ + $action = ''; + $socid = $user->societe_id; +} + +$dir = $conf->fournisseur->facture->dir_output.'/payments'; +if (! $user->rights->societe->client->voir || $socid) $dir.='/private/'.$user->id; // If user has no permission to see all, output dir is specific to user + +$year = $_GET["year"]; +if (! $year) { $year=date("Y"); } + + +/* + * Actions + */ + +if ($action == 'builddoc') +{ + $rap = new pdf_paiement_fourn($db); + + $outputlangs = $langs; + if (GETPOST('lang_id')) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang(GETPOST('lang_id')); + } + + // We save charset_output to restore it because write_file can change it if needed for + // output format that does not support UTF8. + $sav_charset_output=$outputlangs->charset_output; + if ($rap->write_file($dir, $_POST["remonth"], $_POST["reyear"], $outputlangs) > 0) + { + $outputlangs->charset_output=$sav_charset_output; + } + else + { + $outputlangs->charset_output=$sav_charset_output; + dol_print_error($db,$obj->error); + } + + $year = $_POST["reyear"]; +} + + +/* + * View + */ + +$formother=new FormOther($db); + +llxHeader(); + +$titre=($year?$langs->trans("PaymentsReportsForYear",$year):$langs->trans("PaymentsReports")); +print load_fiche_titre($titre,'','title_accountancy.png'); + +// Formulaire de generation +print '
'; +print ''; +print ''; +$cmonth = GETPOST("remonth")?GETPOST("remonth"):date("n", time()); +$syear = GETPOST("reyear")?GETPOST("reyear"):date("Y", time()); + +print $formother->select_month($cmonth,'remonth'); + +print $formother->select_year($syear,'reyear'); + +print ''; +print '
'; +print '
'; + +clearstatcache(); + +// Show link on other years +$linkforyear=array(); +$found=0; +if (is_dir($dir)) +{ + $handle=opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + if (is_dir($dir.'/'.$file) && ! preg_match('/^\./',$file) && is_numeric($file)) + { + $found=1; + $linkforyear[]=$file; + } + } + } +} +asort($linkforyear); +foreach($linkforyear as $cursoryear) +{ + print ''.$cursoryear.'  '; +} + +if ($year) +{ + if (is_dir($dir.'/'.$year)) + { + $handle=opendir($dir.'/'.$year); + + if ($found) print '
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $var=true; + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + if (preg_match('/^payment/i',$file)) + { + $var=!$var; + $tfile = $dir . '/'.$year.'/'.$file; + $relativepath = $year.'/'.$file; + print "".''; + print ''; + print ''; + } + } + closedir($handle); + } + print '
'.$langs->trans("Reporting").''.$langs->trans("Size").''.$langs->trans("Date").'
'.img_pdf().' '.$file.''.dol_print_size(dol_filesize($tfile)).''.dol_print_date(dol_filemtime($tfile),"dayhour").'
'; + } +} + +llxFooter(); + +$db->close();