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




//===========================Category================================================
$query_data="select *
                from t_".$key_table_prefix."_setting
                
                 ";
			  //where client_id = '".$client_id."'
$result_data = mysqli_query($dbconn,$query_data);
while($line_data= mysqli_fetch_array($result_data,MYSQLI_ASSOC))
{
                
                                                         
echo "<setting>
";
echo "<internal_inventory_management_with_stock_posting>".str_replace("&","&amp;",$line_data["set_module_internal_inventory_management_with_stock_posting"])."</internal_inventory_management_with_stock_posting>
";


echo "<stock_picking_exact_quantity>".str_replace("&","&amp;",$line_data["set_stock_picking_exact_quantity"])."</stock_picking_exact_quantity>
";

echo "<stock_in_use_cost>".str_replace("&","&amp;",$line_data["set_stock_in_use_cost"])."</stock_in_use_cost>
";

echo "<stock_out_use_cost>".str_replace("&","&amp;",$line_data["set_stock_out_use_cost"])."</stock_out_use_cost>
";

echo "<stock_transfer_use_cost>".str_replace("&","&amp;",$line_data["set_stock_transfer_use_cost"])."</stock_transfer_use_cost>
";

echo "</setting>
";

                
}





//===========================Device User================================================
$query_data="select *
                from t_".$key_table_prefix."_user_device
                where dusr_inventory_app = 'YES'
                 ";
			  //where client_id = '".$client_id."'
$result_data = mysqli_query($dbconn,$query_data);
while($line_data= mysqli_fetch_array($result_data,MYSQLI_ASSOC))
{
                
                                                         
echo "<user>
";
echo "<name>".str_replace("&","&amp;",$line_data["dusr_name"])."</name>
";
echo "<full_name>".str_replace("&","&amp;",$line_data["dusr_full_name"])."</full_name>
";


echo "<password>".str_replace("&","&amp;",$line_data["dusr_password"])."</password>
";

echo "<group>".str_replace("&","&amp;",$line_data["dusr_group"])."</group>
";







echo "<ivt_stock_out>".str_replace("&","&amp;",$line_data["dusr_inventory_stock_out"])."</ivt_stock_out>
";

echo "<ivt_stock_in>".str_replace("&","&amp;",$line_data["dusr_inventory_stock_in"])."</ivt_stock_in>
";

echo "<ivt_stock_transfer>".str_replace("&","&amp;",$line_data["dusr_inventory_stock_transfer"])."</ivt_stock_transfer>
";


echo "<ivt_picking>".str_replace("&","&amp;",$line_data["dusr_inventory_picking"])."</ivt_picking>
";

echo "<ivt_check_in>".str_replace("&","&amp;",$line_data["dusr_inventory_check_in"])."</ivt_check_in>
";

echo "<ivt_check_out>".str_replace("&","&amp;",$line_data["dusr_inventory_check_out"])."</ivt_check_out>
";

echo "<ivt_internal_use>".str_replace("&","&amp;",$line_data["dusr_inventory_internal_use"])."</ivt_internal_use>
";

echo "<ivt_count>".str_replace("&","&amp;",$line_data["dusr_inventory_count"])."</ivt_count>
";





echo "<created_date>".str_replace("&","&amp;",$line_data["created_date"])."</created_date>
";

echo "<modified_date>".str_replace("&","&amp;",$line_data["modified_date"])."</modified_date>
";

echo "</user>
";

                
}





//===========================Product================================================
$query_data="select *
                from t_".$key_table_prefix."_product
                
                 ";
			  
			  //where client_id = '".$client_id."'
$result_data = mysqli_query($dbconn,$query_data);
while($line_data= mysqli_fetch_array($result_data,MYSQLI_ASSOC))
{
                
    $product_data[$line_data["pdt_id"]] = $line_data["pdt_code"];
                                                         
echo "<product>
";
echo "<code>".str_replace("&","&amp;",$line_data["pdt_code"])."</code>
";

echo "<barcode>".str_replace("&","&amp;",$line_data["pdt_barcode"])."</barcode>
";

echo "<category_code>".str_replace("&","&amp;",$line_data["pdt_category_code"])."</category_code>
";


echo "<menu_group_code>".str_replace("&","&amp;",$line_data["pdt_menu_group_code"])."</menu_group_code>
";


echo "<name>".str_replace("&","&amp;",$line_data["pdt_name"])."</name>
";



echo "<uom>".str_replace("&","&amp;",$line_data["pdt_uom"])."</uom>
";



echo "<price>".str_replace("&","&amp;",$line_data["pdt_price"])."</price>
";

echo "<price_2>".str_replace("&","&amp;",$line_data["pdt_price_2"])."</price_2>
";

echo "<price_3>".str_replace("&","&amp;",$line_data["pdt_price_3"])."</price_3>
";

echo "<price_4>".str_replace("&","&amp;",$line_data["pdt_price_4"])."</price_4>
";

echo "<price_5>".str_replace("&","&amp;",$line_data["pdt_price_5"])."</price_5>
";



echo "<discount_allow>".str_replace("&","&amp;",$line_data["pdt_discount_allow"])."</discount_allow>
";


echo "<cost>".str_replace("&","&amp;",$line_data["pdt_cost"])."</cost>
";


echo "<price_group1>".str_replace("&","&amp;",$line_data["pdt_price_group_1"])."</price_group1>
";
echo "<price_group2>".str_replace("&","&amp;",$line_data["pdt_price_group_2"])."</price_group2>
";
echo "<price_group3>".str_replace("&","&amp;",$line_data["pdt_price_group_3"])."</price_group3>
";
echo "<price_group4>".str_replace("&","&amp;",$line_data["pdt_price_group_4"])."</price_group4>
";
echo "<price_group5>".str_replace("&","&amp;",$line_data["pdt_price_group_5"])."</price_group5>
";






echo "<scale_price_1>".str_replace("&","&amp;",$line_data["pdt_scale_price_1"])."</scale_price_1>
";
echo "<scale_price_2>".str_replace("&","&amp;",$line_data["pdt_scale_price_2"])."</scale_price_2>
";
echo "<scale_price_3>".str_replace("&","&amp;",$line_data["pdt_scale_price_3"])."</scale_price_3>
";
echo "<scale_price_4>".str_replace("&","&amp;",$line_data["pdt_scale_price_4"])."</scale_price_4>
";
echo "<scale_price_5>".str_replace("&","&amp;",$line_data["pdt_scale_price_5"])."</scale_price_5>
";




echo "<scale_price_1_min_qty>".str_replace("&","&amp;",$line_data["pdt_scale_price_1_min_qty"])."</scale_price_1_min_qty>
";
echo "<scale_price_2_min_qty>".str_replace("&","&amp;",$line_data["pdt_scale_price_2_min_qty"])."</scale_price_2_min_qty>
";
echo "<scale_price_3_min_qty>".str_replace("&","&amp;",$line_data["pdt_scale_price_3_min_qty"])."</scale_price_3_min_qty>
";
echo "<scale_price_4_min_qty>".str_replace("&","&amp;",$line_data["pdt_scale_price_4_min_qty"])."</scale_price_4_min_qty>
";
echo "<scale_price_5_min_qty>".str_replace("&","&amp;",$line_data["pdt_scale_price_5_min_qty"])."</scale_price_5_min_qty>
";











echo "<gst_code>".str_replace("&","&amp;",$line_data["pdt_gst_code"])."</gst_code>
";


echo "<gst_mode>".str_replace("&","&amp;",$line_data["pdt_gst_mode"])."</gst_mode>
";


if($line_data["pdt_inventory_tracking"]=="YES")
{
	if(isset($stock_balance[$line_data["pdt_code"]]))
	{
		echo "<balance>".str_replace("&","&amp;",$stock_balance[$line_data["pdt_code"]])."</balance>
		";
		
	}
	else {
		echo "<balance>0</balance>
		";	
	}

}
else {
	echo "<balance>0</balance>
	";	
}



echo "<supplier>".str_replace("&","&amp;",$line_data["pdt_supplier"])."</supplier>
";


echo "<brand>".str_replace("&","&amp;",$line_data["pdt_brand"])."</brand>
";


echo "<select_color>".str_replace("&","&amp;",$line_data["pdt_select_color"])."</select_color>
";

echo "<select_size>".str_replace("&","&amp;",$line_data["pdt_select_size"])."</select_size>
";

echo "<select_pattern>".str_replace("&","&amp;",$line_data["pdt_select_pattern"])."</select_pattern>
";


echo "<featured>".str_replace("&","&amp;",$line_data["pdt_featured"])."</featured>
";



echo "<decimal_quantity>".str_replace("&","&amp;",$line_data["pdt_decimal_quantity"])."</decimal_quantity>
";





echo "<category_1>".str_replace("&","&amp;",$line_data["pdt_category_1"])."</category_1>
";

echo "<category_2>".str_replace("&","&amp;",$line_data["pdt_category_2"])."</category_2>
";

echo "<category_3>".str_replace("&","&amp;",$line_data["pdt_category_3"])."</category_3>
";

echo "<status>".str_replace("&","&amp;",$line_data["pdt_status"])."</status>
";


echo "<inventory_tracking>".str_replace("&","&amp;",$line_data["pdt_inventory_tracking"])."</inventory_tracking>
";

echo "<created_date>".str_replace("&","&amp;",$line_data["created_date"])."</created_date>
";

echo "<modified_date>".str_replace("&","&amp;",$line_data["modified_date"])."</modified_date>
";








echo "</product>
";

                
}








 


//===========================Category================================================
$query_data="select *
                from t_".$key_table_prefix."_category
                
                 ";
			  //where client_id = '".$client_id."'
$result_data = mysqli_query($dbconn,$query_data);
while($line_data= mysqli_fetch_array($result_data,MYSQLI_ASSOC))
{
                
                                                         
echo "<category>
";
echo "<code>".str_replace("&","&amp;",$line_data["cat_code"])."</code>
";
echo "<name>".str_replace("&","&amp;",$line_data["cat_name"])."</name>
";
echo "<sorting>".str_replace("&","&amp;",$line_data["cat_sorting"])."</sorting>
";

echo "<status>".str_replace("&","&amp;",$line_data["cat_status"])."</status>
";

echo "<created_date>".str_replace("&","&amp;",$line_data["created_date"])."</created_date>
";

echo "<modified_date>".str_replace("&","&amp;",$line_data["modified_date"])."</modified_date>
";

echo "</category>
";

                
}





//===========================Color================================================
$query_data="select *
                from t_".$key_table_prefix."_color
                
                 ";
			  //where client_id = '".$client_id."'
$result_data = mysqli_query($dbconn,$query_data);
while($line_data= mysqli_fetch_array($result_data,MYSQLI_ASSOC))
{
                
                                                         
echo "<color>
";
echo "<code>".str_replace("&","&amp;",$line_data["clr_code"])."</code>
";
echo "<name>".str_replace("&","&amp;",$line_data["clr_name"])."</name>
";
echo "<status>".str_replace("&","&amp;",$line_data["clr_status"])."</status>
";

echo "<created_date>".str_replace("&","&amp;",$line_data["created_date"])."</created_date>
";

echo "<modified_date>".str_replace("&","&amp;",$line_data["modified_date"])."</modified_date>
";

echo "</color>
";

                
}



//===========================Size================================================
$query_data="select *
                from t_".$key_table_prefix."_size
                
                 ";
			  //where client_id = '".$client_id."'
$result_data = mysqli_query($dbconn,$query_data);
while($line_data= mysqli_fetch_array($result_data,MYSQLI_ASSOC))
{
                
                                                         
echo "<size>
";
echo "<code>".str_replace("&","&amp;",$line_data["siz_code"])."</code>
";
echo "<name>".str_replace("&","&amp;",$line_data["siz_name"])."</name>
";
echo "<status>".str_replace("&","&amp;",$line_data["siz_status"])."</status>
";

echo "<created_date>".str_replace("&","&amp;",$line_data["created_date"])."</created_date>
";

echo "<modified_date>".str_replace("&","&amp;",$line_data["modified_date"])."</modified_date>
";

echo "</size>
";

                
}






//===========================Pattern================================================
$query_data="select *
                from t_".$key_table_prefix."_pattern
                
                 ";
			  //where client_id = '".$client_id."'
$result_data = mysqli_query($dbconn,$query_data);
while($line_data= mysqli_fetch_array($result_data,MYSQLI_ASSOC))
{
                
                                                         
echo "<pattern>
";
echo "<code>".str_replace("&","&amp;",$line_data["ptn_code"])."</code>
";
echo "<name>".str_replace("&","&amp;",$line_data["ptn_name"])."</name>
";
echo "<status>".str_replace("&","&amp;",$line_data["ptn_status"])."</status>
";

echo "<created_date>".str_replace("&","&amp;",$line_data["created_date"])."</created_date>
";

echo "<modified_date>".str_replace("&","&amp;",$line_data["modified_date"])."</modified_date>
";

echo "</pattern>
";

                
}




//===========================Customer================================================
$query_data="select *
                from t_".$key_table_prefix."_customer
                
                 ";
			  //where client_id = '".$client_id."'
$result_data = mysqli_query($dbconn,$query_data);
while($line_data= mysqli_fetch_array($result_data,MYSQLI_ASSOC))
{
                
                                                         
echo "<customer>
";
echo "<code>".str_replace("&","&amp;",$line_data["cus_code"])."</code>
";
echo "<name>".str_replace("&","&amp;",$line_data["cus_name"])."</name>
";
echo "<gst_no>".str_replace("&","&amp;",$line_data["cus_gst_no"])."</gst_no>
";
echo "<ic_no>".str_replace("&","&amp;",$line_data["cus_ic_no"])."</ic_no>
";


echo "<group>".str_replace("&","&amp;",$line_data["cus_group"])."</group>
";

echo "<discount_percentage>".str_replace("&","&amp;",$line_data["cus_discount_percentage"])."</discount_percentage>
";


echo "<address_billing>".str_replace("&","&amp;",$line_data["cus_address_billing"])."</address_billing>
";

echo "<address_delivery>".str_replace("&","&amp;",$line_data["cus_address_delivery"])."</address_delivery>
";




echo "<latitude>".str_replace("&","&amp;",$line_data["cus_latitude"])."</latitude>
";


echo "<longitude>".str_replace("&","&amp;",$line_data["cus_longitude"])."</longitude>
";

echo "<credit_block>".str_replace("&","&amp;",$line_data["cus_credit_block"])."</credit_block>
";


echo "<status>".str_replace("&","&amp;",$line_data["cus_status"])."</status>
";


echo "<validity_start>".str_replace("&","&amp;",$line_data["cus_validity_start"])."</validity_start>
";


echo "<validity_end>".str_replace("&","&amp;",$line_data["cus_validity_end"])."</validity_end>
";


echo "<created_date>".str_replace("&","&amp;",$line_data["created_date"])."</created_date>
";

echo "<modified_date>".str_replace("&","&amp;",$line_data["modified_date"])."</modified_date>
";

echo "</customer>
";

                
}








//===========================Customer================================================
$query_data="select *
                from t_".$key_table_prefix."_vendor
                
                 ";
			  //where client_id = '".$client_id."'
$result_data = mysqli_query($dbconn,$query_data);
while($line_data= mysqli_fetch_array($result_data,MYSQLI_ASSOC))
{
                
                                                         
echo "<vendor>
";
echo "<code>".str_replace("&","&amp;",$line_data["vdr_code"])."</code>
";
echo "<name>".str_replace("&","&amp;",$line_data["vdr_name"])."</name>
";

echo "<gst_no>".str_replace("&","&amp;",$line_data["vdr_gst_no"])."</gst_no>
";



echo "<discount_percentage>".str_replace("&","&amp;",$line_data["vdr_discount_percentage"])."</discount_percentage>
";


echo "<address_billing>".str_replace("&","&amp;",$line_data["vdr_address_billing"])."</address_billing>
";

echo "<address_delivery>".str_replace("&","&amp;",$line_data["vdr_address_delivery"])."</address_delivery>
";





echo "<status>".str_replace("&","&amp;",$line_data["vdr_status"])."</status>
";




echo "<created_date>".str_replace("&","&amp;",$line_data["created_date"])."</created_date>
";

echo "<modified_date>".str_replace("&","&amp;",$line_data["modified_date"])."</modified_date>
";

echo "</vendor>
";

                
}






//===========================GST================================================
$query_data="select *
                from t_".$key_table_prefix."_warehouse
                
                 ";
			  //where client_id = '".$client_id."'
$result_data = mysqli_query($dbconn,$query_data);
while($line_data= mysqli_fetch_array($result_data,MYSQLI_ASSOC))
{
                
                                                         
echo "<warehouse>
";
echo "<code>".str_replace("&","&amp;",$line_data["whs_code"])."</code>
";
echo "<name>".str_replace("&","&amp;",$line_data["whs_name"])."</name>
";


echo "<created_date>".str_replace("&","&amp;",$line_data["created_date"])."</created_date>
";

echo "<modified_date>".str_replace("&","&amp;",$line_data["modified_date"])."</modified_date>
";

echo "</warehouse>
";

                
}







//===========================GST================================================
$query_data="select *
                from t_".$key_table_prefix."_gst
                
                 ";
			  //where client_id = '".$client_id."'
$result_data = mysqli_query($dbconn,$query_data);
while($line_data= mysqli_fetch_array($result_data,MYSQLI_ASSOC))
{
                
                                                         
echo "<gst>
";
echo "<code>".str_replace("&","&amp;",$line_data["gst_code"])."</code>
";
echo "<name>".str_replace("&","&amp;",$line_data["gst_name"])."</name>
";
echo "<percentage>".str_replace("&","&amp;",$line_data["gst_percentage"])."</percentage>
";

echo "<created_date>".str_replace("&","&amp;",$line_data["created_date"])."</created_date>
";

echo "<modified_date>".str_replace("&","&amp;",$line_data["modified_date"])."</modified_date>
";

echo "</gst>
";

                
}
















//===========================Floor================================================
$query_data="select *
                from t_".$key_table_prefix."_floor_plan
                 ";
$result_data = mysqli_query($dbconn,$query_data);
while($line_data= mysqli_fetch_array($result_data,MYSQLI_ASSOC))
{
           $floor_data[$line_data["flr_id"]] = $line_data["flr_name"];     
                                                         
echo "<floor_setting>
";

echo "<name>".str_replace("&","&amp;",$line_data["flr_name"])."</name>
";
echo "<code>".str_replace("&","&amp;",$line_data["flr_code"])."</code>
";
echo "<whse_code>".str_replace("&","&amp;",$line_data["flr_warehouse_code"])."</whse_code>
";
echo "<sort_key>".str_replace("&","&amp;",$line_data["flr_sort_key"])."</sort_key>
";
echo "<status>".str_replace("&","&amp;",$line_data["flr_status"])."</status>
";
echo "<created_date>".str_replace("&","&amp;",$line_data["created_date"])."</created_date>
";
echo "<modified_date>".str_replace("&","&amp;",$line_data["modified_date"])."</modified_date>
";
echo "</floor_setting>
";

                
}









//===========================table ================================================
$query_data="select *
                from t_".$key_table_prefix."_storage_location
                 ";
$result_data = mysqli_query($dbconn,$query_data);
while($line_data= mysqli_fetch_array($result_data,MYSQLI_ASSOC))
{
                
                 
                                                         
echo "<location>
";
echo "<code>".str_replace("&","&amp;",$line_data["loc_code"])."</code>
";
echo "<name>".str_replace("&","&amp;",$line_data["loc_name"])."</name>
";
echo "<floor>".str_replace("&","&amp;",$line_data["loc_floor_code"])."</floor>
";
echo "<position_x>".str_replace("&","&amp;",$line_data["loc_x"])."</position_x>
";
echo "<position_y>".str_replace("&","&amp;",$line_data["loc_y"])."</position_y>
";

echo "<width>".str_replace("&","&amp;",$line_data["loc_width"])."</width>
";
echo "<height>".str_replace("&","&amp;",$line_data["loc_height"])."</height>
";
echo "<shape>".str_replace("&","&amp;",$line_data["loc_shape"])."</shape>
";






echo "<created_date>".str_replace("&","&amp;",$line_data["created_date"])."</created_date>
";
echo "<modified_date>".str_replace("&","&amp;",$line_data["modified_date"])."</modified_date>
";
echo "</location>
";

                
}










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