Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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
00036
00037
00038 class Print_Ledger {
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 static function factory(Database $cn, $p_type_export, $p_format_output, Acc_Ledger $p_ledger) {
00049
00050
00051
00052 if ($p_format_output == 'PDF') {
00053 switch ($p_type_export) {
00054 case 0:
00055
00056
00057
00058 return new Print_Ledger_Detail($cn, $p_ledger);
00059 break;
00060
00061 case 1:
00062
00063
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
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 }
00124 }
00125 }
00126
00127
00128 }
00129
00130 ?>