<?php
header ("Content-Type:text/xml");
include "start.php";
echo "<psync>";
//---------------------------------------------------------------------------------------------------------

//===========================Product================================================



/*
`ivh_ivh_id` int(11) NOT NULL ,
`ivh_doc_no` varchar(20) DEFAULT NULL,

`ivh_customer_code` varchar(200) DEFAULT NULL,
`ivh_customer_name` varchar(200) DEFAULT NULL,
`ivh_customer_address_billing` longtext DEFAULT NULL,
`ivh_customer_address_delivery` longtext DEFAULT NULL,


`ivh_customer_gst_no` varchar(200) DEFAULT NULL,
`ivh_customer_discount` varchar(200) DEFAULT NULL,

`ivh_date` date DEFAULT NULL,
`ivh_discount_total` double(10,2) DEFAULT NULL,
`ivh_total_before_gst` double(10,2) DEFAULT NULL,
`ivh_gst_amount` double(10,2) DEFAULT NULL,
`ivh_total_amount` double(10,2) DEFAULT NULL,
`ivh_rounding_amount` double(10,2) DEFAULT NULL,
`ivh_total_amount_rounded` double(10,2) DEFAULT NULL,
`ivh_payment_amount` double(10,2) DEFAULT NULL,
`ivh_change_amount` double(10,2) DEFAULT NULL,


`ivh_status` double(10,2) DEFAULT NULL,


`device_id` varchar(200) DEFAULT NULL,



`created_by` int(2) DEFAULT NULL,
`created_date` datetime DEFAULT NULL,
`modified_by` int(2) DEFAULT NULL,
`modified_date` datetime DEFAULT NULL,
`client_id` int(2) DEFAULT NULL,
*/



    $query_sync="INSERT INTO
                    t_".$key_table_prefix."_invoice_header
                    (

					device_id  ,
					ivh_doc_no  ,

					ivh_ivh_id  ,
					ivh_customer_code  ,
					ivh_customer_name  ,
					ivh_customer_address_billing  ,
					ivh_customer_address_delivery  ,
					ivh_customer_gst_no  ,
					ivh_customer_discount  ,
					ivh_date  ,
					ivh_discount_total  ,
					ivh_total_before_gst  ,
					ivh_gst_amount  ,
					ivh_total_amount  ,
					ivh_rounding_amount  ,
					ivh_total_amount_rounded  ,
					ivh_payment_amount  ,
					ivh_change_amount  ,

					ivh_latitude  ,
					ivh_longitude  ,

					ivh_status  ,

					ivh_operation_mode  ,

					ivh_partial_paid  ,
					ivh_amount_paid  ,


					created_date ,

					modified_date ,
					client_id
                    )
                    VALUES
                    (


					'".$_REQUEST["device_id"]."',
					'".$_REQUEST["ivh_doc_no"]."',

					'".$_REQUEST["ivh_id"]."',
					'".$_REQUEST["ivh_customer_code"]."',
					'".$_REQUEST["ivh_customer_name"]."',
					'".$_REQUEST["ivh_customer_address_billing"]."',
					'".$_REQUEST["ivh_customer_address_delivery"]."',
					'".$_REQUEST["ivh_customer_gst_no"]."',
					'".$_REQUEST["ivh_customer_discount"]."',
					'".$_REQUEST["ivh_date"]."',
					'".$_REQUEST["ivh_discount_total"]."',
					'".$_REQUEST["ivh_total_before_gst"]."',
					'".$_REQUEST["ivh_gst_amount"]."',
					'".$_REQUEST["ivh_total_amount"]."',
					'".$_REQUEST["ivh_rounding_amount"]."',
					'".$_REQUEST["ivh_total_amount_rounded"]."',
					'".$_REQUEST["ivh_payment_amount"]."',
					'".$_REQUEST["ivh_change_amount"]."',

					'".$_REQUEST["ivh_latitude"]."',
					'".$_REQUEST["ivh_longitude"]."',

					'".$_REQUEST["ivh_status"]."',

					'".$_REQUEST["ivh_operation_mode"]."',

					'".($_REQUEST["ivh_partial_paid"]+0)."',
					'".($_REQUEST["ivh_amount_paid"]+0)."',


					'".$_REQUEST["created_date"]."',

					'".$_REQUEST["modified_date"]."',

	                    '".$client_id."'
                    )
                    ON DUPLICATE KEY UPDATE

					ivh_ivh_id ='".$_REQUEST["ivh_id"]."',

					ivh_customer_code='".$_REQUEST["ivh_customer_code"]."',
					ivh_customer_name='".$_REQUEST["ivh_customer_name"]."',
					ivh_customer_address_billing='".$_REQUEST["ivh_customer_address_billing"]."',
					ivh_customer_address_delivery='".$_REQUEST["ivh_customer_address_delivery"]."',
					ivh_customer_gst_no='".$_REQUEST["ivh_customer_gst_no"]."',
					ivh_customer_discount='".$_REQUEST["ivh_customer_discount"]."',
					ivh_date='".$_REQUEST["ivh_date"]."',
					ivh_discount_total='".$_REQUEST["ivh_discount_total"]."',
					ivh_total_before_gst='".$_REQUEST["ivh_total_before_gst"]."',
					ivh_gst_amount='".$_REQUEST["ivh_gst_amount"]."',
					ivh_total_amount='".$_REQUEST["ivh_total_amount"]."',
					ivh_rounding_amount='".$_REQUEST["ivh_rounding_amount"]."',
					ivh_total_amount_rounded='".$_REQUEST["ivh_total_amount_rounded"]."',
					ivh_payment_amount='".$_REQUEST["ivh_payment_amount"]."',
					ivh_change_amount='".$_REQUEST["ivh_change_amount"]."',
					ivh_operation_mode='".$_REQUEST["ivh_operation_mode"]."',


					ivh_partial_paid='".($_REQUEST["ivh_partial_paid"]+0)."',
					ivh_amount_paid='".($_REQUEST["ivh_amount_paid"]+0)."',


					ivh_status='".$_REQUEST["ivh_status"]."',
					created_date='".$_REQUEST["created_date"]."',
					modified_date='".$_REQUEST["modified_date"]."',
					client_id = '".$client_id."'

                    ;
                    ";
    $result_sync = mysqli_query($dbconn,$query_sync) or die("Error ".mysqli_error($dbconn));


			echo $query_sync;




echo "<upload>
";
echo "<status>SUCCESS</status>
";
echo "<message>".str_replace("&","&amp;","Upload Successful")."</message>
";
echo "</upload>
";




//---------------------------------------------------------------------------------------------------------
echo "</psync>";
?>
