<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class OrderModel extends CI_Model{
public function validHashCheck($hash,$id){
$this->db->select("*");
$this->db->where("sha1(order_id)",$hash);
$this->db->where("company_id",$id);
$check =$this->db->get('hcs_order_master');
if ($check->num_rows() >= 1 ) {
return true;
}
else{
return false;
}
}
public function getOrderDetails($hash,$company_id){
$result=$this->getIDProcessing($hash);
$order_id=$result->order_id;
$this->db->select("*");
$this->db->where('order_id',$order_id);
$this->db->where("company_id",$company_id);
$this->db->from('hcs_order_master');
$query=$this->db->get();
if($query->num_rows() >0){
$result=$query->result_array();
return $result;
}
else{
return false;
}
}
public function getIDProcessing($id) {
$this->db->select("order_id");
$this->db->where('sha1(order_id)',$id);
$query = $this->db->get('hcs_order_master');
return $query->row();
}
public function getSingleOrderDetailsData($order_id){
$this->db->select("a.*,b.product_name,b.commission_rate,(b.commission_rate*a.qty) as sub_commision");
$this->db->where('a.order_id',$order_id);
$this->db->join('hcs_products as b', 'a.product_id = b.product_id');
$this->db->from('hcs_order_details as a');
$query=$this->db->get();
if($query->num_rows() >0){
$result=$query->result_array();
return $result;
}
else{
return false;
}
}
} |