00001 <?
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024 require_once("constant.php");
00025 require_once("class_widget.php");
00026 require_once("preference.php");
00027 require_once("fiche_inc.php");
00028 require_once("user_common.php");
00043 function FormVenInput($p_cn,$p_jrn,$p_periode,$p_array=null,$pview_only=true,$p_article=1)
00044 {
00045
00046 if ( $p_array != null ) {
00047
00048 foreach ( $p_array as $a=>$v) {
00049 ${"$a"}=$v;
00050 }
00051 }
00052
00053 list ($l_date_start,$l_date_end)=GetPeriode($p_cn,$p_periode);
00054 $op_date=( ! isset($e_date) ) ?substr($l_date_start,2,8):$e_date;
00055 $e_ech=(isset($e_ech))?$e_ech:"";
00056 $e_comm=(isset($e_comm))?$e_comm:"";
00057
00058
00059 echo_debug('user_form_ven.php',__LINE__,"form_input.php.FormVentep_op_date is $op_date");
00060 $r="";
00061 if ( $pview_only == false) {
00062 $r.=JS_SEARCH_CARD;
00063 $r.=JS_SHOW_TVA;
00064 $r.=JS_TVA;
00065
00066 $href=$_SERVER['SCRIPT_NAME'];
00067 switch ($href)
00068 {
00069
00070 case '/user_jrn.php':
00071 $href="user_jrn.php?action=insert_vente&p_jrn=$p_jrn";
00072 break;
00073 case '/commercial.php':
00074 $href="commercial.php?p_action=facture&p_jrn=$p_jrn";
00075 break;
00076 default:
00077 echo_error('user_form_ven.php',__LINE__,'Erreur invalid request uri');
00078 exit (-1);
00079 }
00080
00081 $r.="<FORM NAME=\"form_detail\" ACTION=\"$href\" METHOD=\"POST\">";
00082
00083
00084 }
00085 $sql="select jrn_def_id as value,jrn_def_name as label from jrn_def where jrn_def_type='VEN'";
00086 $list=GetArray($p_cn,$sql);
00087 $r.='<TABLE>';
00088
00089
00090 $Date=new widget("text");
00091 $Date->SetReadOnly($pview_only);
00092 $Date->table=1;
00093 $Date->tabindex=1;
00094 $r.="<tr>";
00095 $r.=$Date->IOValue("e_date",$op_date,"Date");
00096 $r.="</tr>";
00097
00098
00099 $Echeance=new widget("text");
00100 $Echeance->SetReadOnly($pview_only);
00101 $Echeance->table=1;
00102 $Echeance->tabindex=2;
00103 $r.="<tr>";
00104 $r.=$Echeance->IOValue("e_ech",$e_ech,"Echeance");
00105 $r.="</tr>";
00106
00107
00108 $Commentaire=new widget("text");
00109 $Commentaire->table=1;
00110 $Commentaire->SetReadOnly($pview_only);
00111 $Commentaire->size=80;
00112 $Commentaire->tabindex=3;
00113 $r.="<tr>";
00114 $r.=$Commentaire->IOValue("e_comm",$e_comm,"Description");
00115 $r.="</tr>";
00116 include_once("fiche_inc.php");
00117
00118
00119 $fiche='deb';
00120 echo_debug('user_form_ven.php',__LINE__,"Client Nombre d'enregistrement ".sizeof($fiche));
00121
00122
00123 $e_client=( isset ($e_client) )?$e_client:"";
00124 $e_client_label="";
00125
00126
00127
00128 if ( isNumber($e_client) == 1 ) {
00129 if ( isFicheOfJrn($p_cn,$p_jrn,$e_client,'deb') == 0 ) {
00130 $msg="Fiche inexistante !!! ";
00131 echo_error($msg); echo_error($msg);
00132 echo "<SCRIPT>alert('$msg');</SCRIPT>";
00133 $e_client="";
00134 } else {
00135 $a_client=GetFicheAttribut($p_cn,$e_client);
00136 if ( $a_client != null)
00137 $e_client_label=$a_client['vw_name']." adresse ".$a_client['vw_addr']." ".$a_client['vw_cp'];
00138 }
00139 }
00140
00141 $W1=new widget("js_search");
00142 $W1->label="Client";
00143 $W1->name="e_client";
00144 $W1->tabindex=3;
00145 $W1->value=$e_client;
00146 $W1->extra=$fiche;
00147 $W1->extra2=$p_jrn;
00148 $r.="<TR>".$W1->IOValue();
00149 $client_label=new widget("span");
00150 $r.= $client_label->IOValue("e_client_label",$e_client_label)."</TD></TR>";
00151 $r.="</TABLE>";
00152
00153
00154 $Hid=new widget('hidden');
00155 $r.=$Hid->IOValue("nb_item",$p_article);
00156 $e_comment=(isset($e_comment))?$e_comment:"";
00157
00158
00159
00160 $r.="<DIV>";
00161 $r.='<H2 class="info">Articles</H2>';
00162 $r.='<TABLE>';
00163 $r.='<TR>';
00164 $r.="<th></th>";
00165 $r.="<th>Code</th>";
00166 $r.="<th>Dénomination</th>";
00167 $r.="<th>prix</th>";
00168 $r.="<th>tva</th>";
00169 $r.="<th>quantité</th>";
00170 $r.='</TR>';
00171
00172
00173 for ($i=0;$i< $p_article;$i++) {
00174
00175
00176 $march=(isset(${"e_march$i"}))?${"e_march$i"}:"";
00177 $march_sell=(isset(${"e_march".$i."_sell"}))?${"e_march".$i."_sell"}:"";
00178 $march_tva_id=(isset(${"e_march$i"."_tva_id"}))?${"e_march$i"."_tva_id"}:"";
00179
00180 $march_tva_label="";
00181 $march_label="";
00182
00183
00184
00185 if ( isNumber($march) == 1 ) {
00186 if ( isFicheOfJrn($p_cn,$p_jrn,$march,'cred') == 0 ) {
00187 $msg="Fiche inexistante !!! ";
00188 echo_error($msg); echo_error($msg);
00189 echo "<SCRIPT>alert('$msg');</SCRIPT>";
00190 $march="";
00191 } else {
00192
00193
00194 $a_fiche=GetFicheAttribut($p_cn, $march);
00195 if ( $a_fiche != null ) {
00196 if ( $march_tva_id == "" ) {
00197 $march_tva_id=$a_fiche['tva_id'];
00198 $march_tva_label=$a_fiche['tva_label'];
00199 }
00200 $march_label=$a_fiche['vw_name'];
00201 }
00202 }
00203 }
00204
00205
00206 $W1=new widget("js_search");
00207 $W1->label="";
00208 $W1->name="e_march".$i;
00209 $W1->value=$march;
00210 $W1->extra='cred';
00211 $W1->extra2=$p_jrn;
00212 $W1->readonly=$pview_only;
00213 $r.="<TR>".$W1->IOValue()."</TD>";
00214 $Span=new widget ("span");
00215 $Span->SetReadOnly($pview_only);
00216
00217
00218 $r.="<TD>".$Span->IOValue("e_march".$i."_label",$march_label)."</TD>";
00219
00220 $Price=new widget("text");
00221 $Price->SetReadOnly($pview_only);
00222 $Price->table=1;
00223 $r.=$Price->IOValue("e_march".$i."_sell",$march_sell);
00224
00225
00226 $select_tva=make_array($p_cn,"select tva_id,tva_label from tva_rate order by tva_id",1);
00227 $Tva=new widget("select");
00228 $Tva->table=1;
00229 $Tva->selected=$march_tva_id;
00230 $r.=$Tva->IOValue("e_march$i"."_tva_id",$select_tva);
00231
00232
00233
00234 $quant=(isset(${"e_quant$i"}))?${"e_quant$i"}:"1";
00235 $Quantity=new widget("text");
00236 $Quantity->SetReadOnly($pview_only);
00237 $Quantity->table=1;
00238
00239 $r.=$Quantity->IOValue("e_quant".$i,$quant);
00240 $r.='</TR>';
00241 }
00242
00243
00244
00245 $r.="</TABLE>";
00246 $r.="<hr>";
00247
00248 $h=new widget('hidden');
00249 $h->name='jrn_type';
00250 $h->value='VEN';
00251 $r.=$h->IOValue();
00252
00253 if ($pview_only == false ) {
00254 $r.='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout article" TABINDEX="32767">';
00255 $r.='<INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Enregistrer" TABINDEX="32767" ID="SubmitButton">';
00256 $r.="</DIV>";
00257 $r.="</FORM>";
00258 $r.=JS_CALC_LINE;
00259 } else {
00260 $r.="</div>";
00261
00262 }
00263
00264
00265
00266 return $r;
00267
00268
00269 }
00284 function form_verify_input($p_cn,$p_jrn,$p_periode,$p_array,$p_number)
00285 {
00286 foreach ($p_array as $name=>$content) {
00287 ${"$name"}=$content;
00288 }
00289
00290 if ( isDate($e_date) == null ) {
00291 echo_error("Invalid date $e_date");
00292 echo_debug('user_form_ven.php',__LINE__,"Invalid date $e_date");
00293 echo "<SCRIPT> alert('INVALID DATE $e_date !!!!');</SCRIPT>";
00294 return null;
00295 }
00296
00297 for ($o = 0;$o < $p_number; $o++) {
00298 if ( isNumber(${"e_quant$o"}) == 0 ) {
00299 echo_debug('user_form_ven.php',__LINE__,"invalid quantity ".${"e_quant$o"});
00300 echo_error("invalid quantity ".${"e_quant$o"});
00301 echo "<SCRIPT> alert('INVALID QUANTITY !!!');</SCRIPT>";
00302 return null;
00303 }
00304
00305 if ( strlen(trim(${"e_march$o"."_tva_id"})) !=0
00306 and
00307 ${"e_march$o"."_tva_id"} != "-1")
00308 {
00309
00310 if (isNumber(${"e_march$o"."_tva_id"}) == 0
00311 or CountSql($p_cn,"select tva_id from tva_rate where tva_id=".${"e_march$o"."_tva_id"}) ==0)
00312 {
00313 $msg="Invalid TVA !!! e_march".$o."_tva_id = ".${"e_march".$o."_tva_id"};
00314 echo_error($msg); echo_error($msg);
00315 echo "<SCRIPT>alert('$msg');</SCRIPT>";
00316 return null;
00317
00318 }
00319 }
00320
00321 }
00322
00323
00324 if (strlen($e_ech) != 0 and isNumber($e_ech) == 0 and isDate ($e_ech) == null ) {
00325 $msg="Echeance invalide";
00326 echo_error($msg); echo_error($msg);
00327 echo "<SCRIPT>alert('$msg');</SCRIPT>";
00328 return null;
00329 }
00330
00331
00332 if ( strlen($e_ech) != 0 and isNumber($e_ech) == 1) {
00333 list($day,$month,$year)=explode(".",$e_date);
00334 echo_debug('user_form_ven.php',__LINE__," date $e_date = $day.$month.$year");
00335 $p_ech=date('d.m.Y',mktime(0,0,0,$month,$day+$e_ech,$year));
00336 echo_debug('user_form_ven.php',__LINE__,"p_ech = $e_ech $p_ech");
00337 $e_ech=$p_ech;
00338 $wHidden=new widget("hidden");
00339 $data.=$wHidden->IOValue("e_ech",$e_ech);
00340 }
00341
00342
00343 if (IsFicheOfJrn($p_cn , $p_jrn, $e_client,'deb') == 0 )
00344 {
00345 $msg="Client invalid please recheck";
00346 echo_error($msg);
00347 echo "<SCRIPT>alert('$msg');</SCRIPT>";
00348 return null;
00349 }
00350
00351
00352 for ($i=0;$i<$p_number;$i++) {
00353 if ( trim(${"e_march$i"}) == "" ) {
00354
00355 continue;
00356 }
00357
00358
00359
00360 if ( isFicheOfJrn($p_cn,$p_jrn,${"e_march$i"},'cred') == 0 ) {
00361 $msg="Fiche inexistante !!! ";
00362 echo_error($msg); echo_error($msg);
00363 echo "<SCRIPT>alert('$msg');</SCRIPT>";
00364 return null;
00365 }
00366
00367 $poste=GetFicheAttribut($p_cn,${"e_march$i"},ATTR_DEF_ACCOUNT);
00368 if ( $poste == null )
00369 {
00370 $msg="La fiche ".${"e_march$i"}." n\'a pas de poste comptable";
00371 echo_error($msg); echo_debug('user_form_ven.php',__LINE__,$msg);
00372 echo "<SCRIPT>alert('$msg');</SCRIPT>";
00373 return null;
00374
00375 }
00376 if ( strlen(trim($poste))==0 )
00377 {
00378 $msg="La fiche ".$tiers." n\'a pas de poste comptable";
00379 echo_error($msg); echo_debug('user_form_ven.php',__LINE__,$msg);
00380 echo "<SCRIPT>alert('$msg');</SCRIPT>";
00381 }
00382
00383 }
00384
00385
00386
00387 list ($l_date_start,$l_date_end)=GetPeriode($p_cn,$p_periode);
00388
00389
00390 echo_debug ('user_form_ven',__LINE__,"date start periode $l_date_start date fin periode $l_date_end date demande $e_date");
00391 if ( cmpDate($e_date,$l_date_start)<0 ||
00392 cmpDate($e_date,$l_date_end)>0 )
00393 {
00394 $msg="Not in the active periode please change your preference";
00395 echo_error($msg); echo_error($msg);
00396 echo "<SCRIPT>alert('$msg');</SCRIPT>";
00397 return null;
00398 }
00399
00400 if ( PeriodeClosed ($p_cn,$p_periode)=='t' )
00401 {
00402 $msg="This periode is closed please change your preference";
00403 echo_error($msg); echo_error($msg);
00404 echo "<SCRIPT>alert('$msg');</SCRIPT>";
00405 return null;
00406 }
00407 return true;
00408 }
00425 function FormVenteView ($p_cn,$p_jrn,$p_periode,$p_array,$p_number,$p_doc='form',$p_comment='')
00426 {
00427 $r="";
00428 $data="";
00429
00430
00431 $hidden=new widget("hidden");
00432 foreach ($p_array as $name=>$content) {
00433 $data.=$hidden->IOValue($name,$content);
00434 ${"$name"}=$content;
00435 }
00436
00437
00438 $r.='<TABLE>';
00439
00440 $r.="<tr>";
00441 $r.="<TD>Date : $e_date</TD>";
00442 $r.="</tr>";
00443
00444 $r.="<tr>";
00445 $r.="<TD>Client : ".getFicheName($p_cn,$e_client)."</TD>";
00446 $r.="</tr>";
00447
00448
00449 $r.="<tr>";
00450 $r.="<TD> Echeance : $e_ech </TD>";
00451 $r.="</tr>";
00452
00453 $r.="<tr>";
00454 $r.="<TD> Description : $e_comm</TD>";
00455 $r.="</tr>";
00456
00457 $sum_with_vat=0.0;
00458 $sum_march=0.0;
00459
00460 $r.="<TR>";
00461 $r.="<TH>Article</TH>";
00462 $r.="<TH>quantité</TH>";
00463 $r.="<TH>prix unit.</TH>";
00464 $r.="<TH>taux tva</TH>";
00465 $r.="<TH>Montant HTVA</TH>";
00466 $r.="<TH>Montant TVA</TH>";
00467 $r.="<TH>Total</TH>";
00468 $r.="</TR>";
00469 for ($i=0;$i<$p_number;$i++) {
00470 if ( trim(${"e_march$i"}) == "" ) {
00471
00472 continue;
00473 }
00474
00475
00476 $fiche_name=getFicheName($p_cn,${"e_march$i"});
00477
00478
00479 $fiche_quant=${"e_quant$i"};
00480
00481
00482 if ( $fiche_quant == 0.0 ) continue;
00483
00484
00485
00486 if ( isNumber(${"e_march$i"."_sell"}) == 0 ) {
00487 $fiche_price=getFicheAttribut($p_cn,${"e_march$i"},ATTR_DEF_PRIX_VENTE);
00488 } else {
00489 $fiche_price=${"e_march$i"."_sell"};
00490 }
00491
00492
00493
00494 $vat=(isNumber(${"e_march$i"."_tva_id"})==0)?getFicheAttribut($p_cn,${"e_march$i"},ATTR_DEF_TVA):${"e_march$i"."_tva_id"};
00495
00496
00497
00498 $a_vat=GetTvaRate($p_cn,$vat);
00499 if ( $a_vat == null ) {
00500 $vat_label="";
00501 $vat_rate=0.0;
00502 } else {
00503 $vat_label=$a_vat['tva_label'];
00504 $vat_rate=$a_vat['tva_rate'];
00505 }
00506
00507
00508 $fiche_sum=$fiche_price*$fiche_quant;
00509
00510 $sum_march+=$fiche_sum;
00511
00512 $fiche_amount_vat=$fiche_price*$fiche_quant*$vat_rate;
00513
00514 $fiche_with_vat=$fiche_price*$fiche_quant*(1+$vat_rate);
00515
00516 $sum_with_vat+=$fiche_with_vat;
00517
00518 $r.='<TR>';
00519 $r.='<TD>'.$fiche_name.'</TD>';
00520 $r.='<TD ALIGN="CENTER">'.$fiche_quant.'</TD>';
00521 $r.='<TD ALIGN="right">'.$fiche_price.'</TD>';
00522 $r.="<TD ALIGN=\"RIGHT\"> $vat_label </TD>";
00523 $r.='<TD ALIGN="RIGHT">'.round($fiche_sum,2).'</TD>';
00524 $r.='<TD ALIGN="RIGHT">'.round($fiche_amount_vat,2).'</TD>';
00525
00526 $r.='<TD>'.round($fiche_with_vat,2).'</TD>';
00527
00528 $r.="</TR>";
00529 }
00530
00531
00532 $r.='</TABLE> ';
00533 $r.='<DIV style="padding:30px;font-size:14px">';
00534 $r.="Total HTVA =".round( $sum_march,2)." <br>";
00535 $r.="Total = ".round($sum_with_vat,2);
00536
00537
00538 $r.="</DIV>";
00539 if ( $p_doc == 'form' ) {
00540
00541 $href=$_SERVER['SCRIPT_NAME'];
00542 switch ($href)
00543 {
00544
00545 case '/user_jrn.php':
00546 $href="user_jrn.php?action=record&p_jrn=$p_jrn";
00547 break;
00548 case '/commercial.php':
00549 $href="commercial.php?p_action=facture&sa=record&p_jrn=$p_jrn";
00550 break;
00551 default:
00552 echo_error('user_form_ven.php',__LINE__,'Erreur invalid request uri');
00553 exit (-1);
00554 }
00555
00556
00557 $r.='<FORM METHOD="POST" enctype="multipart/form-data" ACTION="'.$href.'">';
00558
00559
00560 $file=new widget("file");
00561 $file->table=1;
00562 $r.="<hr>";
00563 $r.= "<table>";
00564 $r.="<TR>".$file->IOValue("pj","","Pièce justificative")."</TR>";
00565 $r.="</table>";
00566 $r.="<hr>";
00567
00568
00569
00570 if ( $_SERVER['SCRIPT_NAME'] == '/commercial.php')
00571 {
00572
00573 if ( CountSql($p_cn,
00574 "select md_id,md_name from document_modele where md_type=4") > 0 )
00575 {
00576 $r.='Générer une facture <input type="checkbox" name="gen_invoice" CHECKED>';
00577
00578 $doc_gen=new widget("select");
00579 $doc_gen->name="gen_doc";
00580 $doc_gen->value=make_array($p_cn,
00581 "select md_id,md_name from document_modele where md_type=4");
00582 $r.=$doc_gen->IOValue();
00583
00584 $r.="<hr>";
00585 }
00586 }
00587
00588
00589 $r.=$data;
00590 if ( $sum_with_vat != 0 ) {
00591 $r.='<INPUT TYPE="SUBMIT" name="record_and_print_invoice" value="Sauver" >';
00592 }
00593 $r.='<INPUT TYPE="SUBMIT" name="correct_new_invoice" value="Corriger">';
00594
00595 $r.='</FORM>';
00596 }
00597 return $r;
00598
00599 }
00600
00627 function RecordInvoice($p_cn,$p_array,$p_user,$p_jrn)
00628 {
00629 foreach ( $p_array as $v => $e)
00630 {
00631 ${"$v"}=$e;
00632 }
00633
00634
00635 $periode=$p_user->GetPeriode();
00636 $amount=0.0;
00637 $amount_jrn=0.0;
00638
00639
00640 for ($i=0;$i<$nb_item;$i++) {
00641
00642 $a_good[$i]=${"e_march$i"};
00643 $a_quant[$i]=${"e_quant$i"};
00644 $a_price[$i]=0;
00645 $a_vat[$i]=${"e_march$i"."_tva_id"};
00646
00647 if ( isNumber(${"e_march$i"."_sell"}) == 0 ) {
00648 if ( $a_good[$i] != "" ) {
00649
00650 $a_price[$i]=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_PRIX_VENTE);
00651 }
00652 } else {
00653
00654 $a_price[$i]=${"e_march$i"."_sell"};
00655 }
00656 $cost=$a_price[$i]*$a_quant[$i];
00657 $amount+=$cost;
00658 $amount_jrn+=$cost;
00659 }
00660
00661 $comm=FormatString($e_comm);
00662
00663
00664 $a_vat_new=ComputeTotalVat($p_cn,$a_good,$a_quant,$a_price,$a_vat);
00665 $sum_vat=0.0;
00666 if ( $a_vat_new != null ){
00667 foreach ( $a_vat_new as $element => $t) {
00668 echo_debug('user_form_ven.php',__LINE__," a_vat element $element t $t");
00669 $sum_vat+=$t;
00670 echo_debug('user_form_ven.php',__LINE__,"sum_vat = $sum_vat");
00671 }
00672 }
00673
00674
00675
00676 $seq=NextSequence($p_cn,'s_grpt');
00677
00678
00679
00680 $poste=GetFicheAttribut($p_cn,$e_client,ATTR_DEF_ACCOUNT);
00681 StartSql($p_cn);
00682 $r=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,round($amount,2)+round($sum_vat,2),$seq,$periode);
00683 if ( $r == false) { $Rollback($p_cn);exit("error 'user_form_ven.php' __LINE__");}
00684
00685
00686 for ( $i = 0; $i < $nb_item;$i++) {
00687 if ( $a_good[$i] == "" ) continue;
00688 $poste=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_ACCOUNT);
00689
00690
00691 if ( $a_price[$i]*$a_quant[$i] == 0 ) continue;
00692
00693
00694 $j_id=InsertJrnx($p_cn,'c',$p_user->id,$p_jrn,$poste,$e_date,round($a_price[$i]*$a_quant[$i],2),$seq,$periode);
00695 if ( $j_id == false) { $Rollback($p_cn);exit("error 'user_form_ven.php' __LINE__");}
00696
00697 if ( InsertStockGoods($p_cn,$j_id,$a_good[$i],$a_quant[$i],'c') == false ) {
00698 $Rollback($p_cn);exit("error 'user_form_ven.php' __LINE__");}
00699 }
00700
00701
00702
00703 if ( $a_vat_new != null )
00704
00705 {
00706 foreach ($a_vat_new as $tva_id => $tva_amount ) {
00707 $poste=GetTvaPoste($p_cn,$tva_id,'c');
00708 if ($tva_amount == 0 ) continue;
00709 $r=InsertJrnx($p_cn,'c',$p_user->id,$p_jrn,$poste,$e_date,round($tva_amount,2),$seq,$periode);
00710 if ( $r == false ) { Rollback($p_cn); exit(" Error 'user_form_ven.php' __LINE__");}
00711
00712 }
00713 }
00714 echo_debug('user_form_ven.php',__LINE__,"echeance = $e_ech");
00715 $r=InsertJrn($p_cn,$e_date,$e_ech,$p_jrn,"Invoice",round($amount_jrn,2)+round($sum_vat,2),$seq,$periode);
00716 if ( $r == false ) { Rollback($p_cn); exit(" Error 'user_form_ven.php' __LINE__");}
00717
00718 $internal=SetInternalCode($p_cn,$seq,$p_jrn);
00719 $comment=(FormatString($e_comm) == null )?$internal." client : ".GetFicheName($p_cn,$e_client):FormatString($e_comm);
00720
00721
00722 $Res=ExecSql($p_cn,"update jrn set jr_comment='".$comment."' where jr_grpt_id=".$seq);
00723 if ( $Res == false ) { Rollback($p_cn); exit(" Error 'user_form_ven.php' __LINE__"); };
00724
00725 if ( isset ($_FILES)) {
00726 if ( sizeof($_FILES) != 0 )
00727 save_upload_document($p_cn,$seq);
00728 }
00729
00730
00731 for ( $i=0;$i < $nb_item;$i++)
00732 {
00733
00734 if ( $a_price[$i]*$a_quant[$i] == 0 ) continue;
00735
00736
00737
00738 if ( $a_vat[$i] == -1) {
00739 $computed_vat=0;
00740 $vat_code="null";
00741 } else {
00742 $computed_vat=ComputeVat($p_cn,$a_good[$i],$a_quant[$i],$a_price[$i],$a_vat[$i]);
00743 $vat_code=$a_vat[$i];
00744 }
00745 $r=ExecSql($p_cn,"select insert_quant_sold ".
00746 "('".$internal."','".$a_good[$i]."',".$a_quant[$i].",".$a_price[$i]*$a_quant[$i].
00747 ",".$computed_vat.
00748 ",".$vat_code.",'".$e_client."')");
00749 if ( $r == false ) { Rollback($p_cn); exit(" Error 'user_form_ven.php' __LINE__"); };
00750 }
00751 Commit($p_cn);
00752 return array($internal,$comment);
00753 }
00754
00755 ?>