EVOLUTION-NINJA
Edit File: Model.php
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Model extends CI_Model { public function admin_login($email,$password) { $this->db->select('A.user_id,A.user_type_id,A.username,A.password,A.email,B.user_type_id,B.user_type'); $this->db->from('gss_login A'); $this->db->join('gss_user_type B','B.user_type_id=A.user_type_id'); $this->db->where('A.email',$email); $this->db->where('A.password',$password); //$this->db->where('A.user_type_id','1'); $this->db->where('A.delete_status','ACTIVE'); $result = $this->db->get(); return $result->row(); } public function get_where_row($table,$where) { $this->db->select('*'); $this->db->from($table); $this->db->where($where); $query=$this->db->get(); return $query->row(); } public function get_where_result($table,$where) { $this->db->select('*'); $this->db->from($table); $this->db->where($where); $query=$this->db->get(); return $query->result(); } public function projects_list($project_type) { $this->db->select('A.project_name,A.project_id,A.project_status,A.land_owner_address'); $this->db->from('gss_new_projects A'); $this->db->join('gss_project_ownership B','B.id=A.project_ownership','left'); $this->db->where('A.delete_status','ACTIVE'); $this->db->where('A.project_status',$project_type); $this->db->where('A.mobile_status','SELECTED'); $this->db->order_by('A.project_name',"ASC"); $result = $this->db->get(); return $result->result(); } public function all_projects_list() { $this->db->select('A.project_name,A.project_id,A.project_status,A.land_owner_address'); $this->db->from('gss_new_projects A'); $this->db->join('gss_project_ownership B','B.id=A.project_ownership','left'); $this->db->where('A.delete_status','ACTIVE'); $this->db->where('A.mobile_status','SELECTED'); $this->db->order_by('A.project_name',"ASC"); $result = $this->db->get(); return $result->result(); } // public function project_details($project_id) // { // $this->db->select('A.project_id,A.project_name,nick_name,project_status,site_type,nine_and_eleven_image,conversion_image,release_image,approval_image,no_of_years'); // $this->db->from('gss_new_projects A'); // $this->db->where('A.delete_status','ACTIVE'); // $this->db->where('A.project_id',$project_id); // $result = $this->db->get(); // $result = $result->result(); // $array = array(); // if($result) // { // foreach ($result as $key => $value) // { // $data['project_id'] = $value->project_id; // $data['project_name'] = $value->project_name; // $data['nick_name'] = $value->nick_name; // $data['project_status'] = $value->project_status; // $data['site_type'] = $value->site_type; // $data['no_of_years'] = $value->no_of_years; // $data['nine_and_eleven_image'] = 'https://www.gssorganised.com/project_uploads/'.$value->nine_and_eleven_image; // $data['conversion_image'] = 'https://www.gssorganised.com/project_uploads/'.$value->conversion_image; // $data['release_image'] = 'https://www.gssorganised.com/project_uploads/'.$value->release_image; // $data['approval_image'] = 'https://www.gssorganised.com/project_uploads/'.$value->approval_image; // $this->db->select('site_id,project_id,site_number'); // $this->db->from('gss_new_sites'); // $this->db->where('delete_status','ACTIVE'); // $this->db->where('project_id',$value->project_id); // $query = $this->db->get(); // $query = $query->result(); // if($query) // { // $data['site_count'] = count($query); // $data['sites'] = $query; // } // else // { // $data['site_count'] = 0; // $data['sites'] = ""; // } // array_push($array, $data); // } // } // return $array; // } public function project_details($project_id) { $this->db->select('A.project_id,A.project_name,nick_name,project_status,site_type,nine_and_eleven_image,conversion_image,release_image,approval_image,no_of_years'); $this->db->from('gss_new_projects A'); $this->db->where('A.delete_status','ACTIVE'); $this->db->where('A.project_id',$project_id); $result = $this->db->get(); $value = $result->row(); $array = array(); $sum_array = []; $sites_array = array(); if($value) { $data['project_id'] = $value->project_id; $data['project_name'] = $value->project_name; $data['nick_name'] = $value->nick_name; $data['project_status'] = $value->project_status; $data['site_type'] = $value->site_type; $data['no_of_years'] = $value->no_of_years; $data['nine_and_eleven_image'] = 'https://www.gssorganised.com/project_uploads/'.$value->nine_and_eleven_image; $data['conversion_image'] = 'https://www.gssorganised.com/project_uploads/'.$value->conversion_image; $data['release_image'] = 'https://www.gssorganised.com/project_uploads/'.$value->release_image; $data['approval_image'] = 'https://www.gssorganised.com/project_uploads/'.$value->approval_image; $this->db->select('site_id,project_id,site_number'); $this->db->from('gss_new_sites'); $this->db->where('delete_status','ACTIVE'); $this->db->where('project_id',$value->project_id); $query = $this->db->get(); $query = $query->result(); if($query) { $data['site_count'] = count($query); foreach ($query as $key => $val) { $data1['site_id'] = $val->site_id; $data1['project_id'] = $val->project_id; $data1['site_number'] = $val->site_number; array_push($sites_array, $data1); } $sites = array_column($sites_array, 'site_number'); array_multisort($sites, SORT_ASC, $sites_array); $data['sites'] = $sites_array; } else { $data['site_count'] = 0; $data['sites'] = ""; } array_push($array, $data); } return $array; } public function site_details($project_id,$site_number) { $this->db->select('A.site_status,A.site_id,A.project_id,A.site_number,A.north_in_mtrs,A.south_in_mtrs,A.east_in_mtrs,A.west_in_mtrs,A.total_in_sqmtrs,A.total_in_sqft,A.east_facing,A.west_facing,A.north_facing,A.south_facing,A.status,B.project_name'); $this->db->from('gss_new_sites A'); $this->db->join('gss_new_projects B','B.project_id=A.project_id'); $this->db->where('A.delete_status','ACTIVE'); $this->db->where('A.project_id',$project_id); $this->db->where('A.site_number',$site_number); $query = $this->db->get(); $result = $query->result(); $array = array(); if($result) { foreach ($result as $key => $value) { $data['site_id'] = $value->site_id; $data['project_id'] = $value->project_id; $data['site_number'] = $value->site_number; $data['north_in_mtrs'] = $value->north_in_mtrs; $data['south_in_mtrs'] = $value->south_in_mtrs; $data['east_in_mtrs'] = $value->east_in_mtrs; $data['west_in_mtrs'] = $value->west_in_mtrs; $data['total_in_sqmtrs'] = $value->total_in_sqmtrs; $data['total_in_sqft'] = $value->total_in_sqft; $data['east_facing'] = $value->east_facing; $data['west_facing'] = $value->west_facing; $data['north_facing'] = $value->north_facing; $data['south_facing'] = $value->south_facing; $data['status'] = $value->status; $data['site_status'] = $value->site_status; $data['project_name'] = $value->project_name; if(strtoupper($value->status) == "RECEIVED" || strtoupper($value->status) == "RELEASED") { $north_in_mtrs = $value->north_in_mtrs; $value1 = floatval($north_in_mtrs) * 3.2808399; $north_in_mtrs_to_ft = sprintf('%0.2f',$value1); $data['north_in_mtrs_to_feet'] = $north_in_mtrs_to_ft; $east_in_mtrs = $value->east_in_mtrs; $value2 = floatval($east_in_mtrs) * 3.2808399; $east_in_mtrs_to_ft = sprintf('%0.2f',$value2); $data['east_in_mtrs_to_feet'] = $east_in_mtrs_to_ft; $south_in_mtrs = $value->south_in_mtrs; $value3 = floatval($south_in_mtrs) * 3.2808399; $south_in_mtrs_to_ft = sprintf('%0.2f',$value3); $data['south_in_mtrs_to_feet'] = $south_in_mtrs_to_ft; $west_in_mtrs = $value->west_in_mtrs; $value4 = floatval($west_in_mtrs) * 3.2808399; $west_in_mtrs_to_ft = sprintf('%0.2f',$value4); $data['west_in_mtrs_to_feet'] = $west_in_mtrs_to_ft; } else { $data['north_in_mtrs_to_feet'] = ''; $data['east_in_mtrs_to_feet'] = ''; $data['south_in_mtrs_to_feet'] = ''; $data['west_in_mtrs_to_feet'] = ''; } array_push($array, $data); } } return $array; } public function project_site_details($site_number,$project_id) { $this->db->select('A.*,B.*'); $this->db->from('gss_new_sites A'); $this->db->join('gss_new_projects B','B.project_id=A.project_id'); $this->db->where('A.delete_status','ACTIVE'); $this->db->where('B.delete_status','ACTIVE'); $this->db->where('A.site_number',$site_number); $this->db->where('A.project_id',$project_id); $result = $this->db->get(); return $result->row(); } public function sites_status_list($project_id) { $this->db->select('D.*'); $this->db->from('gss_new_sites D'); $this->db->where('D.delete_status','ACTIVE'); $this->db->where('D.project_id',$project_id); $result = $this->db->get(); $result = $result->result(); $array = array(); foreach($result as $val) { $data['site_id'] = $val->site_id; $data['site_number'] = $val->site_number; $data['rel_status'] = $val->status; $this->db->select('A.*,B.*,C.*'); $this->db->from('gss_bookings A'); $this->db->join('gss_new_projects B','B.project_id=A.project_id'); $this->db->join('gss_booking_details C','C.booking_id=A.booking_id'); $this->db->where('A.delete_status','ACTIVE'); $this->db->where('B.delete_status','ACTIVE'); $this->db->where('C.delete_status','ACTIVE'); $this->db->where('C.site_number',$val->site_number); $this->db->where('C.project_id',$project_id); $this->db->where('A.booking_status !=','CANCELLED'); $this->db->where('A.booking_status !=','REFUNDED'); //$this->db->where('C.detail_id','DESC'); $site_result = $this->db->get(); $site_result = $site_result->row(); if($site_result) { $data['site_status'] = $site_result->booking_status; } else { $data['site_status'] = $val->status; } array_push($array,$data); } return $array; } public function single_project_sites($table,$where,$order_by) { $this->db->select('*'); $this->db->from($table); $this->db->where($where); $this->db->order_by('ABS(site_number)',"ASC"); $query=$this->db->get(); return $query->result(); } } ?>