b374k
m1n1 1.01
Apache
Linux webd001.cluster107.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
uid=2234(oyaide) gid=100(users) groups=100(users)
server ip : 213.186.33.18 | your ip : 216.73.216.159
safemode OFF
 >  / home / oyaide / www / bill / billnew / facturation /
Filename/home/oyaide/www/bill/billnew/facturation/factures_current.php
Size2.57 kb
Permissionrw-r--r--
Owneroyaide : users
Create time03-Nov-2008 15:18
Last modified01-Oct-2006 18:42
Last accessed17-Jun-2009 17:15
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
<?
include_once("../lib/bill.php");
include_once("../tbs/tbs_class.php");
include_once("facturepdf.php");

$customerid=$_GET["customerid"];
$id_line=$_GET['id'];
$action=$_GET['action'];

if ($action=='moveUP') {
$sql="update orders_lines set status=11 where id=$id_line";
$result = mysql_query($sql,$billDBConn);
}
elseif ($action=='moveDN') {
$sql="update orders_lines set status=10 where id=$id_line";

$result = mysql_query($sql,$billDBConn);
}
elseif ($action=='bill') {
$bill=getCurrentBillable($customerid,false);

if ( count($bill)==0 ) die("Il n'y a rien &agrave; facturer !!");



// create new bill
$sql="insert into invoices (id_customer,date) values ($customerid,CURDATE())";
$result = mysql_query($sql,$billDBConn) or die(mysql_error());
$id_invoice=mysql_insert_id();

// copy lines from orders_lines to invoices_lines

for($i=0;$i<count($bill);$i++) {
$keyvals=array(
"id_invoice"=>$id_invoice,
"id_order_line"=>$bill[$i]["id_order_line"],
"description"=>$bill[$i]["description"],
"quantity"=>$bill[$i]["quantity"],
"price"=>$bill[$i]["price"],
"tva_rate"=>$bill[$i]["tva_rate"],
"tva_amt"=>$bill[$i]["tva_amt"]
);

// add line to invoice
$sql=genInsertSQLString("invoices_lines",$keyvals);
$result = mysql_query($sql,$billDBConn) or die($sql."<br>".mysql_error());

// update status of the order line
$sql="update orders_lines set status=20 where status<>21 and id=".$bill[$i]["id_order_line"];
$result = mysql_query($sql,$billDBConn) or die($sql."<br>".mysql_error());

}


// creation de la facture pdf
$texte_echeance=$config["echeance_facture"][$_GET["echeance"]];

$pdfbuffer=addslashes(makeBillPDF($id_invoice,null,$texte_echeance));
$sql="update invoices set pdf='$pdfbuffer' where id=$id_invoice";
$result = mysql_query($sql,$billDBConn) or die($sql."<br>".mysql_error());

// on montre la facture
$javascript="window.open('factures_view.php?id=$id_invoice');";

} // end action=bill



$cust=new customer($customerid);

$tbs = new clsTinyButStrong ;
$tbs->LoadTemplate("factures_current.html");

// liste a facturer
$bill=getCurrentBillable($customerid,false);
$totalbillable=0;
foreach($bill as $value) {
$totalbillable+=$value["total"];
}
$tbs->MergeBlock("rsbill","array",$bill);

// liste en suspens
$bill=getCurrentBillable($customerid,true);
$totalnotbillable=0;
foreach($bill as $value) {
$totalnotbillable+=$value["total"];
}
$tbs->MergeBlock("rsnotbill","array",$bill);
$tbs->MergeBlock('echeances',$config["echeance_facture"]) ;
$tbs->Show();

?>