<?php 
include 'session.php';
extract($_REQUEST);
$act=$action;


switch($act)
{		
	case 'get_product_det_by_pdtsku':
		if(isset($_REQUEST['product_sku']) && !empty($_REQUEST['product_sku'])){
			$pdt_prev_img='NoImage.png';			
			$rslt_pdt_det = $db->get_a_line("select * from t_purchase_entry_details where p_invoice_det_id='".$_REQUEST['pdt_invDet_id']."' ");
			
			if (!empty($rslt_pdt_det['upload_img'])) { 
				if(file_exists(CAAROOT_DIR."/uploads/product_image/".$rslt_pdt_det['upload_img']))
				{
					$pdt_prev_img = $rslt_pdt_det['upload_img'];	
				}											
			}
			//image url	
			$img_url =BASE_URL.'uploads/product_image/'.$pdt_prev_img;
						
			echo json_encode(array("rslt"=>"1", "pdt_desc"=>$rslt_pdt_det['saree_desc'], "pdt_img_url"=>$img_url, "pdt_price"=>$rslt_pdt_det['purchase_rate']));
		}
		else{
			echo json_encode(array("rslt"=>"-1")); // error
		}
	
	break;	
	
	case 'get_supplier_det_by_sup_id':
				
		if(isset($_REQUEST['supplier_id']) && !empty($_REQUEST['supplier_id'])){
			$rslt_cus_det = $db->get_a_line("select * from m_supplier where sup_id='".$_REQUEST['supplier_id']."' ");
									
			echo json_encode(array("rslt"=>"1", "sup_state"=>$rslt_cus_det['sup_state']));
		}
		else{
			echo json_encode(array("rslt"=>"-1")); // error
		}
		
	break;
	
	case 'get_customer_det_by_cus_id':
				
		if(isset($_REQUEST['customer_id']) && !empty($_REQUEST['customer_id'])){
			$rslt_cus_det = $db->get_a_line("select * from m_customer where cus_id='".$_REQUEST['customer_id']."' ");
									
			echo json_encode(array("rslt"=>"1", "cus_state"=>$rslt_cus_det['cus_state']));
		}
		else{
			echo json_encode(array("rslt"=>"-1")); // error
		}
		
	break;

	
	case 'get_inv_no_by_company_id':
		$rslt_data='';
		
		if(isset($company_id) && !empty($company_id)){			
			$res_AI = $db->get_a_line("SELECT IFNULL(MAX(`actu_inv_no`), 0) + 1 as disp_inv_no FROM t_purchase_entry_main where 1=1 and company_id='".$company_id."' ");				
			$rslt_data = $res_AI['disp_inv_no'];				
		}
		
		echo json_encode(array("rslt"=>$rslt_data)); //success
	break;

	case 'get_bill_no_by_company_id':
		$rslt_data='';
		
		if(isset($company_id) && !empty($company_id)){			
			$res_AI = $db->get_a_line("SELECT IFNULL(MAX(`actu_bill_no`), 0) + 1 as disp_inv_no FROM t_sales_entry_main where 1=1 and company_id='".$company_id."' ");				
			$rslt_data = $res_AI['disp_inv_no'];				
		}
		
		echo json_encode(array("rslt"=>$rslt_data)); //success
	break;
	
		
}

?>
