32 $this->jr_id=trim($p_id);
43 $this->ledger_type=$this->db->get_value(
"select jrn_def_type from jrn_def ".
44 " where jrn_def_id = (select jr_def_id from jrn where jr_id=$1)",
46 if ($this->ledger_type==
'')
47 throw new Exception(
'Operation non trouvée');
51 if ( $this->ledger_type==
'ACH')
53 $this->array[
'e_mp']=0;
54 $this->array[
'jrn_type']=
'ACH';
55 $jrn=$this->db->get_array(
"select jr_id,to_char(jr_date,'DD.MM.YYYY') as date_fmt,".
56 " to_char(jrn_ech,'DD.MM.YYYY') as ech_fmt,jr_comment,jr_pj_number,
57 jr_tech_per,jr_Def_id,jr_internal ".
58 " from jrn where jr_id=$1",
60 $this->jr_id=$jrn[0][
'jr_id'];
63 $this->array[
'e_ech']=$jrn[0][
'ech_fmt'];
64 $this->array[
'e_date']=$jrn[0][
'date_fmt'];
65 $this->array[
'e_comm']=$jrn[0][
'jr_comment'];
66 $this->array[
'e_pj']=$jrn[0][
'jr_pj_number'];
67 $this->array[
'p_jrn']=$jrn[0][
'jr_def_id'];
68 $this->array[
'periode']=$jrn[0][
'jr_tech_per'];
71 $this->array[
'bon_comm']=$this->db->get_value(
"select ji_value from jrn_info where jr_id=$1 and id_type='BON_COMMANDE'",
73 $this->array[
'other_info']=$this->db->get_value(
"select ji_value from jrn_info where jr_id=$1 and id_type='OTHER'",
76 $qp=$this->db->get_array(
"select * from quant_purchase where j_id in (select j_id from jrnx join jrn on (j_grpt = jr_grpt_id) where ".
77 " jr_id=$1)",array($this->jr_id));
80 throw new Exception(
'Désolé cette opération a été faite en écriture directe');
83 $fcard=
new Fiche($this->db,$qp[0][
'qp_supplier']);
84 $this->array[
'e_client']=
$fcard->get_quick_code();
86 for ($e=0; $e<count($qp); $e++)
88 $fcard=
new Fiche($this->db,$qp[$e][
'qp_fiche']);
89 $this->array[
'e_march'.$e]=
$fcard->get_quick_code();;
90 $this->array[
'e_march'.$e.
'_price']=round($qp[$e][
'qp_price']/$qp[$e][
'qp_quantite'],2);
91 $this->array[
'e_march'.$e.
'_tva_amount']=$qp[$e][
'qp_vat'];
92 $this->array[
'e_march'.$e.
'_tva_id']=$qp[$e][
'qp_vat_code'];
93 $this->array[
'e_quant'.$e]=$qp[$e][
'qp_quantite'];
97 $this->array[
'nb_item']=(count($qp)<MAX_ARTICLE)?MAX_ARTICLE:count($qp);
102 if ( $this->ledger_type==
'VEN')
104 $this->array[
'e_mp']=0;
105 $this->array[
'jrn_type']=
'VEN';
106 $jrn=$this->db->get_array(
"select jr_id,
107 to_char(jr_date,'DD.MM.YYYY') as date_fmt,
108 to_char(jrn_ech,'DD.MM.YYYY') as ech_fmt,
109 jr_comment,jr_pj_number,
110 jr_tech_per,jr_Def_id,jr_internal
111 from jrn where jr_id=$1",
112 array($this->jr_id));
113 $this->jr_id=$jrn[0][
'jr_id'];
116 $this->array[
'e_ech']=$jrn[0][
'ech_fmt'];
117 $this->array[
'e_date']=$jrn[0][
'date_fmt'];
118 $this->array[
'e_comm']=$jrn[0][
'jr_comment'];
119 $this->array[
'e_pj']=$jrn[0][
'jr_pj_number'];
120 $this->array[
'p_jrn']=$jrn[0][
'jr_def_id'];
121 $this->array[
'periode']=$jrn[0][
'jr_tech_per'];
124 $this->array[
'bon_comm']=$this->db->get_value(
"select ji_value from jrn_info where jr_id=$1 and id_type='BON_COMMANDE'",
125 array($this->jr_id));
126 $this->array[
'other_info']=$this->db->get_value(
"select ji_value from jrn_info where jr_id=$1 and id_type='OTHER'",
127 array($this->jr_id));
129 $qp=$this->db->get_array(
"select * from quant_sold where j_id in (select j_id from jrnx join jrn on (j_grpt = jr_grpt_id) where ".
130 " jr_id=$1)",array($this->jr_id));
131 if ( count($qp) == 0)
132 throw new Exception(
'Désolé cette opération a été faite en écriture directe');
134 $fcard=
new Fiche($this->db,$qp[0][
'qs_client']);
135 $this->array[
'e_client']=
$fcard->get_quick_code();
139 for ($e=0; $e<count($qp); $e++)
141 $fcard=
new Fiche($this->db,$qp[$e][
'qs_fiche']);
142 $this->array[
'e_march'.$e]=
$fcard->get_quick_code();;
143 $this->array[
'e_march'.$e.
'_price']=round($qp[$e][
'qs_price']/$qp[$e][
'qs_quantite'],2);
144 $this->array[
'e_march'.$e.
'_tva_amount']=$qp[$e][
'qs_vat'];
145 $this->array[
'e_march'.$e.
'_tva_id']=$qp[$e][
'qs_vat_code'];
146 $this->array[
'e_quant'.$e]=$qp[$e][
'qs_quantite'];
150 $this->array[
'nb_item']=(count($qp)<MAX_ARTICLE)?MAX_ARTICLE:count($qp);
156 if ( $this->ledger_type==
'ODS')
158 $this->array[
'e_mp']=0;
159 $this->array[
'jrn_type']=
'ODS';
160 $jrn=$this->db->get_array(
"select jr_id,jr_internal,to_char(jr_date,'DD.MM.YYYY') as date_fmt,jr_comment,jr_pj_number, jr_tech_per,jr_Def_id from jrn where jr_id=$1",
161 array($this->jr_id));
162 $this->jr_id=$jrn[0][
'jr_id'];
165 $this->array[
'e_date']=$jrn[0][
'date_fmt'];
166 $this->array[
'desc']=$jrn[0][
'jr_comment'];
167 $this->array[
'e_pj']=$jrn[0][
'jr_pj_number'];
168 $this->array[
'p_jrn']=$jrn[0][
'jr_def_id'];
169 $this->array[
'periode']=$jrn[0][
'jr_tech_per'];
170 $ods=$this->db->get_array(
'select j_qcode,j_poste,j_text,j_montant,j_debit from jrnx where j_grpt = (select jr_grpt_id from jrn where jr_id=$1)',
171 array($this->jr_id));
172 for ($e=0; $e<count($ods); $e++)
174 $this->array[
'qc_'.$e]=$ods[$e][
'j_qcode'];
175 $this->array[
'poste'.$e]=(trim($ods[$e][
'j_qcode'])==
'')?$ods[$e][
'j_poste']:
'';
176 if ( $ods[$e][
'j_debit']==
't' )
177 $this->array[
'ck'.$e]=
true;
178 $this->array[
'amount'.$e]=$ods[$e][
'j_montant'];
179 $this->array[
'ld'.$e]=$ods[$e][
'j_text'];
181 $this->array[
'nb_item']=(count($ods)<MAX_ARTICLE)?MAX_ARTICLE:count($ods);
187 if ( $this->ledger_type==
"FIN")
189 $jrn=$this->db->get_array(
"select jr_id,to_char(jr_date,'DD.MM.YYYY') as date_fmt,to_char(jrn_ech,'DD.MM.YYYY') as ech_fmt,jr_comment,jr_pj_number, jr_tech_per,jr_Def_id from jrn where jr_id=$1",
190 array($this->jr_id));
192 $this->jr_id=$jrn[0][
'jr_id'];
193 $this->array[
'e_date']=$jrn[0][
'date_fmt'];
194 $this->array[
'e_comm']=$jrn[0][
'jr_comment'];
195 $this->array[
'e_pj']=$jrn[0][
'jr_pj_number'];
196 $this->array[
'p_jrn']=$jrn[0][
'jr_def_id'];
197 $this->array[
'period']=$jrn[0][
'jr_tech_per'];
199 $qp=$this->db->get_array(
"select * from quant_fin where jr_id =$1",array($this->jr_id));
201 if ( count($qp) == 0)
202 throw new Exception(
'Désolé cette opération ne peut être corrigée');
204 $fcard=
new Fiche($this->db,$qp[0][
'qf_bank']);
205 $this->array[
'e_bank']=
$fcard->get_quick_code();
207 $fcard=
new Fiche($this->db,$qp[0][
'qf_other']);
208 $this->array[
'e_other']=
$fcard->get_quick_code();
209 $this->array[
'e_amount']=$qp[0][
'qf_amount'];
218 $g_parameter->MY_STRICT=
'N';
228 if ($this->strict==
true)
230 $owner=
new Own($this->db);
231 $owner->MY_STRICT=
'Y';
232 $owner->save(
'MY_STRICT');
241 $g_parameter->MY_PJ_SUGGEST=
'N';
251 if ($this->toggle==
true)
253 $owner=
new Own($this->db);
254 $owner->MY_PJ_SUGGEST=
'Y';
255 $owner->save(
'MY_PJ_SUGGEST');
suspend_receipt()
deactivate the suggest mode for the receipt number, if
activate_strict()
activate strict mode, only if $this->strict=true
activate_receipt()
activate receipt, only if $this->toggle=true
format()
retrieve data from jrnx, jrn, quant_xxx and format them to usable for the acc_leger input function ...
suspend_strict()
deactivate the strict mode
__construct($p_cn, $p_id)
if($p_number->value==0) l les annuités seront recalculées et l pct[] ad_year[] select jr_internal
$fcard
Open the file and parse it.