	<?php
//	
//	include ('settz.php');
	
	$result = '';
	
	$curdate = date("Y-m-d");
	
	 include 'configi.php';
	 
	 $count_web_today = 0;
	 
	 $count_all_today = 0;
	 
	 $count_prog_today = 0;
	 
	 $uid_client = 0;
	 $comp_name = "";
	 $prog_status = 1;
	 $st_table = 0;
	 
	 $s_postline1 = "";
	 $s_postline2 = "";
	 $s_postline2 = "";
	 $s_postline3 = "";
	 $s_postline4 = "";
	 $s_postline5 = "";
	 
	 $a_postline1 = "";
	 $a_postline2 = "";
	 $a_postline2 = "";
	 $a_postline3 = "";
	 $a_postline4 = "";
	 $a_postline5 = "";
	 
	 $s_postcountry		= "";
	 
	 $prog_status		= "";
	 
	 $st_table			= "";
	 
	 $cart_id = $_REQUEST['cart_id'];
	 
	 $sales_cust_disc = 0;
	 
//	 $cart_id = 1687;
	 
	 $querystst="SELECT * from ".$_COOKIE['phxcrmclient_id']."_st where st_id =".$cart_id;
		
	//	echo $querystst;
		$resultstst=mysqli_query($conn, $querystst);
	


		while($querystst=mysqli_fetch_array($resultstst)) { 

			$uid_client			= $querystst['uid_client'];
	//		$prog_status		= $querystst['prog_status'];
			$status				= $querystst['status'];
		//	$st_outlet_id		= $querystst['st_outlet_id'];
	//		$st_table			= $querystst['st_table'];
//			$s_postcountry		= $querystst['s_postcountry'];
			
		//	$sales_cust_disc	= $querystst['sales_cust_disc'];
		
			$job_descr			= htmlspecialchars($querystst['job_descr']);
			$job_descr2			= $querystst['job_descr'];

			
			$s_postline1		= htmlspecialchars($querystst['s_postline1']);
			$s_postline2		= htmlspecialchars($querystst['s_postline2']);
			$s_postline3		= htmlspecialchars($querystst['s_postline3']);
			$s_postline4		= htmlspecialchars($querystst['s_postline4']);
			$s_postline5		= htmlspecialchars($querystst['s_postline5']);
			
			$a_postline1		= htmlspecialchars($querystst['a_postline1']);
			$a_postline2		= htmlspecialchars($querystst['a_postline2']);
			$a_postline3		= htmlspecialchars($querystst['a_postline3']);
			$a_postline4		= htmlspecialchars($querystst['a_postline4']);
			$a_postline5		= htmlspecialchars($querystst['a_postline5']);

			

		}
	 
	 
	 $querystcl="SELECT * from ".$_COOKIE['phxcrmclient_id']."_client where uid_client =".$uid_client;
		
	//	echo $querysttw;
		$resultstcl=mysqli_query($conn, $querystcl);
	


		while($querystcl=mysqli_fetch_array($resultstcl)) { 

			$uid_client			= $querystcl['uid_client'];
			$comp_name			= $querystcl['comp_name'];

		}

	//	$querysttw="SELECT count(*) as count_web_today from ".$_COOKIE['phxcrmclient_id']."_st where DATE_FORMAT(sales_datetime, '%Y-%m-%d') = '".$curdate."' and channel = 'website';";
		
		//echo $querysttw;
//		$resultsttw=mysqli_query($conn, $querysttw);
	


	//	while($querysttw=mysqli_fetch_array($resultsttw)) { 
//
		//	$count_web_today			= $querysttw['count_web_today'];

	//	}
$count_web_today			=  0;

$count_all_today			=  0;
		if ($_COOKIE['phxcrmclient_id'] == 100){
			
		}else{

		$querystta="SELECT count(*) as count_all_today from ".$_COOKIE['phxcrmclient_id']."_jobs_view where status in ('Quote Sent','Quote Draft') or status = 'Work Schd'";
		
	//	echo $querystt;
	
	
	
		$resultstta=mysqli_query($conn, $querystta);
	


		while($querystta=mysqli_fetch_array($resultstta)) { 

			$count_all_today			= $querystta['count_all_today'];

		}

		}


		$count_prog_today			= 0;
		
		if ($_COOKIE['phxcrmclient_id'] == 100){
			
		}else{
		

//		$querystta="SELECT count(*) as count_prog_today from ".$_COOKIE['phxcrmclient_id']."_st where (" . $_COOKIE['phxcrmclient_id'] . "_st.status <> 'Paid' or prog_status <> 1)";
		
		$querystta2 = "SELECT * FROM ".$_COOKIE['phxcrmclient_id']."_jobs_view where st_channel = 2 and ack_by = 0";			
		
	//	echo $querystta;
		$resultstta2=mysqli_query($conn, $querystta2);
	


		while($querystta2=mysqli_fetch_array($resultstta2)) { 

			$count_prog_today			= $querystta2['count_prog_today'];

		}
		

		}	
				$phxcrmclient_id = $_COOKIE['phxcrmclient_id'];
		

		
		$sqlstaff = "SELECT * FROM phx_userid where idphx_userid = " . $phxcrmclient_id;
		
//		echo $sqlstaff;
					

		$resultstaff = $conn->query($sqlstaff);

		if ($resultstaff->num_rows > 0) {
			// output data of each row
			while($rowcompany = $resultstaff->fetch_assoc()) {

				$comp_type2				= $rowcompany["comp_type2"];
				$phx_comp_name			= $rowcompany["comp_name"];
				$phx_username			= $rowcompany["username"];
				
				$comp_phys_addr1		= $rowcompany["comp_phys_addr1"];
				$comp_phys_addr2		= $rowcompany["comp_phys_addr2"];
				$comp_phys_addr3		= $rowcompany["comp_phys_addr3"];
				
				$comp_website_url		= $rowcompany["comp_website_url"];
				$comp_phone				= $rowcompany["comp_phone"];
				
			}
			
		}
		
		//get staff security level
		
		$uid_staff = $_COOKIE['phxcrmuserid'];
		
		
		$querystsec="SELECT * from ".$_COOKIE['phxcrmclient_id']."_staff where uid_staff = ".$uid_staff;
		
		$staff_sec_level = "None"; 
		
	//	echo $querystt;
		$resultstsec=mysqli_query($conn, $querystsec);
	


		while($rowstsec=mysqli_fetch_array($resultstsec)) { 

			$staff_sec_level			= $rowstsec['staff_sec_level'];

		}
		
		
		$sales_cust_disc = 0;
		
		$st_outlet_id = 1;


$job_alert = "";

$outputarray = array('count_prog_today' => $count_prog_today,'count_web_today' => $count_web_today,'count_all_today' => $count_all_today,'uid_client' => $uid_client,'comp_name' => $comp_name,'prog_status' => $prog_status,'st_table' => $st_table,'s_postline1' => $s_postline1,'s_postline2' => $s_postline2,'s_postline3' => $s_postline3,'s_postline4' => $s_postline4,'s_postline5' => $s_postline5,'a_postline1' => $a_postline1,'a_postline2' => $a_postline2,'a_postline3' => $a_postline3,'a_postline4' => $a_postline4,'a_postline5' => $a_postline5,'phx_comp_name' => $phx_comp_name,'phx_username' => $phx_username,
'comp_phys_addr1' => $comp_phys_addr1,'comp_phys_addr2' => $comp_phys_addr2,'comp_phys_addr3' => $comp_phys_addr3,'comp_website_url' => $comp_website_url,'comp_phone' => $comp_phone,'s_postcountry' => $s_postcountry, 'sales_cust_disc' => $sales_cust_disc, 'st_outlet_id' => $st_outlet_id, 'status' => $status, 'staff_sec_level' => $staff_sec_level, 'job_descr' => $job_descr2);

$output2 = json_encode($outputarray);

echo $output2;


			
			?>