application/controllers/SPharmacy.php
/*
    * It Fetches the products data from the product table 
    * this function is called from the datatable ajax function
    */
It Fetches the products data from the product table
this function is called from the datatable ajax function
It Fetches the products data from the product table this function is called from the datatable ajax function
public function fetchAssetData()
		{
			$result = array('data' => array());
			$curl = curl_init();
			curl_setopt_array($curl, array(
				CURLOPT_URL => "http://54.237.0.216:8080/api/queryAllAssets",
				CURLOPT_RETURNTRANSFER => true,
				CURLOPT_ENCODING => "",
				CURLOPT_MAXREDIRS => 10,
				CURLOPT_TIMEOUT => 0,
				CURLOPT_FOLLOWLOCATION => true,
				CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
				CURLOPT_CUSTOMREQUEST => "GET",
				CURLOPT_POSTFIELDS =>"Test",
				CURLOPT_HTTPHEADER => array(
				"Content-Type: application/javascript"
			),
			));
			$response = curl_exec($curl);
			curl_close($curl);
			$response = json_decode($response, true);
			$response1 = json_decode($response['response'],true);
			$newdata = array();
			for($i = 0; $i < count($response1); $i++)
			{
				$newdata[$response1[$i]["Key"]]=$i;				
			}
			$newdata1 = array();			
			$newId = 0;
			for($i = 0; $i < count($response1); $i++)
			{
				$checkVars = array("JutebagWithRicemill","JutebagReturnedToWarehouse");
				If (in_array($response1[$newdata[$i+1]]["Record"]["AssetStatus"],$checkVars,true)) {
					$newdata1[$newId] = ($response1[$newdata[$i+1]]["Record"]);
					$newId = $newId+1;
				}
			}
			foreach (array_reverse($newdata1) as $key => $value) 
			{
				$buttons = ''; 				
				if ($value["AssetStatus"] == "JutebagWithRicemill") 
				{
					$buttons = '<a href="'.base_url().'ricemill/returntowh/'.$value['JbAssetId'].'" class="label label-primary" role="button">&nbsp;&nbsp;&nbsp;&nbsp;ReturnToWH&nbsp;&nbsp;&nbsp;&nbsp;</a>&nbsp;&nbsp;';
					$value["AssetStatus"] = "Jutebag With Ricemill";
				} 
				if ($value["AssetStatus"] == "JutebagReturnedToWarehouse") 
				{
					$value["AssetStatus"] = "Returned To WH";
				} 
				$result["data"][$key] = array(
					"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$value['JbAssetId'],
					"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"."<img id='barcode' 
					src=https://api.qrserver.com/v1/create-qr-code/?data=".$value['QRCode']."&amp;size=100x100
					width='20' 
					height='20' /><br>".$value['QRCode'],
					$value['BatchNo'],
					$value['OrderNo'],
					$value['AssetName'].'<br>'.$value['AssetType'],
					$value['Jutemill'],
					$value['Warehouse'],
					$value['Owner'], 
					$value['AssetStatus'],
					$buttons
					);
			} 
			echo json_encode($result); 					
		}
public function fetchAssetData ( ) { $ result = array ( 'data' => array ( ) ) ; $ curl = curl_init ( ) ; curl_setopt_array ( $ curl , array ( CURLOPT_URL => " http://54.237.0.216:8080/api/queryAllAssets " , CURLOPT_RETURNTRANSFER => true , CURLOPT_ENCODING => " " , CURLOPT_MAXREDIRS => 10 , CURLOPT_TIMEOUT => 0 , CURLOPT_FOLLOWLOCATION => true , CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1 , CURLOPT_CUSTOMREQUEST => " GET " , CURLOPT_POSTFIELDS => " Test " , CURLOPT_HTTPHEADER => array ( " Content-Type: application/javascript " ) , ) ) ; $ response = curl_exec ( $ curl ) ; curl_close ( $ curl ) ; $ response = json_decode ( $ response , true ) ; $ response1 = json_decode ( $ response [ 'response' ] , true ) ; $ newdata = array ( ) ; for ( $ i = 0 ; $ i < count ( $ response1 ) ; $ i ++ ) { $ newdata [ $ response1 [ $ i ] [ " Key " ] ] = $ i ; } $ newdata1 = array ( ) ; $ newId = 0 ; for ( $ i = 0 ; $ i < count ( $ response1 ) ; $ i ++ ) { $ checkVars = array ( " JutebagWithRicemill " , " JutebagReturnedToWarehouse " ) ; If ( in_array ( $ response1 [ $ newdata [ $ i + 1 ] ] [ " Record " ] [ " AssetStatus " ] , $ checkVars , true ) ) { $ newdata1 [ $ newId ] = ( $ response1 [ $ newdata [ $ i + 1 ] ] [ " Record " ] ) ; $ newId = $ newId + 1 ; } } foreach ( array_reverse ( $ newdata1 ) as $ key => $ value ) { $ buttons = '' ; if ( $ value [ " AssetStatus " ] == " JutebagWithRicemill " ) { $ buttons = '<a href="' . base_url ( ) . 'ricemill/returntowh/' . $ value [ 'JbAssetId' ] . '" class="label label-primary" role="button">&nbsp;&nbsp;&nbsp;&nbsp;ReturnToWH&nbsp;&nbsp;&nbsp;&nbsp;</a>&nbsp;&nbsp;' ; $ value [ " AssetStatus " ] = " Jutebag With Ricemill " ; } if ( $ value [ " AssetStatus " ] == " JutebagReturnedToWarehouse " ) { $ value [ " AssetStatus " ] = " Returned To WH " ; } $ result [ " data " ] [ $ key ] = array ( " &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " . $ value [ 'JbAssetId' ] , " &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " . " <img id='barcode' 
					src=https://api.qrserver.com/v1/create-qr-code/?data= " . $ value [ 'QRCode' ] . " &amp;size=100x100
					width='20' 
					height='20' /><br> " . $ value [ 'QRCode' ] , $ value [ 'BatchNo' ] , $ value [ 'OrderNo' ] , $ value [ 'AssetName' ] . '<br>' . $ value [ 'AssetType' ] , $ value [ 'Jutemill' ] , $ value [ 'Warehouse' ] , $ value [ 'Owner' ] , $ value [ 'AssetStatus' ] , $ buttons ) ; } echo json_encode ( $ result ) ; }
It Fetches the products data from the product table
 this function is called from the datatable ajax function
It Fetches the products data from the product table this function is called from the datatable ajax function
//echo '<pre>'; print_r($response1);exit(); // Sorting //$value['Logistics'], // /foreach			