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

/*
`rth_rth_id` int(11) NOT NULL ,
`rth_doc_no` varchar(20) DEFAULT NULL,

`rth_customer_code` varchar(200) DEFAULT NULL,
`rth_customer_name` varchar(200) DEFAULT NULL,
`rth_customer_address_billing` longtext DEFAULT NULL,
`rth_customer_address_delivery` longtext DEFAULT NULL,


`rth_customer_gst_no` varchar(200) DEFAULT NULL,
`rth_customer_discount` varchar(200) DEFAULT NULL,

`rth_date` date DEFAULT NULL,
`rth_discount_total` double(10,2) DEFAULT NULL,
`rth_total_before_gst` double(10,2) DEFAULT NULL,
`rth_gst_amount` double(10,2) DEFAULT NULL,
`rth_total_amount` double(10,2) DEFAULT NULL,
`rth_rounding_amount` double(10,2) DEFAULT NULL,
`rth_total_amount_rounded` double(10,2) DEFAULT NULL,
`rth_payment_amount` double(10,2) DEFAULT NULL,
`rth_change_amount` double(10,2) DEFAULT NULL,


`rth_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."_return_header
                    (
					
					device_id  ,
					rth_doc_no  ,
					
					rth_rth_id  ,
					rth_customer_code  ,
					rth_customer_name  ,
					rth_customer_address_billing  ,
					rth_customer_address_delivery  ,
					rth_customer_gst_no  ,
					rth_customer_discount  ,
					rth_date  ,
					rth_discount_total  ,
					rth_total_before_gst  ,
					rth_gst_amount  ,
					rth_total_amount  ,
					rth_rounding_amount  ,
					rth_total_amount_rounded  ,
					rth_payment_amount  ,
					rth_change_amount  ,
					
					rth_latitude  ,
					rth_longitude  ,
					
					rth_status  ,
					
					
					rth_closing_batch,
					
					created_date ,
					
					modified_date ,
					client_id 
                    )
                    VALUES
                    (
	                    
					
					'".$_REQUEST["device_id"]."',
					'".$_REQUEST["rth_doc_no"]."',
					
					'".$_REQUEST["rth_id"]."',
					'".$_REQUEST["rth_customer_code"]."',
					'".$_REQUEST["rth_customer_name"]."',
					'".$_REQUEST["rth_customer_address_billing"]."',
					'".$_REQUEST["rth_customer_address_delivery"]."',
					'".$_REQUEST["rth_customer_gst_no"]."',
					'".$_REQUEST["rth_customer_discount"]."',
					'".$_REQUEST["rth_date"]."',
					'".($_REQUEST["rth_discount_total"]+0)."',
					'".($_REQUEST["rth_total_before_gst"]+0)."',
					'".($_REQUEST["rth_gst_amount"]+0)."',
					'".($_REQUEST["rth_total_amount"]+0)."',
					'".($_REQUEST["rth_rounding_amount"]+0)."',
					'".($_REQUEST["rth_total_amount_rounded"]+0)."',
					'".($_REQUEST["rth_payment_amount"]+0)."',
					'".($_REQUEST["rth_change_amount"]+0)."',
					
					'".$_REQUEST["rth_latitude"]."',
					'".$_REQUEST["rth_longitude"]."',
					
					'".$_REQUEST["rth_status"]."',
					
					'".$_REQUEST["rth_closing_batch"]."',
					 
					
					'".$_REQUEST["created_date"]."',
					
					'".$_REQUEST["modified_date"]."',
					
	                    '".$client_id."'
                    )
                    ON DUPLICATE KEY UPDATE
				
					rth_rth_id ='".$_REQUEST["rth_id"]."',
					
					rth_customer_code='".$_REQUEST["rth_customer_code"]."',
					rth_customer_name='".$_REQUEST["rth_customer_name"]."',
					rth_customer_address_billing='".$_REQUEST["rth_customer_address_billing"]."',
					rth_customer_address_delivery='".$_REQUEST["rth_customer_address_delivery"]."',
					rth_customer_gst_no='".$_REQUEST["rth_customer_gst_no"]."',
					rth_customer_discount='".$_REQUEST["rth_customer_discount"]."',
					rth_date='".$_REQUEST["rth_date"]."',
					rth_discount_total='".($_REQUEST["rth_discount_total"]+0)."',
					rth_total_before_gst='".($_REQUEST["rth_total_before_gst"]+0)."',
					rth_gst_amount='".($_REQUEST["rth_gst_amount"]+0)."',
					rth_total_amount='".($_REQUEST["rth_total_amount"]+0)."',
					rth_rounding_amount='".($_REQUEST["rth_rounding_amount"]+0)."',
					rth_total_amount_rounded='".($_REQUEST["rth_total_amount_rounded"]+0)."',
					rth_payment_amount='".($_REQUEST["rth_payment_amount"]+0)."',
					rth_change_amount='".($_REQUEST["rth_change_amount"]+0)."',
					rth_status='".$_REQUEST["rth_status"]."',
					
					rth_closing_batch='".$_REQUEST["rth_closing_batch"]."',
					
					
					
					
					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 "<upload>
";
echo "<status>SUCCESS</status>
";
echo "<message>".str_replace("&","&amp;","Upload Successful")."</message>
";
echo "</upload>
";

         


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