noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
class_print_ledger.php
Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004  *   This file is part of NOALYSS.
00005  *
00006  *   NOALYSS is free software; you can redistribute it and/or modify
00007  *   it under the terms of the GNU General Public License as published by
00008  *   the Free Software Foundation; either version 2 of the License, or
00009  *   (at your option) any later version.
00010  *
00011  *   NOALYSS is distributed in the hope that it will be useful,
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *   GNU General Public License for more details.
00015  *
00016  *   You should have received a copy of the GNU General Public License
00017  *   along with NOALYSS; if not, write to the Free Software
00018  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 /**
00022  *  Parent class for the print_ledger class
00023  *
00024  * @author danydb
00025  */
00026 require_once 'class_database.php';
00027 require_once('class_print_ledger_detail.php');
00028 require_once('class_print_ledger_simple.php');
00029 require_once('class_print_ledger_simple_without_vat.php');
00030 require_once('class_print_ledger_fin.php');
00031 require_once('class_print_ledger_misc.php');
00032 require_once 'class_print_ledger_detail_item.php';
00033 
00034 /**
00035  * @brief Strategie class for the print_ledger class
00036  * 
00037  */
00038 class Print_Ledger {
00039 
00040     /**
00041      * Create an object Print_Ledger* depending on $p_type_export ( 0 => accounting
00042      * 1-> one row per operation 2-> detail of item)
00043      * @param type $cn
00044      * @param type $p_type_export
00045      * @param type $p_format_output CSV or PDF
00046      * @param Acc_Ledger $ledger
00047      */
00048     static function factory(Database $cn, $p_type_export, $p_format_output, Acc_Ledger $p_ledger) {
00049         /**
00050          * For PDF output
00051          */
00052         if ($p_format_output == 'PDF') {
00053             switch ($p_type_export) {
00054                 case 0:
00055                     //---------------------------------------------
00056                     // Detailled Printing (accounting )
00057                     //---------------------------------------------
00058                     return new Print_Ledger_Detail($cn, $p_ledger);
00059                     break;
00060 
00061                 case 1:
00062                     //----------------------------------------------------------------------
00063                     // Simple Printing Purchase Ledger
00064                     //---------------------------------------------------------------------
00065                     $own = new Own($cn);
00066                     $jrn_type = $p_ledger->get_type();
00067 
00068 
00069                     if ($jrn_type == 'ACH' || $jrn_type == 'VEN') {
00070                         if (
00071                                 ($jrn_type == 'ACH' && $cn->get_value('select count(qp_id) from quant_purchase') == 0) ||
00072                                 ($jrn_type == 'VEN' && $cn->get_value('select count(qs_id) from quant_sold') == 0)
00073                         ) {
00074                             $pdf = new Print_Ledger_Simple_without_vat($cn, $p_ledger);
00075                             $pdf->set_error('Ce journal ne peut être imprimé en mode simple');
00076                             return $pdf;
00077                         }
00078                         if ($own->MY_TVA_USE == 'Y') {
00079                             $pdf = new Print_Ledger_Simple($cn, $p_ledger);
00080                             return $pdf;
00081                         }
00082                         if ($own->MY_TVA_USE == 'N') {
00083                             $pdf = new Print_Ledger_Simple_without_vat($cn, $p_ledger);
00084                             return $pdf;
00085                         }
00086                     }
00087 
00088                     if ($jrn_type == 'FIN') {
00089                         $pdf = new Print_Ledger_Financial($cn, $p_ledger);
00090                         return $pdf;
00091                     }
00092                     if ($jrn_type == 'ODS' || $p_ledger->id == 0) {
00093                         $pdf = new Print_Ledger_Misc($cn, $p_ledger);
00094                         return $pdf;
00095                     }
00096                     break;
00097                 case 2:
00098                     /**********************************************************
00099                      * Print Detail Operation + Item
00100                      ********************************************************** */
00101                     $own = new Own($cn);
00102                     $jrn_type = $p_ledger->get_type();
00103                     if ($jrn_type == 'FIN') {
00104                         $pdf = new Print_Ledger_Financial($cn, $p_ledger);
00105                         return $pdf;
00106                         ;
00107                     }
00108                     if ($jrn_type == 'ODS' || $p_ledger->id == 0) {
00109                         $pdf = new Print_Ledger_Misc($cn, $p_ledger);
00110                         return $pdf;
00111                     }
00112                     if (
00113                             ($jrn_type == 'ACH' && $cn->get_value('select count(qp_id) from quant_purchase') == 0) ||
00114                             ($jrn_type == 'VEN' && $cn->get_value('select count(qs_id) from quant_sold') == 0)
00115                     ) {
00116                         $pdf = new Print_Ledger_Simple_without_vat($cn, $p_ledger);
00117                         $pdf->set_error('Ce journal ne peut être imprimé en mode simple');
00118                         return $pdf;
00119                     }
00120                     $pdf = new Print_Ledger_Detail_Item($cn,$p_ledger);
00121                     return $pdf;
00122                     
00123             } // end switch
00124         } // end $p_format == PDF
00125     }
00126 
00127 // end function
00128 }
00129 
00130 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations