<?php  
session_start(); 
	include("connect.php");	
	include("connectp.php");
	header("Access-Control-Allow-Origin: *");

		 $q = $db7->prepare("select * from res_trolley_master order by trolleymid desc");
	//$q->bindValue(':p1', "$par1");
	//$q->bindValue(':p2',  "$par2");
	$q->execute();
	
	
	
	
	$response = array();
	$posts = array();
	
	$result="0";
	
	if ($q->rowCount() > 0)
	{
		$i=1;
		while($i<=$q->rowCount())
		{
			$rt = $q->fetch(PDO::FETCH_ASSOC);
			
			 	$trolleymid=$rt['trolleymid'];
				
				 $uedit="<a href='trolleyedit.php?id=".$rt['trolleymid']."' data-toggle='tooltip' data-placement='top' title='Edit' class='fa fa-edit fa-lg'>  </a>"; 
			
			
				 $udelete="<a href='trolleydelete.php?id=".$rt['trolleymid']."' onclick='return confirm(&#39;Are you sure you want to delete ?&#39;);' data-toggle='tooltip' data-placement='top' title='Delete' class='far fa-trash-alt fa-lg'>  </a>"; 
				
				
				 $view="<a href='itemdetail.php?id=".$rt['trolleymid']."' data-toggle='tooltip' data-placement='top' title='View' class='fa fa-eye fa-lg' >  </a>"; 
				
				$duplicate="<form action='itemadd.php' method='post' style='flex: 1; margin-right: 2px;'><button  class='fa fa-clone fa-lg' name='itemid' type='submit' value='$trolleymid'></button></form> ";
				$duplicate="";
				/* $duplicate="<a href='itemadd.php?id=".$rt['itemid']."' data-toggle='tooltip' data-placement='top' title='Duplicate' class='fa fa-clone' >  </a>"; */
				
				$op=$uedit."&nbsp;&nbsp; ".$udelete;
				
		
				$trolleynumber=$rt['trolleynumber'];
				
				$trolleyqrcode=$rt['trolleyqrcode'];
				
				$trolleytareweight=$rt['trolleytareweight'];
				$trolleymid=$rt['trolleymid'];
				$trolleycolor=$rt['trolleycolor'];
				
				
						

				
				$posts[] = array('srno'=> $i++,'trolleymid'=>$trolleymid,'trolleyno'=> $trolleynumber, 'trolleybarcode'=> $trolleyqrcode, 'weight'=> $trolleytareweight, 'op'=> $op,'trolleycolor'=>$trolleycolor);
		}
		 
		$response['posts'] = $posts;
		echo stripslashes(json_encode( array('data' => $posts)));
		//mysqli_close($conn);
		//return;
	}
	
   else
	{
		$result="0";
		$msg="Invalid Error";
		
		$posts[] = array('p1'=> $result,'p2'=> $msg);
	
		$response['posts'] = $posts;
		echo stripslashes(json_encode( array('item' => $posts)));
	}
   
	mysqli_close($conn);	
?>