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
00027
00028
00029
00030
00031
00032
00033 require_once '../include/constant.php';
00034 require_once ('class_database.php');
00035 require_once ('class_acc_compute.php');
00036 require_once('class_dossier.php');
00037 require_once ('class_acc_tva.php');
00038 require_once ('class_user.php');
00039
00040
00041 extract ($_GET);
00042 foreach (array('t','c','p','q','n','gDossier') as $a)
00043 {
00044 if ( ! isset (${$a}) )
00045 {
00046 echo "error $a is not set ";
00047 exit();
00048 }
00049
00050 }
00051 $cn=new Database(dossier::id());
00052 $User=new User($cn);
00053 $User->Check();
00054
00055 if ( $t != -1 && isNumber($t) == 1 )
00056 {
00057 $tva_rate=new Acc_Tva($cn);
00058 $tva_rate->set_parameter('id',$t);
00059
00060
00061
00062 if ( $tva_rate->load() != 0 )
00063 {
00064 $tva_rate->set_parameter('rate',0);
00065 }
00066 }
00067
00068 $total=new Acc_Compute();
00069 bcscale(4);
00070 $amount=round(bcmul($p,$q),2);
00071 $total->set_parameter('amount',$amount);
00072 if ( $t != -1 && isNumber($t) == 1 )
00073 {
00074 $total->set_parameter('amount_vat_rate',$tva_rate->get_parameter('rate'));
00075 $total->compute_vat();
00076 if ($tva_rate->get_parameter('both_side')== 1) $total->set_parameter('amount_vat', 0);
00077 $tvac=($tva_rate->get_parameter('rate') == 0 || $tva_rate->get_parameter('both_side')== 1) ? $amount : bcadd($total->get_parameter('amount_vat'),$amount);
00078 header("Content-type: text/html; charset: utf8",true);
00079 echo '{"ctl":"'.$n.'","htva":"'.$amount.'","tva":"'.$total->get_parameter('amount_vat').'","tvac":"'.$tvac.'"}';
00080 }
00081 else
00082 {
00083
00084 header("Content-type: text/html; charset: utf8",true);
00085 echo '{"ctl":"'.$n.'","htva":"'.$amount.'","tva":"NA","tvac":"'.$amount.'"}';
00086 }
00087 ?>
00088