Task #890 PRINTJRN : export PDF et CSV des opérations détaillées
This commit is contained in:
parent
9a7839e21f
commit
919fd339d0
4 changed files with 263 additions and 128 deletions
129
include/class_print_ledger.php
Normal file
129
include/class_print_ledger.php
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of PhpCompta.
|
||||
*
|
||||
* PhpCompta 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 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PhpCompta 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 PhpCompta; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* Parent class for the print_ledger class
|
||||
*
|
||||
* @author danydb
|
||||
*/
|
||||
require_once 'class_database.php';
|
||||
require_once('class_print_ledger_detail.php');
|
||||
require_once('class_print_ledger_simple.php');
|
||||
require_once('class_print_ledger_simple_without_vat.php');
|
||||
require_once('class_print_ledger_fin.php');
|
||||
require_once('class_print_ledger_misc.php');
|
||||
|
||||
/**
|
||||
* @brief Strategie class for the print_ledger class
|
||||
*
|
||||
*/
|
||||
class Print_Ledger {
|
||||
|
||||
/**
|
||||
* Create an object Print_Ledger* depending on $p_type_export ( 0 => accounting
|
||||
* 1-> one row per operation 2-> detail of item)
|
||||
* @param type $cn
|
||||
* @param type $p_type_export
|
||||
* @param type $p_format_output CSV or PDF
|
||||
* @param Acc_Ledger $ledger
|
||||
*/
|
||||
static function factory(Database $cn, $p_type_export, $p_format_output, Acc_Ledger $p_ledger) {
|
||||
/**
|
||||
* For PDF output
|
||||
*/
|
||||
if ($p_format_output == 'PDF') {
|
||||
switch ($p_type_export) {
|
||||
case 0:
|
||||
//---------------------------------------------
|
||||
// Detailled Printing (accounting )
|
||||
//---------------------------------------------
|
||||
return new Print_Ledger_Detail($cn, $p_ledger);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
//----------------------------------------------------------------------
|
||||
// Simple Printing Purchase Ledger
|
||||
//---------------------------------------------------------------------
|
||||
$own = new Own($cn);
|
||||
$jrn_type = $p_ledger->get_type();
|
||||
|
||||
|
||||
if ($jrn_type == 'ACH' || $jrn_type == 'VEN') {
|
||||
if (
|
||||
($jrn_type == 'ACH' && $cn->get_value('select count(qp_id) from quant_purchase') == 0) ||
|
||||
($jrn_type == 'VEN' && $cn->get_value('select count(qs_id) from quant_sold') == 0)
|
||||
) {
|
||||
$pdf = new Print_Ledger_Simple_without_vat($cn, $p_ledger);
|
||||
$pdf->set_error('Ce journal ne peut être imprimé en mode simple');
|
||||
return $pdf;
|
||||
}
|
||||
if ($own->MY_TVA_USE == 'Y') {
|
||||
$pdf = new Print_Ledger_Simple($cn, $p_ledger);
|
||||
return $pdf;
|
||||
}
|
||||
if ($own->MY_TVA_USE == 'N') {
|
||||
$pdf = new Print_Ledger_Simple_without_vat($cn, $p_ledger);
|
||||
return $pdf;
|
||||
}
|
||||
}
|
||||
|
||||
if ($jrn_type == 'FIN') {
|
||||
$pdf = new Print_Ledger_Financial($cn, $p_ledger);
|
||||
return $pdf;
|
||||
}
|
||||
if ($jrn_type == 'ODS' || $p_ledger->id == 0) {
|
||||
$pdf = new Print_Ledger_Misc($cn, $p_ledger);
|
||||
return $pdf;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
/* * ********************************************************
|
||||
* Print Detail Operation + Item
|
||||
* ********************************************************* */
|
||||
$own = new Own($cn);
|
||||
$jrn_type = $p_ledger->get_type();
|
||||
if ($jrn_type == 'FIN') {
|
||||
$pdf = new Print_Ledger_Financial($cn, $p_ledger);
|
||||
return $pdf;
|
||||
;
|
||||
}
|
||||
if ($jrn_type == 'ODS' || $p_ledger->id == 0) {
|
||||
$pdf = new Print_Ledger_Misc($cn, $p_ledger);
|
||||
return $pdf;
|
||||
}
|
||||
if (
|
||||
($jrn_type == 'ACH' && $cn->get_value('select count(qp_id) from quant_purchase') == 0) ||
|
||||
($jrn_type == 'VEN' && $cn->get_value('select count(qs_id) from quant_sold') == 0)
|
||||
) {
|
||||
$pdf = new Print_Ledger_Simple_without_vat($cn, $p_ledger);
|
||||
$pdf->set_error('Ce journal ne peut être imprimé en mode simple');
|
||||
return $pdf;
|
||||
}
|
||||
$pdf = new Print_Ledger_Detail_Item($cn,$p_ledger);
|
||||
return $pdf;
|
||||
|
||||
} // end switch
|
||||
} // end $p_format == PDF
|
||||
}
|
||||
|
||||
// end function
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -28,12 +28,13 @@ require_once('class_pdf.php');
|
|||
|
||||
class Print_Ledger_Detail extends PDF
|
||||
{
|
||||
public function __construct ($p_cn = null, $orientation = 'P', $unit = 'mm', $format = 'A4')
|
||||
public function __construct ($p_cn = null, Acc_Ledger $ledger)
|
||||
{
|
||||
|
||||
if($p_cn == null) die("No database connection. Abort.");
|
||||
|
||||
|
||||
parent::__construct($p_cn,'L', 'mm', 'A4');
|
||||
$this->ledger=$ledger;
|
||||
date_default_timezone_set ('Europe/Paris');
|
||||
|
||||
}
|
||||
|
|
@ -70,13 +71,14 @@ class Print_Ledger_Detail extends PDF
|
|||
return parent::Cell($w, $h, $txt, $border, $ln, $align, $fill, $link);
|
||||
}
|
||||
|
||||
function export($Jrn)
|
||||
function export()
|
||||
{
|
||||
|
||||
// detailled printing
|
||||
$rap_deb=0;
|
||||
$rap_cred=0;
|
||||
// take all operations from jrn
|
||||
$array=$Jrn->get_operation($_GET['from_periode'],$_GET['to_periode']);
|
||||
$array=$this->ledger->get_operation($_GET['from_periode'],$_GET['to_periode']);
|
||||
|
||||
$this->SetFont('DejaVu','BI',7);
|
||||
$this->Cell(215,7,'report Débit',0,0,'R');
|
||||
|
|
|
|||
105
include/class_print_ledger_detail_item.php
Normal file
105
include/class_print_ledger_detail_item.php
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
/**
|
||||
* Print detail of operation PURCHASE or SOLD plus the items
|
||||
* There is no report of the different amounts
|
||||
*
|
||||
* @author danydb
|
||||
*/
|
||||
class Print_Ledger_Detail_Item extends PDF
|
||||
{
|
||||
public function __construct ($p_cn,$p_jrn)
|
||||
{
|
||||
|
||||
if($p_cn == null) die("No database connection. Abort.");
|
||||
|
||||
parent::__construct($p_cn,'L', 'mm', 'A4');
|
||||
$this->ledger=$p_jrn;
|
||||
|
||||
}
|
||||
|
||||
function setDossierInfo($dossier = "n/a")
|
||||
{
|
||||
$this->dossier = dossier::name()." ".$dossier;
|
||||
}
|
||||
/**
|
||||
*@brief write the header of each page
|
||||
*/
|
||||
function Header()
|
||||
{
|
||||
//Arial bold 12
|
||||
$this->SetFont('DejaVu', 'B', 12);
|
||||
//Title
|
||||
$this->Cell(0,10,$this->dossier, 'B', 0, 'C');
|
||||
//Line break
|
||||
$this->Ln(20);
|
||||
|
||||
}
|
||||
/**
|
||||
*@brief write the Footer
|
||||
*/
|
||||
function Footer()
|
||||
{
|
||||
//Position at 3 cm from bottom
|
||||
$this->SetY(-20);
|
||||
/* write reporting */
|
||||
$this->Cell(143,6,'Total page ','T',0,'R'); /* HTVA */
|
||||
$this->Cell(15,6,nbm($this->tp_htva),'T',0,'R'); /* HTVA */
|
||||
if ( $this->jrn_type !='VEN')
|
||||
{
|
||||
$this->Cell(15,6,nbm($this->tp_priv),'T',0,'R'); /* prive */
|
||||
$this->Cell(15,6,nbm($this->tp_nd),'T',0,'R'); /* Tva ND */
|
||||
}
|
||||
foreach($this->a_Tva as $line_tva)
|
||||
{
|
||||
$l=$line_tva['tva_id'];
|
||||
$this->Cell(15,6,nbm($this->tp_tva[$l]),'T',0,'R');
|
||||
}
|
||||
$this->Cell(15,6,nbm($this->tp_tvac),'T',0,'R'); /* Tvac */
|
||||
$this->Ln(2);
|
||||
|
||||
$this->Cell(143,6,'report',0,0,'R'); /* HTVA */
|
||||
$this->Cell(15,6,nbm($this->rap_htva),0,0,'R'); /* HTVA */
|
||||
if ( $this->jrn_type !='VEN')
|
||||
{
|
||||
$this->Cell(15,6,nbm($this->rap_priv),0,0,'R'); /* prive */
|
||||
$this->Cell(15,6,nbm($this->rap_nd),0,0,'R'); /* Tva ND */
|
||||
}
|
||||
foreach($this->a_Tva as $line_tva)
|
||||
{
|
||||
$l=$line_tva['tva_id'];
|
||||
$this->Cell(15,6,nbm($this->rap_tva[$l]),0,0,'R');
|
||||
}
|
||||
$this->Cell(15,6,nbm($this->rap_tvac),0,0,'R'); /* Tvac */
|
||||
$this->Ln(2);
|
||||
|
||||
//Arial italic 8
|
||||
$this->SetFont('Arial', 'I', 8);
|
||||
//Page number
|
||||
$this->Cell(0,8,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'L');
|
||||
// Created by PhpCompta
|
||||
$this->Cell(0,8,'Created by Phpcompta, online on http://www.aevalys.eu',0,0,'R',false,'http://www.aevalys.eu');
|
||||
}
|
||||
|
||||
function Cell ($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
|
||||
{
|
||||
$txt = str_replace("\\", "", $txt);
|
||||
return parent::Cell($w, $h, $txt, $border, $ln, $align, $fill, $link);
|
||||
}
|
||||
/**
|
||||
*@brief export the ledger in PDF
|
||||
*/
|
||||
function export()
|
||||
{
|
||||
bcscale(2);
|
||||
$a_jrn=$this->ledger->get_operation($_GET['from_periode'],
|
||||
$_GET['to_periode']);
|
||||
|
||||
if ( $a_jrn == null ) return;
|
||||
for ( $i=0;$i<count($a_jrn);$i++)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
@ -21,13 +21,14 @@
|
|||
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
// $Revision$
|
||||
/*! \file
|
||||
/* ! \file
|
||||
* \brief Send a ledger in a pdf format
|
||||
*
|
||||
*/
|
||||
if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
|
||||
if (!defined('ALLOWED'))
|
||||
die('Appel direct ne sont pas permis');
|
||||
require_once('class_dossier.php');
|
||||
$gDossier=dossier::id();
|
||||
$gDossier = dossier::id();
|
||||
require_once('class_pdf.php');
|
||||
include_once('class_user.php');
|
||||
include_once("ac_common.php");
|
||||
|
|
@ -36,146 +37,44 @@ include_once("class_impress.php");
|
|||
include_once("class_acc_ledger.php");
|
||||
require_once('class_own.php');
|
||||
require_once('class_periode.php');
|
||||
require_once('class_print_ledger_detail.php');
|
||||
require_once('class_print_ledger_simple.php');
|
||||
require_once('class_print_ledger_simple_without_vat.php');
|
||||
require_once('class_print_ledger_fin.php');
|
||||
require_once('class_print_ledger_misc.php');
|
||||
require_once 'class_print_ledger.php';
|
||||
|
||||
|
||||
$cn=new Database($gDossier);
|
||||
$periode=new Periode($cn);
|
||||
$cn = new Database($gDossier);
|
||||
$periode = new Periode($cn);
|
||||
|
||||
$l_type="JRN";
|
||||
$own=new Own($cn);
|
||||
$l_type = "JRN";
|
||||
$own = new Own($cn);
|
||||
|
||||
$Jrn=new Acc_Ledger($cn,$_GET['jrn_id']);
|
||||
$Jrn = new Acc_Ledger($cn, $_GET['jrn_id']);
|
||||
|
||||
$Jrn->get_name();
|
||||
$g_user->Check();
|
||||
$g_user->check_dossier($gDossier);
|
||||
|
||||
// Security
|
||||
if ( $_GET['jrn_id']!=0 && $g_user->check_jrn($_GET['jrn_id']) == 'X' )
|
||||
{
|
||||
if ($_GET['jrn_id'] != 0 && $g_user->check_jrn($_GET['jrn_id']) == 'X') {
|
||||
/* Cannot Access */
|
||||
NoAccess();
|
||||
}
|
||||
|
||||
$ret="";
|
||||
$ret = "";
|
||||
|
||||
// filter : 0 for Grand Livre otherwise 1
|
||||
$filter=( $Jrn->id == 0)?0:1;
|
||||
$jrn_type=$Jrn->get_type();
|
||||
$jrn_type = $Jrn->get_type();
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Detailled Printing
|
||||
//---------------------------------------------------------------------
|
||||
if ( $_REQUEST['p_simple']== 0 )
|
||||
{
|
||||
$pdf=new Print_Ledger_Detail($cn);
|
||||
$pdf->setDossierInfo($Jrn->name);
|
||||
$pdf->AliasNbPages();
|
||||
$pdf->AddPage();
|
||||
$pdf->SetAuthor('Phpcompta');
|
||||
$pdf->setTitle("Journal",true);
|
||||
$pdf = Print_Ledger::factory($cn, $_REQUEST['p_simple'], "PDF", $Jrn);
|
||||
|
||||
$pdf->export($Jrn);
|
||||
$pdf->setDossierInfo($Jrn->name);
|
||||
$pdf->AliasNbPages();
|
||||
$pdf->AddPage();
|
||||
$pdf->SetAuthor('Phpcompta');
|
||||
$pdf->setTitle("Journal", true);
|
||||
|
||||
$fDate=date('dmy-Hi');
|
||||
$pdf->Output('journal-'.$fDate.'.pdf','D');
|
||||
exit(0);
|
||||
$pdf->export();
|
||||
|
||||
} // impression detaillé
|
||||
//----------------------------------------------------------------------
|
||||
// Simple Printing Purchase Ledger
|
||||
//---------------------------------------------------------------------
|
||||
if ( $_REQUEST['p_simple']== 1 )
|
||||
{
|
||||
if ( $jrn_type=='ACH' || $jrn_type=='VEN')
|
||||
{
|
||||
if ( $jrn_type=='ACH' && $cn->get_value('select count(qp_id) from quant_purchase') == 0 )
|
||||
{
|
||||
$pdf= new Print_Ledger_Simple_without_vat($cn,$Jrn);
|
||||
$pdf->setDossierInfo($Jrn->name);
|
||||
$pdf->AliasNbPages();
|
||||
$pdf->AddPage();
|
||||
$pdf->SetAuthor('Phpcompta');
|
||||
$pdf->setTitle("Journal",true);
|
||||
$fDate = date('dmy-Hi');
|
||||
$pdf->Output('journal-' . $fDate . '.pdf', 'D');
|
||||
exit(0);
|
||||
|
||||
$pdf->Cell(0,6,'Ce journal ne peut être imprimé en mode simple');
|
||||
$pdf->output('erreur.pdf','D');
|
||||
exit();
|
||||
}
|
||||
if ( $jrn_type=='VEN' && $cn->get_value('select count(qs_id) from quant_sold') == 0 )
|
||||
{
|
||||
$pdf= new Print_Ledger_Simple_without_vat($cn,$Jrn);
|
||||
$pdf->setDossierInfo($Jrn->name);
|
||||
$pdf->AliasNbPages();
|
||||
$pdf->AddPage();
|
||||
$pdf->Cell(0,6,'Ce journal ne peut être imprimé en mode simple');
|
||||
$pdf->output('erreur.pdf','D');
|
||||
exit();
|
||||
}
|
||||
|
||||
if ( $own->MY_TVA_USE=='Y')
|
||||
{
|
||||
$pdf= new Print_Ledger_Simple($cn,$Jrn);
|
||||
$pdf->setDossierInfo($Jrn->name);
|
||||
$pdf->AliasNbPages();
|
||||
$pdf->AddPage();
|
||||
$pdf->SetAuthor('Phpcompta');
|
||||
$pdf->setTitle("Journal",true);
|
||||
|
||||
$pdf->export();
|
||||
$fDate=date('dmy-Hi');
|
||||
$pdf->Output('journal-'.$fDate.'.pdf','D');
|
||||
exit(0);
|
||||
}
|
||||
if ( $own->MY_TVA_USE=='N')
|
||||
{
|
||||
$pdf= new Print_Ledger_Simple_without_vat($cn,$Jrn);
|
||||
$pdf->setDossierInfo($Jrn->name);
|
||||
$pdf->AliasNbPages();
|
||||
$pdf->AddPage();
|
||||
$pdf->SetAuthor('Phpcompta');
|
||||
$pdf->setTitle("Journal", true);
|
||||
|
||||
$pdf->export($Jrn);
|
||||
$fDate=date('dmy-Hi');
|
||||
$pdf->Output('journal-'.$fDate.'.pdf','D');
|
||||
exit(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($jrn_type=='FIN')
|
||||
{
|
||||
$pdf= new Print_Ledger_Financial($cn,$Jrn);
|
||||
$pdf->setDossierInfo($Jrn->name);
|
||||
$pdf->AliasNbPages();
|
||||
$pdf->AddPage();
|
||||
$pdf->SetAuthor('Phpcompta');
|
||||
$pdf->setTitle("Journal",true);
|
||||
|
||||
$pdf->export();
|
||||
$fDate=date('dmy-Hi');
|
||||
$pdf->Output('journal-'.$fDate.'.pdf','D');
|
||||
exit(0);
|
||||
}
|
||||
if ( $jrn_type=='ODS' || $Jrn->id==0)
|
||||
{
|
||||
$pdf= new Print_Ledger_Misc($cn,$Jrn);
|
||||
$pdf->setDossierInfo($Jrn->name);
|
||||
$pdf->AliasNbPages();
|
||||
$pdf->SetAuthor('Phpcompta');
|
||||
$pdf->setTitle("Journal",true);
|
||||
|
||||
$pdf->AddPage();
|
||||
$pdf->export();
|
||||
$fDate=date('dmy-Hi');
|
||||
$pdf->Output('journal-'.$fDate.'.pdf','D');
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue