<?php
// PI Count

header('Cache-Control: no-cache, no-store, must-revalidate');   
header('Expires: 0');
set_time_limit(0);

$mHost = "172.16.1.46";
$mUser = "root";
$mPwd = "root";
$mDbName = "vims";

$mConnection=mysqli_connect($mHost,$mUser,$mPwd,$mDbName) or
			exit("FAIL-Connect failed: ".mysqli_connect_errno()." : ". mysqli_connect_error());
			
$mDataQuery = "SELECT * FROM inventory_Master WHERE location_code = 'DOCK1'";
if (!$mData = mysqli_query($mConnection,$mDataQuery))
		return "FAIL-".mysqli_error($mConnection)."-".$mDataQuery;		

while($mRow = mysqli_fetch_assoc($mData))
{
	$mTranQuery = "INSERT INTO transaction_history (id,short_code,part_number,serial_reference,ran_order,scanned_qty,count_qty,from_plt,from_location_code,to_location_code,document_reference,created_by,date_created,last_updated_date,last_updated_by) VALUES(DEFAULT,'RBTD','".($mRow['part_number'])."','".($mRow['serial_reference'])."','".($mRow['ran_order'])."',".($mRow['inventory_qty']).",0,'".($mRow['plt_number'])."','','".($mRow['location_code'])."','','".($mRow['created_by'])."',now(),now(),'".($mRow['created_by'])."')";	
	if (!mysqli_query($mConnection,$mTranQuery))
		return("FAIL-".mysqli_error($mConnection)."-".$mTranQuery);
}

?>					