<?

include getenv("DOCUMENT_ROOT")."/include/session_include.php";

//echo "1111OKKKKKKKKKKKKKKKKKK";exit;


/*
for($i=0; $i<sizeof($_POST); $i++) {
	list($key, $value) = each($_POST);
	$$key = $value;

	if(is_array($value))
	{
		$count = 10;
		for($i = 0; $i < $count; $i ++) {
			if ($value[$i]) echo "ARRAY[$key][$value[$i]]<br>";
		}
	}
	else 	echo "[$key][$value]<br>";
	//print_r($_POST);
}

//exit;
*/


$c_uid = trim($_POST["c_uid"]);
$c_fullcycle = trim($_POST["c_fullcycle"]);

//echo "[$c_uid][$c_fullcycle][$PRDSEQ][$QUANTITY][$ORGQTY]";exit;

if ($c_uid != "" && $c_fullcycle !== "") {

		$qry_org = "SELECT c_fullcycle, c_fullcycleforced, c_fullcycleflag, c_mainvolume 
								FROM tbl_customer WHERE c_uid = '$c_uid' ";
		$rt_org = $jdb->fQuery($qry_org, "query error");
		
		$qry_cycle = "UPDATE tbl_customer 
									SET c_fullcycleforced = $c_fullcycle, c_fullcycleflag = 1, c_forceddate = '".date("Ymd")."' 
									WHERE c_uid = '$c_uid' ";
		$jdb->nQuery($qry_cycle, "update error");

		addLog ("add", "FORCED CYCLE", "UPDATE", $lguserid, $qry_cycle, $c_uid);

		$qry = "SELECT c_fullcycleforced, c_fullcycleflag FROM tbl_customer WHERE c_uid = '$c_uid' ";
		$rt = $jdb->fQuery($qry, "query error");

		if ($c_fullcycle == $rt['c_fullcycleforced'] &&  $rt['c_fullcycleflag'] == 1 )
			echo "OK|$c_fullcycle|".$rt['c_fullcycleforced'];
		else {
			if ($rt_org['c_fullcycleflag'] == 1) echo "ERROR1|".$rt_org['c_fullcycleforced']."|".$rt_org['c_fullcycleforced'];
			else echo "ERROR1|".$rt_org['c_fullcycle']."|0";
		}
}
else
			echo "ERROR2";

?>

