Go to the source code of this file.
Functions | |
FormODS ($p_cn, $p_jrn, $p_periode, $p_submit, $p_array=null, $pview_only=true, $p_article=6, $p_saved=false) | |
Display the miscellaneous operation Used to show detail, encode a new oper or update one. | |
RecordODS ($p_cn, $p_array, $p_user, $p_jrn) | |
Record an buy in the table jrn & jrnx. |
Definition in file user_form_ods.php.
|
Display the miscellaneous operation Used to show detail, encode a new oper or update one.
Definition at line 45 of file user_form_ods.php. References $filter, $flag, $i, $l_line, $msg, $p_jrn, $r, CountSql(), echo_error(), GetJrnProperty(), GetPeriode(), GetPosteLibelle(), isNumber(), name, value, and VerifyOperationDate(). 00046 { 00047 include_once("poste.php"); 00048 if ( $p_array != null ) { 00049 // array contains old value 00050 foreach ( $p_array as $a=>$v) { 00051 ${"$a"}=$v; 00052 } 00053 } 00054 // The date 00055 list ($l_date_start,$l_date_end)=GetPeriode($p_cn,$p_periode); 00056 $flag=(isset($e_date))?1:0; 00057 $e_date=( ! isset($e_date) ) ? substr($l_date_start,2,8):$e_date; 00058 00059 // Verify if valid date 00060 if ( $flag==1 and VerifyOperationDate($p_cn,$p_periode,$e_date) == null) { 00061 if ( $pview_only == true) 00062 return null; 00063 else 00064 $e_date=substr($l_date_start,2,8); 00065 } 00066 00067 $e_comm=(isset($e_comm))?$e_comm:""; 00068 // Save old value and set a new one 00069 00070 $r=""; 00071 if ( $pview_only == false) { 00072 $r.=JS_SEARCH_POSTE; 00073 } 00074 $r.="<FORM NAME=\"form_detail\" enctype=\"multipart/form-data\" ACTION=\"user_jrn.php?action=new&p_jrn=$p_jrn\" METHOD=\"POST\">"; 00075 $r.='<TABLE>'; 00076 // Date 00077 $wDate=new widget('text'); 00078 $wDate->SetReadOnly($pview_only); 00079 $wDate->table=1; 00080 $r.="<TR>".$wDate->IOValue("e_date",$e_date,'Date')."</TR>"; 00081 00082 // Description 00083 $Commentaire=new widget("text"); 00084 $Commentaire->table=1; 00085 $Commentaire->SetReadOnly($pview_only); 00086 $Commentaire->size=80; 00087 $r.="<tr>"; 00088 $r.=$Commentaire->IOValue("e_comm",$e_comm,"Description"); 00089 $r.="</tr>"; 00090 00091 include_once("fiche_inc.php"); 00092 00093 // Record the current number of article 00094 $r.='<INPUT TYPE="HIDDEN" name="nb_item" value="'.$p_article.'">'; 00095 $e_comment=(isset($e_comment))?$e_comment:""; 00096 00097 00098 // Start the div for item to encode 00099 $r.="<DIV>"; 00100 $r.='<H2 class="info">Opérations Diverses</H2>'; 00101 $r.='<TABLE border="0">'; 00102 $r.="<tr>"; 00103 $r.="<th></th>"; 00104 $r.="<th>Compte</th>"; 00105 $r.="<th>Poste</th>"; 00106 $r.="<th>Montant</th>"; 00107 $r.="<th>Crédit ou dédit</th>"; 00108 $r.="</tr>"; 00109 $sum_deb=0.0; 00110 $sum_cred=0.0; 00111 00112 // for each good 00113 for ($i=0;$i< $p_article;$i++) { 00114 00115 $account=(isset(${"e_account$i"}))?${"e_account$i"}:""; 00116 00117 $lib=""; 00118 // If $account has a value 00119 if ( isNumber($account) == 1 ) { 00120 if ( CountSql($p_cn,"select * from tmp_pcmn where pcm_val=$account") == 0 ) { 00121 $msg="Poste comptable inexistant !!! "; 00122 echo_error($msg); echo_error($msg); 00123 echo "<SCRIPT>alert('$msg');</SCRIPT>"; 00124 $account=""; 00125 if ( $pview_only == true ) return null; 00126 } else { 00127 // retrieve the tva label and name 00128 $lib=GetPosteLibelle($p_cn, $account,1); 00129 } 00130 } 00131 00132 ${"e_account$i"."_amount"}=(isset(${"e_account$i"."_amount"}))?${"e_account$i"."_amount"}:0; 00133 if ( isNumber(${"e_account$i"."_amount"}) == 0 ) { 00134 if ( $pview_only==true) { 00135 $msg="Montant invalide !!! "; 00136 echo_error($msg); echo_error($msg); 00137 echo "<SCRIPT>alert('$msg');</SCRIPT>"; 00138 return null; 00139 } 00140 ${"e_account$i"."_amount"}=0; 00141 } 00142 // code 00143 // Do we need a filter ? 00144 $l_line=GetJrnProperty($p_cn,$p_jrn); 00145 if( strlen(trim ($l_line['jrn_def_class_cred']) ) > 0 or 00146 strlen(trim ($l_line['jrn_def_class_deb']) ) > 0 ) { 00147 $filter=1; 00148 } 00149 else 00150 $filter=null; 00151 $W = new widget('js_search_poste'); 00152 $W->readonly=$pview_only; 00153 $W->label=""; 00154 $W->extra=$p_jrn; 00155 $W->extra2=$filter; 00156 // $r.='<TR>'.InputType("","js_search_poste","e_account".$i,$account,$pview_only,$filter); 00157 $r.="<TR>".$W->IOValue("e_account".$i, $account); 00158 //libelle 00159 $r.="<td> $lib </td>"; 00160 //amount 00161 $wAmount=new widget("text"); 00162 $wAmount->table=1; 00163 $wAmount->SetReadOnly($pview_only); 00164 $r.=$wAmount->IOValue("e_account".$i."_amount",${"e_account$i"."_amount"}); 00165 00166 00167 // Type is debit or credit, retrieve the old values 00168 ${"e_account$i"."_type"}=(isset (${"e_account$i"."_type"}))?${"e_account$i"."_type"}:'d'; 00169 $c_check=( ${"e_account$i"."_type"} == 'c')?"CHECKED":""; 00170 $d_check=( ${"e_account$i"."_type"} == 'd' )?"CHECKED":""; 00171 $r.='<td>'; 00172 if ( $pview_only == false ) { 00173 $r.=' <input type="radio" name="'."e_account"."$i"."_type".'" value="d" '.$d_check.'> Débit ou '; 00174 $r.=' <input type="radio" name="'."e_account"."$i"."_type".'" value="c" '.$c_check.'> Crédit '; 00175 }else { 00176 $r.=(${"e_account$i"."_type"} == 'c' )?"Crédit":"Dédit"; 00177 $r.='<input type="hidden" name="e_account'.$i.'_type" value="'.${"e_account$i"."_type"}.'">'; 00178 } 00179 $r.='</td>'; 00180 $r.='</TR>'; 00181 $sum_deb+=(${"e_account$i"."_type"}=='d')?${"e_account$i"."_amount"}:0; 00182 $sum_cred+=(${"e_account$i"."_type"}=='c')?${"e_account$i"."_amount"}:0; 00183 } // End for 00184 00185 $r.="</TABLE>"; 00186 00187 if ( $pview_only==true && $p_saved==false) { 00188 // check for upload piece 00189 $file=new widget("file"); 00190 $file->table=1; 00191 $r.="<hr>"; 00192 $r.= "<table>"; 00193 $r.="<TR>".$file->IOValue("pj","","Pièce justificative")."</TR>"; 00194 $r.="</table>"; 00195 $r.="<hr>"; 00196 } 00197 // Set correctly the REQUEST param for jrn_type 00198 $h=new widget('hidden'); 00199 $h->name='jrn_type'; 00200 $h->value='OD'; 00201 $r.=$h->IOValue(); 00202 00203 $r.=$p_submit; 00204 // $r.="</DIV>"; 00205 $r.="</FORM>"; 00206 //TODO if view only show total 00207 $tmp= abs($sum_deb-$sum_cred); 00208 echo_debug('user_form_ods.php',__LINE__,"Diff = ".$tmp); 00209 if ( abs($sum_deb-$sum_cred) > 0.0001 and $pview_only==true) { 00210 $msg=sprintf("Montant non correspondant credit = %.5f debit = %.5f diff = %.5f", 00211 $sum_cred,$sum_deb,$sum_cred-$sum_deb); 00212 echo "<script> alert('$msg'); </script>"; 00213 return null; 00214 } 00215 00216 // Verify that we have a non-null operation 00217 if ($pview_only==true and $sum_cred == 0) 00218 { 00219 $msg=sprintf("Montant null"); 00220 echo "<script> alert('$msg'); </script>"; 00221 return null; 00222 } 00223 00224 return $r; 00225 00226 00227 }
|
|
Record an buy in the table jrn & jrnx.
Definition at line 247 of file user_form_ods.php. References $e, $seq, exit, InsertJrnx(), isNumber(), NextSequence(), and StartSql(). 00248 { 00249 foreach ( $p_array as $v => $e) 00250 { 00251 ${"$v"}=$e; 00252 } 00253 // Get the default period 00254 $periode=$p_user->GetPeriode(); 00255 $amount=0.0; 00256 // Computing total customer 00257 00258 $sum_deb=0.0; 00259 $sum_cred=0.0; 00260 00261 // Compute the j_grpt 00262 $seq=NextSequence($p_cn,'s_grpt'); 00263 00264 StartSql($p_cn); 00265 // store into the database 00266 for ( $i = 0; $i < $nb_item;$i++) { 00267 if ( isNumber(${"e_account$i"}) == 0 ) continue; 00268 $sum_deb+=(${"e_account$i"."_type"}=='d')?round(${"e_account$i"."_amount"},2):0; 00269 $sum_cred+=(${"e_account$i"."_type"}=='c')?round(${"e_account$i"."_amount"},2):0; 00270 00271 if ( ${"e_account$i"."_amount"} == 0 ) continue; 00272 if ( ($j_id=InsertJrnx($p_cn,${"e_account$i"."_type"},$p_user->id,$p_jrn,${"e_account$i"},$e_date,${"e_account$i"."_amount"},$seq,$periode)) == false ) { 00273 $Rollback($p_cn);exit("error 'user_form_ods.php' __LINE__");} 00274 } 00275 00276 if ( InsertJrn($p_cn,$e_date,"",$p_jrn,$e_comm,$sum_deb,$seq,$periode) == false ) { 00277 $Rollback($p_cn);exit("error 'user_form_ods.php' __LINE__");} 00278 00279 // Set Internal code and Comment 00280 $internal_code=SetInternalCode($p_cn,$seq,$p_jrn); 00281 if ( $e_comm=="" ) { 00282 // Update comment if comment is blank 00283 $Res=ExecSql($p_cn,"update jrn set jr_comment='".$internal_code."' where jr_grpt_id=".$seq); 00284 } 00285 if ( isset ($_FILES)) 00286 save_upload_document($p_cn,$seq); 00287 00288 Commit($p_cn); 00289 return $internal_code; 00290 }
|