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