	<?php

	$result = '';
	
	$phxcrmclient_id = $_COOKIE['phxcrmclient_id'];
	
	$dept_id = $_REQUEST['dept_id'];
	

	
	$result = '<div class="row">';
	
	$cart_id	= 0;
	
	$postage = 0;
	
	 include 'configi.php';
		$prod_image_url1 = "";
		
		$all_del = 0;
		
		//check if all is selected

		$querystt2 = "SELECT * from ".$phxcrmclient_id."_catpos_sel where cp_sel = 1";

	//	echo $querystt2;
		$resultstt2=mysqli_query($conn, $querystt2);
		
		$cnt = 0;
		

		while($rowstt2=mysqli_fetch_array($resultstt2)) { 

			$cp_cat_id			 			= $rowstt2['cp_cat_id'];
			
			if ($cnt == 0){
			
				$cat_sels		= $cp_cat_id;
			
			}else{
				
				$cat_sels		= $cat_sels.",".$cp_cat_id;
				
			}
			
			$cnt = $cnt + 1;
			
		}


		
		echo "davedave2";
		

		$querystt="SELECT DISTINCT (".$phxcrmclient_id."_prod_search.uid) AS Expr1, ".$phxcrmclient_id."_prodserv.uid, ".$phxcrmclient_id."_prod_category.cat_id, ".$phxcrmclient_id."_prod_search.title, ".$phxcrmclient_id."_prod_search.prod_image_url1, ".$phxcrmclient_id."_prod_search.sku, ".$phxcrmclient_id."_prod_search.price
FROM ((".$phxcrmclient_id."_prodserv INNER JOIN ".$phxcrmclient_id."_prod_dept ON ".$phxcrmclient_id."_prodserv.uid = ".$phxcrmclient_id."_prod_dept.prod_uid) INNER JOIN ".$phxcrmclient_id."_prod_category ON ".$phxcrmclient_id."_prodserv.uid = ".$phxcrmclient_id."_prod_category.prod_uid) INNER JOIN ".$phxcrmclient_id."_prod_search ON ".$phxcrmclient_id."_prodserv.uid = ".$phxcrmclient_id."_prod_search.uid
WHERE header = 1 and (((".$phxcrmclient_id."_prod_category.cat_id) In (".$cat_sels.")) AND ((".$phxcrmclient_id."_prod_dept.dept_id)=".$dept_id.")) group by ".$phxcrmclient_id."_prod_search.uid;";

echo $querystt;


		$resultstt=mysqli_query($conn, $querystt);

		//truncate picker table

	


		while($rowstt=mysqli_fetch_array($resultstt)) { 

			$price			 			= $rowstt['price'];
			$sku			 			= $rowstt['sku'];
			$title			 			= $rowstt['title'];
		//	$main_uid		 			= $rowstt['main_uid'];

			$qp_prodserv_uid  = 1;
			
			$disp_price = $price;

					

					
		
$result = $result . '
    <div class="col-md-3"><div class="chip"  data-toggle="tooltip" data-html="true" title="SKU:'.htmlspecialchars($sku).' Title: ' .htmlspecialchars($title). '" ondragstart="dragItqp(event, '.$qp_prodserv_uid.')" onclick="javascript: add_item_quickpick('.$qp_prodserv_uid.')">
<table>
<tr>
<td>
  <img src="https://app.phoenixcrm.co.nz/crm/images/products/'.$prod_image_url1.'"  width="88" height="88" onerror="this.onerror=null; this.src=\'https://app.phoenixcrm.co.nz/crm/images/noimage.png\'" alt="no image" />
  </td>
  <td>
        <span class="chip-label">$'.$disp_price.' </span>
		<br>'.htmlspecialchars($title).'
		</td>
		</tr>
		
		</table>
</div></div>';
		}	
		
		$result = $result . '</div>';

echo $result;

			
			?>