<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class manage extends CI_Controller {	
public function __construct()
{
parent::__construct();
$this->load->model('akrsp_model1');
$this->load->helper('date');
$this->load->library('Datatables');
$this->load->library('table');
$this->load->database();
$this->load->library('form_validation');
 $this->load->library("pagination");
 $this->load->helper('download');
 $this->load->helper('file');
 $this->load->library('email');
 @date_default_timezone_set('UTC');
if($this->session->userdata('loggedinadmin')!=true)
{
redirect('welcome/index');
}
}
//CODE WRITTEN AND DESIGN BY TADA JOBS
public function index()
{
$this->load->view('consumer');
//set table id in table open tag
/*  $tmpl = array ( 'table_open'  => '<table id="big_table" border="1" cellpadding="2" cellspacing="1" class="mytable">' );
$this->table->set_template($tmpl); */
}
function viewconsumer()
{
$this->table->set_heading('First Name','Last Name','Email','xzxzxzx');
$this->load->view('viewconsumer');	
}

//function to handle callbacks
function datatable()
{


$this->datatables->select('consumer_id,ref_number,first_name,last_name')
->unset_column('consumer_id')
->from('consumer');
echo $this->datatables->generate();
}
//function to insert consumer
public function insert_consumer()
{
$record=array('contact'=>$this->input->post('ref_number'),
'first_name'=>$this->input->post('first_name'),
'last_name'=>$this->input->post('last_name'),
'cnic'=>$this->input->post('cnic'),
'address'=>$this->input->post('address'),
'meter_number'=>$this->input->post('meter_number'),
'initial_meter_reading'=>$this->input->post('meter_reading'),
'consumer_type'=>$this->input->post('type'),
'meter_reading_date'=>$this->input->post('meter_reading_date'),
'region_id'=>$this->session->userdata('region_id'),
'created_on'=>date("Y/m/d"),
'status'=>0
);

$this->load->model('akrsp_model1');
$data['query']=$this->akrsp_model1->insert_consumer_record($record);
if($data)
{
$data['mesg']="your record has been inserted";
$this->read_consumer();
/* echo '<script type="text/javascript">' . "\n";
echo 'parent.jQuery.fancybox.close();';
//echo 'location.reload("read_consumer");';
echo '</script>';*/

}
else
{
$data['mesg']=" Not inserted";
$this->load->view('consumer',$data);
}
}
public function edit_consumer()
{		$id=$this->input->get('id');
$pas=array('consumer_id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_con_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_con_record($pas);
$this->load->view('edit_consumer',$data);

}   
}

public function read_consumer()
{		
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_consumer_record();
$data['query'] = $result;
$this->load->view('read_consumer',$data);

}
//function for show user
public function user()
{		
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_user_record();
$data['query'] = $result;
$data['city_list']= $this->akrsp_model1->get_dropdown_list();
$this->load->view('user',$data);
}
public function customer()
{		

$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_customer_record();
$data['query'] = $result;
$this->load->view('customer',$data);
}


//function for delete user
public function delete_user()
{
$id=$this->input->get('id');
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->del_rec($id);
redirect('manage/user');
}

public function delete_page()
{
$id=$this->input->get('id');
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->del_page($id);
echo '<script type="text/javascript">' . "\n";
echo 'window.location="cms_pages";';
echo '</script>';
}

//function for delete customer
public function delete_customer()
{
$id=$this->input->get('id');
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->del_customer($id);
echo '<script type="text/javascript">' . "\n";
echo 'window.location="customer";';
echo '</script>';
}



public function update_consumer()
{			$id=$this->input->post('consumer_id');

$record=array('contact'=>$this->input->post('ref_number'),
'first_name'=>$this->input->post('first_name'),
'last_name'=>$this->input->post('last_name'),
'cnic'=>$this->input->post('cnic'),
'address'=>$this->input->post('address'),
'meter_number'=>$this->input->post('meter_number'),
'initial_meter_reading'=>$this->input->post('meter_reading'),
'consumer_type'=>$this->input->post('type'),
'meter_reading_date'=>$this->input->post('meter_reading_date'),
'region_id'=>$this->session->userdata('region_id'),
'updated_on'=>date("Y/m/d")
);

$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->update_consumer_record($id,$record);
if($result)
{  echo '<script type="text/javascript">' . "\n";
echo 'parent.jQuery.fancybox.close()';

//echo 'child.location.reload()';
echo '</script>';


//$this->read_consumer();

}


}

public function delete_consumer()
{
$id=$this->input->get('id');

$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->delete_consumer_record($id);
if($result==0)
{

$this->read_consumer();
}
if($result==1)
{ 
$this->read_consumer();
}
if($result==2)
{ 
echo "it is blocked";
}

}
//code for delete consumer
public function deleteconsumer()
{
$id=$this->input->get('id');
$data = array('status' =>'1');
$this->db->where('consumer_id',$id);
$this->db->update('consumer', $data);
}


public function update_mapping()
{
$id=$this->input->post('a_id');
$meter=$this->input->post('meter_id');
$consumer=$this->input->post('consumer_id');
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->update_mapping_record($id,'con_meter_map',array(
													'meter_id'=>$meter,
													'consumer_id'=>$consumer));
}
function upload()
{
$randumtime=time();
$upload_image_file = trim(addslashes($_FILES['image']['name']));
$upload_image_file = str_replace(' ', '_', $upload_image_file);
$config['upload_path'] = './assets/upload/';

$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['max_size'] = '20000';
$config['max_width'] = '0';
$config['max_height'] = '0';
$config['file_name'] = $randumtime.$upload_image_file;
$this->load->library('upload');
$this->upload->initialize($config);
if (isset($_FILES['image']['name'])) 
{
$this->upload->do_upload('image');
}
$upload_data = $this->upload->data();
}
function uploadjob()
{
$randumtime=time();
$upload_image_file = trim(addslashes($_FILES['image']['name']));
$upload_image_file = str_replace(' ', '_', $upload_image_file);
$config['upload_path'] = './assets/upload/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['create_thumb'] = TRUE;
$config['max_size'] = '20000';
$config['max_width'] = '0';
$config['max_height'] = '0';
/*$config['maintain_ratio'] = TRUE;*/
/*$config['width'] ='221';
$config['height'] = '115';*/

$config['file_name'] = $randumtime.$upload_image_file;
$this->load->library('upload', $config);
$this->upload->initialize($config);
/*$this->load->library('image_lib',$config);
$this->image_lib->resize();
$this->image_lib->clear();*/
/*$this->upload->resize();
$this->upload->clear();*/
if (isset($_FILES['image']['name'])) 
{
$this->upload->do_upload('image');
}
$upload_data = $this->upload->data();
}


///// Add user data code in php
public function add_user()
{	
$this->form_validation->set_rules('name', 'Name', 'required');
/*$this->form_validation->set_rules('father_name', 'Father Name', 'required');*/
$this->form_validation->set_rules('email', 'Email', 'required|valid_email');
$this->form_validation->set_rules('password', 'password', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('add_user_from');
}
else
{
$email=$this->input->post('email');
$this->db->where('email',$email);
$query = $this->db->get('njobn_users');
$nic=$this->input->post('nic');
$this->db->where('nic',$nic);
$query1 = $this->db->get('njobn_users');
if($query->num_rows() > 0)
{
echo "<script>alert('Email Address Already Exist');</script>";	 			  							
redirect('manage/add_user_from');
}

/*elseif($query1->num_rows() > 0)
{
echo "<script>alert('CNIC Already Exist');</script>";	 			  							
redirect('manage/add_user_from');
}*/
else
{
$record=array('group_id'=>$this->input->post('group_id'),
'name'=>$this->input->post('name'),
'father_name'=>$this->input->post('father_name'),
'nic'=>$this->input->post('nic'),
'email'=>$this->input->post('email'),
'password'=>md5($this->input->post('password')),
'created_on'=>date("Y/m/d"));

$this->load->model('akrsp_model1');
$data['query']=$this->akrsp_model1->insert_user_record($record);
$result=$data['query'];
redirect('manage/user');
}
}
}

//code fo add customer
public function add_customer()
{	
$this->form_validation->set_rules('fname', 'First Name', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('add_customer_from');
}
else
{

$email=$this->input->post('email');
$this->db->where('email',$email);
$query = $this->db->get('customer');
if($query->num_rows() > 0){
echo "<script>alert('Email Address Already Exist');</script>";	 			  							
redirect('manage/add_customer_from');
}
else
{
$record=array('fname'=>$this->input->post('fname'),
'lname'=>$this->input->post('lname'),
'company_name'=>$this->input->post('company_name'),
'email'=>$this->input->post('email'),
'phone'=>$this->input->post('phone'),
'address'=>$this->input->post('address'),
'city'=>$this->input->post('city'),
'state'=>$this->input->post('state'),
'zipcode'=>$this->input->post('zipcode'),
'country'=>$this->input->post('country'),
'comments'=>$this->input->post('comments'),
'type'=>$this->input->post('type'),
'account_number'=>$this->input->post('account_number'),
'date'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$data['query']=$this->akrsp_model1->insert_customer_record($record);
$result=$data['query'];;
redirect('manage/customer');	
}

}
}	


//code fo update customer
public function update_customer()
{
$id=$this->input->post('id');
$record=array('fname'=>$this->input->post('fname'),
'lname'=>$this->input->post('lname'),
'company_name'=>$this->input->post('company_name'),
'email'=>$this->input->post('email'),
'phone'=>$this->input->post('phone'),
'address'=>$this->input->post('address'),
'city'=>$this->input->post('city'),
'state'=>$this->input->post('state'),
'zipcode'=>$this->input->post('zipcode'),
'country'=>$this->input->post('country'),
'comments'=>$this->input->post('comments'),
'type'=>$this->input->post('type'),
'account_number'=>$this->input->post('account_number'),
'updated_by'=>$this->session->userdata('admin_id'),
'date'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->update_customer_record($id,$record);
if($result)
{				
redirect('manage/customer');				
}
}
//code fo update customer
public function update_commission()
{
$id=$this->input->post('id');
$record=array('fname'=>$this->input->post('fname'),
'lname'=>$this->input->post('lname'),
'company_name'=>$this->input->post('company_name'),
'email'=>$this->input->post('email'),
'phone'=>$this->input->post('phone'),
'address'=>$this->input->post('address'),
'city'=>$this->input->post('city'),
'state'=>$this->input->post('state'),
'zipcode'=>$this->input->post('zipcode'),
'country'=>$this->input->post('country'),
'comments'=>$this->input->post('comments'),
'account_number'=>$this->input->post('account_number'),
'updated_by'=>$this->session->userdata('admin_id'),
'date'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->update_commission_record($id,$record);
if($result)
{				
redirect('manage/commission');		
}
}
//show edit commsion page
public  function edit_commission()
{		$id=$this->input->get('id');
$pas=array('id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_commission_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_commission_record($pas);
$this->load->view('edit_commission',$data);

}   
}

public  function edit_customer()
{		$id=$this->input->get('id');
$pas=array('id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_customer1_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_customer1_record($pas);
$this->load->view('edit_customer',$data);

}   
}
public  function viewcustomer()
{		$id=$this->input->get('id');
$pas=array('id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_customer1_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_customer1_record($pas);
$this->load->view('viewcustomer',$data);

}   
}
public  function viewcommission()
{		$id=$this->input->get('id');
$pas=array('id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_commission23_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_commission23_record($pas);
$this->load->view('viewcommission',$data);

}   
}


public  function edit_supplier()
{		$id=$this->input->get('id');
$pas=array('id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_supplier1_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_supplier1_record($pas);
$this->load->view('edit_supplier',$data);

}   
}
public  function viewsupplier()
{		$id=$this->input->get('id');
$pas=array('id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_supplier1_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_supplier1_record($pas);
$this->load->view('viewsupplier',$data);

}   
}

public function update_supplier()
{			

$id=$this->input->post('id');
$this->form_validation->set_rules('fname', 'First Name', 'required');
$this->form_validation->set_rules('email', 'Email', 'required|valid_email');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('supplier');
}
else
{
$record=array('name'=>$this->input->post('fname'),
'email'=>$this->input->post('email'),
'phone_number'=>$this->input->post('phone'),
'updated_by'=>$this->session->userdata('admin_id'),
'date'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->update_supplier_record($id,$record);
if($result)
{				
redirect('manage/supplier');				
}
}
}									
//code for to edit the user record	
public function update_user()
{			

$id=$this->input->post('user_id');
$record=array('group_id'=>$this->input->post('group_id'),
'name'=>$this->input->post('name'),
'father_name'=>$this->input->post('father_name'),
'nic'=>$this->input->post('nic'),
'email'=>$this->input->post('email'),
'password'=>md5($this->input->post('password')),
'updated_on'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->update_user_record($id,$record);
if($result)
{				
redirect('manage/user');				
}
//				
}

//code for to edit update product	
public function update_product()
{			

$id=$this->input->post('prod_id');
$this->form_validation->set_rules('prod_name', 'Product Name', 'required');
$this->form_validation->set_rules('prod_qty', 'Product Weight', 'required');
$this->form_validation->set_rules('prod_price', 'Product Price', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('edit_product');
}
else
{
//auto number

if($_FILES['image']['name']!='')
{
if($this->input->post('old_image')!='')
{
$oldfile=$this->input->post('old_image');
$vair=unlink( './assets/upload/'.$oldfile);
}
$this->upload();
//$field_name=$_FILES['image']['name'];
$randumtime=time();
$field_name=trim(addslashes($_FILES['image']['name']));
$field_name= str_replace(' ', '_', $field_name);
$field_name=$randumtime.$field_name;
}
else
{
$field_name=$this->input->post('old_image');
}
$record=array('prod_name'=>$this->input->post('prod_name'),
'autonumber'=>$this->input->post('prod_number'),
'prod_qty'=>$this->input->post('prod_qty'),
'prod_des'=>$this->input->post('prod_des'),
'prod_price'=>$this->input->post('prod_price'),
'prod_type'=>$this->input->post('prod_type'),
'prod_image'=>$field_name,
'updated_by'=>$this->session->userdata('admin_id'),
'date'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->update_product_record($id,$record);
if($result)
{				
redirect('manage/product');			
}	
}
}

public function update_jobeidtpage_category()
{
if($_FILES['image']['name']!='')
{
if($this->input->post('old_image')!='')
{
$oldfile=$this->input->post('old_image');
$vair=unlink( './assets/upload/'.$oldfile);
}
$this->upload();
//$field_name=$_FILES['image']['name'];
$randumtime=time();
$field_name=trim(addslashes($_FILES['image']['name']));
$field_name= str_replace(' ', '_', $field_name);
$field_name=$randumtime.$field_name;
}
else
{
$field_name=$this->input->post('old_image');
}			
$id=$this->input->post('jobs_category_id');
$record=array('jobs_category_title'=>$this->input->post('jobs_category_title'),
'jobs_category_des'=>$this->input->post('jobs_category_des'),
'updated_by'=>$this->session->userdata('admin_id'),
'jobcatimage'=>$field_name,
'jobs_category_date'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->update_sasasas_record($id,$record);
if($result)
{					
redirect('manage/jobscategory');			
}
}
public  function edit_user()
{		$id=$this->input->get('id');
$pas=array('user_id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_user1_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_user1_record($pas);
$this->load->view('edit_user',$data);

}   
}
public  function viewuser()
{		$id=$this->input->get('id');
$pas=array('user_id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_user1_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_user1_record($pas);
$this->load->view('viewuser',$data);

}   
}
//code for to read data of edit product

public  function edit_product()
{		$id=$this->input->get('id');
$pas=array('prod_id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_product2_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_product2_record($pas);
$this->load->view('edit_product',$data);

}   
}
public  function edit_testimonials()
{
$id=$this->input->get('id');
$pas=array('testimonials_id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_testimonials2_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_testimonials2_record($pas);
$this->load->view('edit_testimonials',$data);

}   
}
public  function viewproduct()
{		$id=$this->input->get('id');
$pas=array('prod_id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_product2_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_product2_record($pas);
$this->load->view('viewproduct',$data);

}   
}
public  function viewpurchase()
{		$id=$this->input->get('id');
$pas=array('purchase_id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_purhcase2_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_purhcase2_record($pas);
$this->load->view('viewpurchase',$data);

}   
}

//code for to read data of make
public  function make_sale()
{		$id=$this->input->get('id');
$pas=array('prod_id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_product2_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_product2_record($pas);
$this->load->view('make_sale',$data);

}   
}

//code for to load add_user page
public function add_user_from()
{		
$this->load->model('akrsp_model1');
$this->load->view('add_user_from');
}
//code for to load add_user page
public function add_currency_form()
{		
$this->load->model('akrsp_model1');
$this->load->view('add_currency_form');
}

//code for to load add_team form page
public function add_team_from()
{		
$this->load->model('akrsp_model1');
$this->load->view('add_team_from');
}
//code for to load add testimonials from
public function add_testimonials_form()
{		
$this->load->model('akrsp_model1');
$this->load->view('add_testimonials_form');
}
//code for to load add_webuser page
public function add_webuser_from()
{		
$this->load->model('akrsp_model1');
$this->load->view('add_webuser_from');
}
//code for to load add_job_category
public function add_job_category_from()
{		
$this->load->model('akrsp_model1');
$this->load->view('add_job_category_from');
}

//code for to load add product form page
public function add_product_from()
{		
$this->load->model('akrsp_model1');
$this->load->view('add_product_from');
}
//code for to add muilple file uploads
public function uploadcv_form()
{		
$this->load->model('akrsp_model1');
$this->load->view('uploadcv_form');
}

//code for to read sales
public function sales()
{		
$this->load->model('akrsp_model1');
$this->load->view('sales');
}
//code for to load add purchase form page
public function add_purchase_from()
{		
$this->load->model('akrsp_model1');
$this->load->view('add_purchase_from');
}
//code for to load add_customer page


 //code for to read privillages
public function privileges()
{		
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_privileges_record();
$data['query'] = $result;
$this->load->view('privileges',$data);
}
// code for to read jobscategory

public function jobscategory()
{		
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_jobscategory_record();
$data['query'] = $result;
$this->load->view('jobscategory',$data);
}	
//code for to privillages 

public function delete_privillages()
{
$id=$this->input->get('id');
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->del_pre($id);
redirect('manage/privileges');
}	
//code for to add privillages
//code for to load add_user page
public function add_privillages_from()
{		
$this->load->model('akrsp_model1');
$this->load->view('add_privillages_from');
}
public function add_privillages()
{
$this->form_validation->set_rules('name', 'Name', 'required');
$this->form_validation->set_rules('des', 'Description', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('add_privillages_from');
}
else
{	
$record=array('privilege_name'=>$this->input->post('name'),
'file_name'=>$this->input->post('fname'),
'description'=>$this->input->post('des'),
'created_on'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$data['query']=$this->akrsp_model1->insert_privillges_record($record);
$result=$data['query'];
redirect('manage/privileges');
}
}
//code for to add jobs category
public function add_job_category()
{
$this->form_validation->set_rules('jobs_category_title', 'Title', 'required');
$this->form_validation->set_rules('jobs_category_des', 'Description', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('add_job_category_from');
}
else
{
$this->upload();
$randumtime=time();
$field_name=trim(addslashes($_FILES['image']['name']));
$field_name= str_replace(' ', '_', $field_name);
$field_name=$randumtime.$field_name;	
$record=array('jobs_category_title'=>$this->input->post('jobs_category_title'),
'jobs_category_des'=>$this->input->post('jobs_category_des'),
'created_by'=>$this->session->userdata('admin_id'),
'jobcatimage'=>$field_name,
'jobs_category_date	'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$data['query']=$this->akrsp_model1->insert_jobscategory_record($record);
$result=$data['query'];
redirect('manage/jobscategory');
}
}
// code for to read groups

public function groups()
{		
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_groups_record();
$data['query'] = $result;
$this->load->view('groups',$data);
}	


//code for to delet groups 
public function delete_terr()
{
$type=$this->input->get('consumer_type');
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->del_ter($type);
}

//code for delete the groups
public function delete_groups()
{
$id=$this->input->get('id');
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->del_groups($id);
redirect('manage/groups');
}	
//code for to add groups
public function add_group_from()
{		
$this->load->model('akrsp_model1');
$this->load->view('add_group_from');
}
public function add_groups()
{
$this->form_validation->set_rules('name', 'Name', 'required');
$this->form_validation->set_rules('desc', 'Description', 'required');
$this->form_validation->set_rules('type', 'Type', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('add_group_from');
}
else
{	
$record=array('group_name'=>$this->input->post('name'),
'type'=>$this->input->post('type'),
'description'=>$this->input->post('desc'),
'created_on'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$data['query']=$this->akrsp_model1->insert_groups_record($record);
$result=$data['query'];
redirect('manage/groups');
}
}		
//read assign priivalges
public function assgine_privileges($gr_id)
{
error_reporting(0);
$this->load->model('akrsp_model1');
$user = $this->session->userdata('admin_id');
$id = $user;		
$chk = $this->akrsp_model1->chk_permission(array('ad.user_id'=>$id));
if($this->input->post('save'))
{
$this->akrsp_model1->del_rec1('njobn_assigne_privilege_group',array('group_id'=>$this->input->post('group_id')));

foreach($this->input->post('chk') as $pre)
{
$this->akrsp_model1->insert_data('njobn_assigne_privilege_group',array('privilege_id'=>$pre,'group_id'=>$this->input->post('group_id')));
}
redirect('/manage/groups', 'refresh');

}
$data['gr_id'] = $gr_id;
$data['all'] = $this->akrsp_model1->get_where('njobn_privileges',null);
$chk = $this->akrsp_model1->join_two_result('njobn_group gr','njobn_assigne_privilege_group apg','gr.group_id=apg.group_id','',array('gr.group_id'=>$gr_id));

$pre_aray = array();
foreach($chk as $row)
{
$pre_aray[$row->privilege_id] = $row->privilege_id;
}
//print_r($pre_aray);
$data['query'] = $pre_aray;
//$data['content'] = "assgine_privileges";
$this->load->view('assgine_privileges',$data);
}
			
public function ajax()
{
//$this->load->model('akrsp_model1');
$this->load->view('ajax');
}
//delete code for jobscategory
public function delete_jobscategory()
{
$id=$this->input->get('id');
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->delete_jobs_category('njobn_jobs_category',$id);
redirect('manage/jobscategory');
}
//delete code for job
public function delete_job()
{
$id=$this->input->get('id');
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->delete_job('njobn_jobdetails',$id);
$delete_from_industries=$this->akrsp_model1->delete_job('njobn_industeries',$id);
redirect('manage/jobs');
}
//code for to show data on jobcatgory page
public  function edit_job_category()
{		
$id=$this->input->get('id');
$pas=array('jobs_category_id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_job_category_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_job_category_record($pas);
$this->load->view('edit_job_category',$data);
}   
}		
//code for to show data on edit skill page
public  function edit_skills()
{		
$id=$this->input->get('id');
$pas=array('skill_id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_editskill_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_editskill_record($pas);
$this->load->view('edit_skills',$data);
}   
}
//code for to show page edit tags
public  function edit_tags()
{		
$id=$this->input->get('id');
$pas=array('tag_id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_edittags_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_edittags_record($pas);
$this->load->view('edit_tags',$data);
}   
}
//code for edit currency
public  function edit_currency()
{		
$id=$this->input->get('id');
$pas=array('skill_id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_editcurrency_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_editcurrency_record($pas);
$this->load->view('edit_currency',$data);
}   
}
//code for to view jobcategory page
public  function viewjobcategory()
{		
$id=$this->input->get('id');
$pas=array('jobs_category_id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_viewjobscategory_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_viewjobscategory_record($pas);
$this->load->view('viewjobcategory',$data);
}   
}
//code for to show the job add
//code for to load add purchase form page
public function add_job()
{		
$this->load->model('akrsp_model1');
$this->load->view('add_job');
}
//code for to add job deatils
public function add_job_details()
{	
$this->form_validation->set_rules('company_name', 'Company Name', 'required');
$this->form_validation->set_rules('job_title', 'Job Title', 'required');
$this->form_validation->set_rules('job_des', 'Job Details', 'required');
$this->form_validation->set_rules('job_salary_from', 'Salary From', 'required');
$this->form_validation->set_rules('job_salary_to', 'Salary To', 'required');
$this->form_validation->set_rules('job_contact_fname', 'First name', 'required');
$this->form_validation->set_rules('job_contact_lname', 'Last name', 'required');
$this->form_validation->set_rules('job_contact_email', 'Email', 'required|valid_email');
$this->form_validation->set_rules('exp_date', 'Expiry Date', 'required');

if ($this->form_validation->run() == FALSE)
{
$this->load->view('add_job');
}
else
{
//auto number
$date_get=$this->input->post('exp_date');
$datearray=explode("-", $date_get);
$month=$datearray[0];
$day=$datearray[1];
$year=$datearray[2];
$exp_date=$year."/".$month."/".$day;
$this->uploadjob();
$randumtime=time();
$field_name=trim(addslashes($_FILES['image']['name']));
$field_name= str_replace(' ', '_', $field_name);
$field_name=$randumtime.$field_name;
/*$field_name=$_FILES['image']['name'];*/
$record=array('company_name'=>$this->input->post('company_name'),
'job_des'=>$this->input->post('job_des'),
'job_type'=>$this->input->post('job_type'),
'currency'=>$this->input->post('currency'),
'job_title'=>$this->input->post('job_title'),
'perday'=>$this->input->post('perday'),
'job_refernce'=>$this->input->post('job_refernce'),
'job_salary_from'=>$this->input->post('job_salary_from'),
'job_salary_to'=>$this->input->post('job_salary_to'),
'displaySalary'=>$this->input->post('displaySalary'),
'job_salary_info'=>$this->input->post('job_salary_info'),
'job_location_id'=>$this->input->post('job_location_id'),
'job_postalcode'=>$this->input->post('job_postalcode'),
'carLevel'=>$this->input->post('carLevel'),
'gender'=>$this->input->post('gender'),
'exp'=>$this->input->post('exp'),
'exp1'=>$this->input->post('exp1'),
'total_postions'=>$this->input->post('total_postions'),
'job_shift'=>$this->input->post('job_shift'),
'fage'=>$this->input->post('fage'),
'job_status'=>$this->input->post('job_status'),
'tage'=>$this->input->post('tage'),
'job_contact_fname'=>$this->input->post('job_contact_fname'),
'job_contact_lname'=>$this->input->post('job_contact_lname'),
'job_contact_email'=>$this->input->post('job_contact_email'),
'telephone'=>$this->input->post('telephone'),
'address'=>$this->input->post('address'),
'city'=>$this->input->post('city'),
'state'=>$this->input->post('state'),
'postcode'=>$this->input->post('postcode'),
'exp_date'=>$exp_date,
'degreetitle'=>$this->input->post('degreetitle'),
'comapny_image'=>$field_name,
'created_by'=>$this->session->userdata('admin_id'),
'date'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$data['query']=$this->akrsp_model1->insert_job_add_record($record);
$jobid=$this->db->insert_id();
//echo $jobid;
//$job_id=$this->db->mysql_insert_id();

//$counter=count($_POST['secters']);
//echo $counter;
//exit;
//error_reporting(0);
error_reporting(0);
foreach ($_POST['secters'] as $selectedOption)
{
if($selectedOption!=0)
{
/*echo "insert into njobn_industeries set job_id='".$jobid."',
						 date='".date("Y/m/d")."', 
						  industeries_id='".$selectedOption."'";*/
$sql_insert=mysql_query("insert into njobn_industeries set job_id='".$jobid."',
						 date='".date("Y/m/d")."', 
						  industeries_id='".$selectedOption."'");
}
}
//$result=$data['query'];
redirect('manage/jobs');
}
}
//code for to view jobs page
public  function jobs()
{		
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_viewjob_record();
if($result)
{
$data['query']=$this->akrsp_model1->read_viewjob_record();   
$this->load->view('jobs',$data);
}
}
//code for to show data on job page
public  function edit_job()
{		
$id=$this->input->get('id');
$pas=array('job_id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_jobedit_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_jobedit_record($pas);
$this->load->view('edit_job',$data);
}   
}	
//code for to update jobdatils	
public function update_job_details()
{
$this->form_validation->set_rules('company_name', 'Company Name', 'required');
$this->form_validation->set_rules('job_des', 'Job Details', 'required');
$this->form_validation->set_rules('job_salary_from', 'Salary From', 'required');
$this->form_validation->set_rules('job_salary_to', 'Salary To', 'required');
$this->form_validation->set_rules('job_contact_fname', 'First name', 'required');
$this->form_validation->set_rules('job_contact_lname', 'Last name', 'required');
$this->form_validation->set_rules('job_contact_email', 'Email', 'required|valid_email');
$this->form_validation->set_rules('exp_date', 'Expiry Date', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('edit_job');
}
else
{
$id=$this->input->post('job_id');
if($_FILES['image']['name']!='')
{
if($this->input->post('old_image')!='')
{
$oldfile=$this->input->post('old_image');
//echo base_url().'./assets/upload/'.$oldfile;
//exit;
$vair=unlink( './assets/upload/'.$oldfile);
}
$this->uploadjob();
$randumtime=time();
$field_name=trim(addslashes($_FILES['image']['name']));
$field_name= str_replace(' ', '_', $field_name);
$field_name=$randumtime.$field_name;
}
else
{
$field_name=$this->input->post('old_image');
}
$date_get=$this->input->post('exp_date');
$datearray=explode("-", $date_get);
$month=$datearray[0];
$day=$datearray[1];
$year=$datearray[2];
$exp_date=$year."/".$month."/".$day;
//auto number
$record=array('company_name'=>$this->input->post('company_name'),
'job_des'=>$this->input->post('job_des'),
'job_type'=>$this->input->post('job_type'),
'job_title'=>$this->input->post('job_title'),
'currency'=>$this->input->post('currency'),
'perday'=>$this->input->post('perday'),
'job_refernce'=>$this->input->post('job_refernce'),
'job_salary_from'=>$this->input->post('job_salary_from'),
'job_salary_to'=>$this->input->post('job_salary_to'),
'displaySalary'=>$this->input->post('displaySalary'),
'job_salary_info'=>$this->input->post('job_salary_info'),
'job_location_id'=>$this->input->post('job_location_id'),
'job_postalcode'=>$this->input->post('job_postalcode'),
'carLevel'=>$this->input->post('carLevel'),
'gender'=>$this->input->post('gender'),
'job_status'=>$this->input->post('job_status'),
'exp'=>$this->input->post('exp'),
'exp1'=>$this->input->post('exp1'),
'total_postions'=>$this->input->post('total_postions'),
'job_shift'=>$this->input->post('job_shift'),
'fage'=>$this->input->post('fage'),
'tage'=>$this->input->post('tage'),
'job_contact_fname'=>$this->input->post('job_contact_fname'),
'job_contact_lname'=>$this->input->post('job_contact_lname'),
'job_contact_email'=>$this->input->post('job_contact_email'),
'telephone'=>$this->input->post('telephone'),
'address'=>$this->input->post('address'),
'city'=>$this->input->post('city'),
'state'=>$this->input->post('state'),
'postcode'=>$this->input->post('postcode'),
'exp_date'=>$exp_date,
'degreetitle'=>$this->input->post('degreetitle'),
'comapny_image'=>$field_name,
'updated_by'=>$this->session->userdata('admin_id'),
'date'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->update_jobs_record($id,$record);
if($result)
{				
redirect('manage/jobs');			
}	
}
}	
//code for to view jobs page
public  function viewjob()
{		
$id=$this->input->get('id');
$pas=array('job_id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_viewjobsdeatilss_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_viewjobsdeatilss_record($pas);
$this->load->view('viewjob',$data);
}   
}
//cosw for to add users New Controller
public function add_webuser()
{
	
$this->form_validation->set_rules('fname', 'First Name', 'required');
$this->form_validation->set_rules('lname', 'Last Name', 'required');
$this->form_validation->set_rules('email', 'Email', 'required|valid_email');
$this->form_validation->set_rules('password', 'password', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('add_webuser_from');
}
else
{
$email=$this->input->post('email');
$this->db->where('email',$email);
$query = $this->db->get('njobn_webusers');
if($query->num_rows() > 0)
{ 
echo "<script>alert('Email Address Already Exist');</script>";	
redirect('manage/add_webuser_from');
}
else
{
$record=array('user_type'=>2,
'fname'=>$this->input->post('fname'),
'lname'=>$this->input->post('lname'),
'email'=>$this->input->post('email'),
'password'=>md5($this->input->post('password')),
'created_by'=>$this->session->userdata('admin_id'),
'date'=>date("Y/m/d"));

$this->load->model('akrsp_model1');
$data['query']=$this->akrsp_model1->insert_webuser_record($record);
$result=$data['query'];
redirect('manage/webuser');
}
}
}
//function for show Webusers
public function webuser()
{		
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_webuser_record();
$data['query'] = $result;
$this->load->view('webuser',$data);
}
//function for delete webuser
public function delete_webuser()
{
$id=$this->input->get('id');
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->del_webrecuser($id);
redirect('manage/webuser');
}
//code for to show data on webuser eidt page
public  function edit_webuser()
{		
$id=$this->input->get('id');
$pas=array('user_id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_webedit_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_webedit_record($pas);
$this->load->view('edit_webuser',$data);
}   
}
//code for to edit the web user record	
public function update_webuser()
{
$id=$this->input->post('user_id');
$record=array('user_type'=>2,
'fname'=>$this->input->post('fname'),
'lname'=>$this->input->post('lname'),
'email'=>$this->input->post('email'),
'updated_by'=>$this->session->userdata('admin_id'),
'password'=>md5($this->input->post('password')),
'date'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->update_webuser_record($id,$record);
if($result)
{				
redirect('manage/webuser');				
}
//				
}
//code for view webusers
public  function webviewuser()
{		$id=$this->input->get('id');
$pas=array('user_id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_webuser1_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_webuser1_record($pas);
$this->load->view('webviewuser',$data);
}   
}
//function for delete Team memeber
public function delete_team()
{
$id=$this->input->get('id');
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->del_team($id);
redirect('manage/team');
}
//function for show team memebers
public function team()
{		
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_team_record();
$data['query'] = $result;
$this->load->view('team',$data);
}
//code for to add team member
public function add_team()
{

$this->form_validation->set_rules('team_name_datils', 'Title details', 'required');
$this->form_validation->set_rules('team_desg', 'Designation', 'required');
$this->form_validation->set_rules('team_details_full', 'Full Details', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('add_team_from');
}
else
{
$this->upload();
$randumtime=time();
$field_name=trim(addslashes($_FILES['image']['name']));
$field_name= str_replace(' ', '_', $field_name);
$field_name=$randumtime.$field_name;
$busniess_card1file=$randumtime.$_FILES["busniess_card1"]["name"];
$busniess_card2file=$randumtime.$_FILES["busniess_card2"]["name"];
move_uploaded_file($_FILES["busniess_card1"]["tmp_name"],
      "./assets/upload/" .$busniess_card1file);
$busniess_card1=$randumtime.$_FILES["busniess_card1"]["name"];

move_uploaded_file($_FILES["busniess_card2"]["tmp_name"],
      "./assets/upload/" .$busniess_card2file);
$busniess_card2=$randumtime.$_FILES["busniess_card2"]["name"];
$record=array('team_name_datils'=>$this->input->post('team_name_datils'),
'team_desg'=>$this->input->post('team_desg'),
'team_details_full'=>$this->input->post('team_details_full'),
'created_by'=>$this->session->userdata('admin_id'),
'card1'=>$busniess_card1,
'card2'=>$busniess_card2,
'team_image'=>$field_name,
'date'=>date("Y/m/d"));
$this->load->model('akrsp_model1');

$data['query']=$this->akrsp_model1->insert_team_record($record);
$result=$data['query'];
redirect('manage/team');
}
}
//code for to show the edit tema page
public  function edit_team()
{		$id=$this->input->get('id');
$pas=array('team_id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_teameditpage_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_teameditpage_record($pas);
$this->load->view('edit_team',$data);

}   
}
//code for to edit the team memeber	
public function update_team()
{
$this->form_validation->set_rules('team_name_datils', 'Title details', 'required');
$this->form_validation->set_rules('team_desg', 'Designation', 'required');
$this->form_validation->set_rules('team_details_full', 'Full Details', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('edit_team');
}
else
{
if($_FILES['image']['name']!='')
{
if($this->input->post('old_image')!='')
{
$oldfile=$this->input->post('old_image');
$vair=unlink( './assets/upload/'.$oldfile);
}
$this->upload();
$randumtime=time();
$field_name=trim(addslashes($_FILES['image']['name']));
$field_name= str_replace(' ', '_', $field_name);
$field_name=$randumtime.$field_name;
}
else
{
$field_name=$this->input->post('old_image');
}
$oldbusniess_card1=$this->input->post('oldbusniess_card1');
if($_FILES["busniess_card1"]["name"]=='')
{
$busniess_card1 =$oldbusniess_card1;
}
else
{
if($this->input->post('oldbusniess_card1')!='')
{
$oldfile=$this->input->post('oldbusniess_card1');
$vair=unlink( './assets/upload/'.$oldfile);
}
move_uploaded_file($_FILES["busniess_card1"]["tmp_name"],
      "./assets/upload/" . $_FILES["busniess_card1"]["name"]);
$busniess_card1= $_FILES["busniess_card1"]["name"];
}
$oldbusniess_card2=$this->input->post('oldbusniess_card2');
if($_FILES["busniess_card2"]["name"]=='')
{
$busniess_card2 =$oldbusniess_card2;
}
else
{
if($this->input->post('busniess_card2')!='')
{
$oldfile=$this->input->post('busniess_card2');
$vair=unlink( './assets/upload/'.$oldfile);
}
move_uploaded_file($_FILES["busniess_card2"]["tmp_name"],
      "./assets/upload/" . $_FILES["busniess_card2"]["name"]);
$busniess_card2= $_FILES["busniess_card2"]["name"];
}

$id=$this->input->post('team_id');
$record=array('team_name_datils'=>$this->input->post('team_name_datils'),
'team_desg'=>$this->input->post('team_desg'),
'team_details_full'=>$this->input->post('team_details_full'),
'created_by'=>$this->session->userdata('admin_id'),
'card1'=>$busniess_card1,
'card2'=>$busniess_card2,
'team_image'=>$field_name,
'date'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
/*echo '<pre>';
print_r($record);
exit;*/
$result=$this->akrsp_model1->update_teammemebr_record($id,$record);
if($result)
{				
redirect('manage/team');			
}
}
//				
}
//code fot view team memebr deatils
public  function viewteam()
{		$id=$this->input->get('id');
$pas=array('team_id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_teammember_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_teammember_record($pas);
$this->load->view('viewteam',$data);

}   
}
//function for show testimonials
public function testimonials()
{		
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_testimonials_record();
$data['query'] = $result;
$this->load->view('testimonials',$data);
}
//function for delete testimonials
public function delete_testimonials()
{
$id=$this->input->get('id');
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->del_testimonials($id);
redirect('manage/testimonials');
}
//functaion to insert code testimonials
public function add_testimonials()
{

$this->form_validation->set_rules('title', 'Title', 'required');
$this->form_validation->set_rules('about_client', 'Details About Client', 'required');
$this->form_validation->set_rules('details1', 'Full Details', 'required');
$this->form_validation->set_rules('details2', 'Other Details', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('add_testimonials_form');
}
else
{
$this->upload();
$randumtime=time();
$field_name=trim(addslashes($_FILES['image']['name']));
$field_name= str_replace(' ', '_', $field_name);
$field_name=$randumtime.$field_name;
$record=array('name'=>$this->input->post('title'),
'about_client'=>$this->input->post('about_client'),
'details1'=>$this->input->post('details1'),
'type'=>$this->input->post('type'),
'details2'=>$this->input->post('details2'),
'created_by'=>$this->session->userdata('admin_id'),
'image'=>$field_name,
'date'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$data['query']=$this->akrsp_model1->insert_testimonials_record($record);
$result=$data['query'];
redirect('manage/testimonials');
}
}
//code for to edit the testimonials memeber	
public function update_testimonials()
{
$this->form_validation->set_rules('title', 'Title details', 'required');
$this->form_validation->set_rules('about_client', 'Designation', 'required');
$this->form_validation->set_rules('details1', 'Full Details', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('edit_testimonials');
}
else
{
if($_FILES['image']['name']!='')
{
if($this->input->post('old_image')!='')
{
$oldfile=$this->input->post('old_image');
$vair=unlink( './assets/upload/'.$oldfile);
}
$this->upload();
$randumtime=time();
$field_name=trim(addslashes($_FILES['image']['name']));
$field_name= str_replace(' ', '_', $field_name);
$field_name=$randumtime.$field_name;
}
else
{
$field_name=$this->input->post('old_image');
}
$id=$this->input->post('testimonials_id');
$record=array('name'=>$this->input->post('title'),
'about_client'=>$this->input->post('about_client'),
'details1'=>$this->input->post('details1'),
'type'=>$this->input->post('type'),
'details2'=>$this->input->post('details2'),
'updated_by'=>$this->session->userdata('admin_id'),
'image'=>$field_name,
'date'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->update_testimonials_record($id,$record);
if($result)
{				
redirect('manage/testimonials');				
}
}
//				
}
//code for to show the edit tema page

//code fot view testimonials
public  function viewtestimonials()
{		$id=$this->input->get('id');
$pas=array('testimonials_id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_viewtestimonials_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_viewtestimonials_record($pas);
$this->load->view('viewtestimonials',$data);
}   
}
//***************skils section code****************//
//function for show skils
public function skills()
{		
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_skills_record();
$data['query'] = $result;
$this->load->view('skills',$data);
}
//code for to show tags
public function tags()
{		
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_tags_record();
$data['query'] = $result;
$this->load->view('tags',$data);
}
//code for currrency
public function currency()
{		
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_currency_record();
$data['query'] = $result;
$this->load->view('currency',$data);
}

public function admin_dashboard()
{		
$this->load->model('akrsp_model1');
$this->load->view('admin_dashboard');
}
//code for to show set tags page
public  function settags_form()
{		
$id=$this->input->get('id');
$pas=array('user_id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_webedit_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_webedit_record($pas);
$this->load->view('settags_form',$data);
}     
}
//set tags code
public function settags()
{
$cand_id=$this->input->post('cand_id');
if($this->input->post('tagname')=='')
{
foreach ($_POST['tags'] as $selectedOption)
{
if($selectedOption!=0)
{
$sql_insert23=mysql_query("insert into candtags set cand_id='".$cand_id."',date='".date("Y/m/d")."',tag_id='".$selectedOption."'");
}
}
redirect('manage/candidateuser');	
}
else
{
//code for new tags
$enternewtags==mysql_query("insert into tags set tag_name='".$this->input->post('tagname')."',date='".date("Y/m/d")."'");
$newtagid=mysql_insert_id();
$sql_insert=mysql_query("insert into candtags set cand_id='".$cand_id."',date='".date("Y/m/d")."',tag_id='".$newtagid."'");
redirect('manage/candidateuser');	
}

}
//function for delete skills
public function delete_skills()
{
$id=$this->input->get('id');
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->del_skills($id);
redirect('manage/skills');	
}
//code for to dlete tags
public function delete_tag()
{
$id=$this->input->get('id');
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->del_tags($id);
redirect('manage/tags');	
}
//function for delete currency
public function delete_currency()
{
$id=$this->input->get('id');
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->del_currency($id);
redirect('manage/currency');	
}
//functaion to insert code skills
public function add_skills()
{
$this->form_validation->set_rules('skill_name', 'Skill Name', 'required');
$this->form_validation->set_rules('skill_code', 'Skill Code', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('add_skills_form');
}
else
{
$record=array('skill_name'=>$this->input->post('skill_name'),
'skill_code'=>$this->input->post('skill_code'),
'created_by'=>$this->session->userdata('admin_id'),
'date'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$data['query']=$this->akrsp_model1->insert_skills_record($record);
$result=$data['query'];
redirect('manage/skills');	
}
}
//code for to add tags
public function add_tags()
{
$this->form_validation->set_rules('tag_name', 'Tag Name', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('add_tags_form');
}
else
{
$record=array('tag_name'=>$this->input->post('tag_name'),
'created_by'=>$this->session->userdata('admin_id'),
'date'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$data['query']=$this->akrsp_model1->insert_tags_record($record);
$result=$data['query'];
redirect('manage/tags');	
}
}
//funcation code for add currency
public function add_currency()
{

$this->form_validation->set_rules('skill_name', 'Currency Name', 'required');
$this->form_validation->set_rules('skill_code', 'Currency Symbol Code', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('add_currency_form');
}
else
{
$record=array('skill_name'=>$this->input->post('skill_name'),
'skill_code'=>$this->input->post('skill_code'),
'created_by'=>$this->session->userdata('admin_id'),
'date'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$data['query']=$this->akrsp_model1->insert_currency_record($record);
$result=$data['query'];
redirect('manage/currency');	
}
}
//code for to edit the currency
public function update_currency()
{
$this->form_validation->set_rules('skill_name', 'Currency Name', 'required');
$this->form_validation->set_rules('skill_code', 'Currency Name', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('edit_currency');
}
else
{
$id=$this->input->post('skill_id');
$record=array('skill_name'=>$this->input->post('skill_name'),
'skill_code'=>$this->input->post('skill_code'),
'updated_by'=>$this->session->userdata('admin_id'),
'date'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->update_currency_record($id,$record);
if($result)
{				
redirect('manage/currency');				
}
}
//				
}
//code for to edit the Skilss
public function update_skills()
{
$this->form_validation->set_rules('skill_name', 'Title details', 'required');
$this->form_validation->set_rules('skill_code', 'Skill Code', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('edit_skills');
}
else
{

$id=$this->input->post('skill_id');
$record=array('skill_name'=>$this->input->post('skill_name'),
'skill_code'=>$this->input->post('skill_code'),
'updated_by'=>$this->session->userdata('admin_id'),
'date'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->update_skills_record($id,$record);
if($result)
{				
redirect('manage/skills');				
}
}
//				
}
//code for update tags
//code for to edit the Skilss
public function update_tags()
{
$this->form_validation->set_rules('tag_name', 'Tag Name', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('edit_tags');
}
else
{

$id=$this->input->post('tag_id');
$record=array('tag_name'=>$this->input->post('tag_name'),
'updated_by'=>$this->session->userdata('admin_id'),
'date'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->update_tags_record($id,$record);
if($result)
{				
redirect('manage/tags');				
}
}
//				
}
//code fot view skills
public  function viewskills()
{		$id=$this->input->get('id');
$pas=array('skill_id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_viewskills_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_viewskills_record($pas);
$this->load->view('viewskills',$data);
}   
}
//code for views tags
public  function viewtags()
{
$id=$this->input->get('id');
$pas=array('tag_id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_viewtags_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_viewtags_record($pas);
$this->load->view('viewtags',$data);
}   
}
public  function viewcurrency()
{		
$id=$this->input->get('id');
$pas=array('skill_id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_viewscurrency_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_viewscurrency_record($pas);
$this->load->view('viewcurrency',$data);
}   
}
//code for to load add_skills form page
public function add_skills_form()
{		
$this->load->model('akrsp_model1');
$this->load->view('add_skills_form');
}
//code for to show add tage page
public function add_tags_form()
{		
$this->load->model('akrsp_model1');
$this->load->view('add_tags_form');
}
//***************languages section code****************//
//function for show languages
public function languages()
{		
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_languages_record();
$data['query'] = $result;
$this->load->view('languages',$data);
}
//function for delete languages
public function delete_languages()
{
$id=$this->input->get('id');
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->delete_languages($id);
redirect('manage/languages');
}
//functaion to insert code languages
public function add_languages()
{

$this->form_validation->set_rules('language_name', 'Language Name', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('add_languages_form');
}
else
{
$record=array('language_name'=>$this->input->post('language_name'),
'created_by'=>$this->session->userdata('admin_id'),
'date'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$data['query']=$this->akrsp_model1->insert_languages_record($record);
$result=$data['query'];
redirect('manage/languages');	
}
}
//code for to edit the languages
public function update_languages()
{
$this->form_validation->set_rules('language_name', 'Language details', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('edit_languages');
}
else
{

$id=$this->input->post('language_id');
$record=array('language_name'=>$this->input->post('language_name'),
'updated_by'=>$this->session->userdata('admin_id'),
'date'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->update_languages_record($id,$record);
if($result)
{				
redirect('manage/languages');				
}
}
//				
}
//code fot view languages
public  function viewlanguages()
{		$id=$this->input->get('id');
$pas=array('language_id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_languagesview_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_languagesview_record($pas);
$this->load->view('viewlanguages',$data);
}   
}
//code for to load  languages frompage
public function add_languages_form()
{		
$this->load->model('akrsp_model1');
$this->load->view('add_languages_form');
}
//code for add cms page
public function add_cmspages()
{		
$this->load->model('akrsp_model1');
$this->load->view('add_cmspages');
}

//code for to show data on edit skill page
public  function edit_languages()
{		
$id=$this->input->get('id');
$pas=array('language_id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_editlanguages_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_editlanguages_record($pas);
$this->load->view('edit_languages',$data);
}   
}
//***************cms pages section code****************//
//function for show cms pages in grid 
public function cms_pages()
{		
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_cmspages_record();
$data['query'] = $result;
$this->load->view('cms_pages',$data);
}
//code for show the edit_cms page
public  function edit_cmspages()
{		
$id=$this->input->get('id');
$pas=array('id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_editcmspage_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_editcmspage_record($pas);
$this->load->view('edit_cmspages',$data);
}   
}
//code for to add cms page
public function add_cmspage()
{
$this->form_validation->set_rules('name', 'Page Name', 'required');
$this->form_validation->set_rules('title', 'Page Title', 'required');
$this->form_validation->set_rules('body', 'Page Content', 'required');
$this->form_validation->set_rules('meta_keywords', 'Page Mata Keywords', 'required');
$this->form_validation->set_rules('meta_description', 'Page Meta Description', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('cms_pages');
}
else
{
$id=$this->input->post('cms_id');
$record=array('title'=>$this->input->post('title'),
'body'=>$this->input->post('body'),
'name'=>$this->input->post('name'),
'meta_keywords'=>$this->input->post('meta_keywords'),
'meta_description'=>$this->input->post('meta_description'),
'other_text'=>$this->input->post('other_text'),
'updated_by'=>$this->session->userdata('admin_id'),
'date'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->add_cms_record($record);
if($result)
{				
redirect('manage/cms_pages');			
}
}
//				
}
//code for to edit the cms form
public function update_cmspage()
{
$this->form_validation->set_rules('name', 'Page Name', 'required');
$this->form_validation->set_rules('title', 'Page Title', 'required');
$this->form_validation->set_rules('body', 'Page Content', 'required');
$this->form_validation->set_rules('meta_keywords', 'Page Mata Keywords', 'required');
$this->form_validation->set_rules('meta_description', 'Page Meta Description', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('cms_pages');
}
else
{
$id=$this->input->post('cms_id');
$record=array('title'=>$this->input->post('title'),
'body'=>$this->input->post('body'),
'name'=>$this->input->post('name'),
'meta_keywords'=>$this->input->post('meta_keywords'),
'meta_description'=>$this->input->post('meta_description'),
'other_text'=>$this->input->post('other_text'),
'updated_by'=>$this->session->userdata('admin_id'),
'date'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->update_cms_record($id,$record);
if($result)
{				
redirect('manage/cms_pages');			
}
}
//				
}
//***********************Email Templtes Code *************************
public  function edit_emailtemplates()
{		
$id=$this->input->get('id');
$pas=array('id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_editemailtemplates_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_editemailtemplates_record($pas);
$this->load->view('edit_emailtemplates',$data);
}   
}
//code for show email templtes page to 
public function email_templates()
{		
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_email_templates_record();
$data['query'] = $result;
$this->load->view('email_templates',$data);
}
//code for to edit email templet page
public function update_emailtempltes()
{
$this->form_validation->set_rules('type', 'Enter Templte Type', 'required');
if($this->input->post('femail')!='')
{
$this->form_validation->set_rules('femail', 'From Email', 'required|valid_email');
}
if($this->input->post('temail')!='')
{
$this->form_validation->set_rules('temail', 'To Email', 'required|valid_email');
}

$this->form_validation->set_rules('subject', 'Subject', 'required');
$this->form_validation->set_rules('body', 'Body Content', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('email_templates');
}
else
{
$id=$this->input->post('template_id');
$record=array('type'=>$this->input->post('type'),
'femail'=>$this->input->post('femail'),
'temail'=>$this->input->post('temail'),
'subject'=>$this->input->post('subject'),
'body'=>$this->input->post('body'),
'updated_by'=>$this->session->userdata('admin_id'),
'date'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->update_templtes_record($id,$record);
if($result)
{				
redirect('manage/email_templates');			
}
}
//				
}
//***********************Web site Setting *************************

//code for show web setting
public function web_setting()
{		
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_website_record();
$data['query'] = $result;
$this->load->view('web_setting',$data);
}
//code for to edit email setting
public function update_setting()
{
if($this->input->post('email')!='')
{
$this->form_validation->set_rules('email', 'Email', 'required|valid_email');
}
if ($this->form_validation->run() == FALSE)
{
$this->load->view('web_setting');
}
else
{	
//insert code 
if($_FILES["web_logo"]["name"]=='')
{
$upload_web_logo=$this->input->post('old_logo');
}
else
{
move_uploaded_file($_FILES["web_logo"]["tmp_name"],
      "./assets/upload/" . $_FILES["web_logo"]["name"]);
$upload_web_logo =$_FILES['web_logo']['name'];
}	
if($_FILES["web_icon"]["name"]=='')
{
$upload_web_icon=$this->input->post('old_icon');
}
else
{
move_uploaded_file($_FILES["web_icon"]["tmp_name"],
      "./assets/upload/" . $_FILES["web_icon"]["name"]);
$upload_web_icon =$_FILES['web_icon']['name'];
}


if($_FILES["banner_image"]["name"]=='')
{
$upload_banner_image=$this->input->post('old_banner_image');
}
else
{
move_uploaded_file($_FILES["banner_image"]["tmp_name"],
      "./assets/upload/" . $_FILES["banner_image"]["name"]);
$upload_banner_image=$_FILES['banner_image']['name'];
}
$id=$this->input->post('setting_id');
$record=array('web_title'=>$this->input->post('web_title'),
'web_icon'=>$upload_web_icon,
'web_logo'=>$upload_web_logo,
'banner_image'=>$upload_banner_image,
'facebook'=>$this->input->post('facebook'),
'facebook'=>$this->input->post('facebook'),
'twitter'=>$this->input->post('twitter'),
'gmail'=>$this->input->post('gmail'),
'youtube'=>$this->input->post('youtube'),
'linkedin'=>$this->input->post('linkedin'),
'copy_right'=>$this->input->post('copy_right'),
'Address'=>$this->input->post('Address'),
'footer_about'=>$this->input->post('footer_about'),
'phone1'=>$this->input->post('phone1'),
'phone2'=>$this->input->post('phone2'),
'mobile'=>$this->input->post('mobile'),
'email'=>$this->input->post('email'),
'updated_by'=>$this->session->userdata('admin_id'),
'date'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->update_websiteseeting_record($id,$record);
if($result)
{		
$this->session->set_flashdata('sucess_msg', 'Information Updated Successfully');		
redirect('manage/web_setting');			
}
}
//				
}
	public function loadData()
	{	
		$loadType=$_REQUEST['loadType'];
		$loadId=$_REQUEST['loadId'];
	$this->load->model('akrsp_model1');
		$result=$this->akrsp_model1->getData($loadType,$loadId);
		$HTML="";
		
		if($result->num_rows() > 0){
			foreach($result->result() as $list){
				$HTML.="<option value='".$list->id."'>".$list->name."</option>";
			}
		}
		echo $HTML;
	}	
/*Hamza code - advertisements****************/
		
		//code for to load add_avertisement page
		public function add_advert_form()
		{		
			$this->load->model('akrsp_model1');
			$this->load->view('add_advert_form');
		}
		//code to add adverts
		public function add_advert()
		{
			
			$this->form_validation->set_rules('name', 'Advert Name', 'required');
			$this->form_validation->set_rules('url', 'URL', 'required');
			$this->form_validation->set_rules('position', 'Position', 'required');
			if ($this->form_validation->run() == FALSE)
			{
				$this->load->view('add_advert_form');
			}
			else
			{
				$this->upload();
				$randumtime=time();
				$field_name=trim(addslashes($_FILES['image']['name']));
				$field_name= str_replace(' ', '_', $field_name);
				$field_name=$randumtime.$field_name;	
				$record=array(
				'name'=>$this->input->post('name'),
				'image'=>$field_name,
				'url'=>$this->input->post('url'),
				'position'=>$this->input->post('position'),
				'date'=>date("Y/m/d"));
				$this->load->model('akrsp_model1');
				$data['query']=$this->akrsp_model1->insert_advert_record($record);
				$result=$data['query'];
				if ($result)
				{
					redirect('manage/advertisements');
				}
				else
				{
					$this->load->view('add_advert_form');
				}
				
			}
		}	
		// code for to read advertisements
		public function advertisements()
		{		
			$this->load->model('akrsp_model1');
			$result=$this->akrsp_model1->read_advertisements_record();
			$data['query'] = $result;
			$this->load->view('advertisements',$data);
		}
		//delete code for advertisements
		public function delete_advertisement()
		{
			$id=$this->input->get('id');
			$this->load->model('akrsp_model1');
			$result=$this->akrsp_model1->delete_advert('advertisements', $id);
			redirect('manage/advertisements');
		}		
		//code to open edit advertisements page
		public function edit_advert()
		{		
			$id=$this->input->get('id');
			$pas=array('id'=>$id);
			$this->load->model('akrsp_model1');
			$result=$this->akrsp_model1->read_advert_record($pas);
			if($result)
			{
				$data['query']=$this->akrsp_model1->read_advert_record($pas);
				$this->load->view('edit_advert', $data);
			}   
		}
		
		//code to commit changes made during update to database
		
		public function update_advert()
		{
			if($_FILES['image']['name']!='')
			{
			if($this->input->post('old_image')!='')
			{
			$oldfile=$this->input->post('old_image');
			$vair=unlink( './assets/upload/'.$oldfile);
			}
				$this->upload();
				$randumtime=time();
				$field_name=trim(addslashes($_FILES['image']['name']));
				$field_name= str_replace(' ', '_', $field_name);
				$field_name=$randumtime.$field_name;
			}
			else
			{
				$field_name=$this->input->post('old_image');
			}			
			$id=$this->input->post('id');
			$record=array(
			'name'=>$this->input->post('name'),
			'image'=>$field_name,
			'url'=>$this->input->post('url'),
			'position'=>$this->input->post('position'),
			'date'=>date("Y/m/d"));
			$this->load->model('akrsp_model1');
			$result=$this->akrsp_model1->update_advert_record($id,$record);
			if($result)
			{					
				redirect('manage/advertisements');			
			}
		}
		//code to view single advertisement 
		public  function view_advert()
		{		
			$id=$this->input->get('id');
			$pas=array('id'=>$id);
			$this->load->model('akrsp_model1');
			$result=$this->akrsp_model1->view_advert_record($pas);
			if($result)
			{
				$data['query']=$this->akrsp_model1->view_advert_record($pas);
				$this->load->view('view_advert_record',$data);
			}   
		}	
//code to load add_logo_form
		public function add_logo_form()
		{		
			$this->load->model('akrsp_model1');
			$this->load->view('add_logo_form');
		}
		//code to add logo
		public function add_logo()
		{
			
			$this->form_validation->set_rules('name', 'Logo Name', 'required');
			if ($this->form_validation->run() == FALSE)
			{
				//error for incomplete data entry
				$this->load->view('add_logo_form');
			}
			else
			{
				$this->upload();
				$randumtime=time();
				$field_name=trim(addslashes($_FILES['image']['name']));
				$field_name= str_replace(' ', '_', $field_name);
				$field_name=$randumtime.$field_name;	
				$record=array(
				'name'=>$this->input->post('name'),
				'position'=>$this->input->post('position'),
				'image'=>$field_name,
				'date'=>date("Y/m/d"));
				$this->load->model('akrsp_model1');
				$data['query']=$this->akrsp_model1->insert_logo_record($record);
				$result=$data['query'];
				if ($result)
				{
					redirect('manage/logos');
				}
			/*	else
				{	
					$this->session->set_flashdata('feedback', 'Cant add more than 5 logos');
					//$this->load->view('add_logo_form', $data);
					redirect('manage/add_logo_form');
				}
				*/
			}
		}	
		// code for to read logos
		public function logos()
		{		
			$this->load->model('akrsp_model1');
			$result=$this->akrsp_model1->read_logos_record();
			$data['query'] = $result;
			$this->load->view('logos',$data);
		}
		//delete code for logo
		public function delete_logo()
		{
			$id=$this->input->get('id');
			$this->load->model('akrsp_model1');
			$result=$this->akrsp_model1->del_logo('logo', $id);
			redirect('manage/logos');
		}		
		//code to open edit logo page
		public function edit_logo()
		{		
			$id=$this->input->get('id');
			$pas=array('id'=>$id);
			$this->load->model('akrsp_model1');
			$result=$this->akrsp_model1->read_logo_record($pas);
			if($result)
			{
				$data['query']=$this->akrsp_model1->read_logo_record($pas);
				$this->load->view('edit_logo', $data);
			}   
		}
		
		//code to commit changes made during update to database
		
		public function update_logo()
		{
			if($_FILES['image']['name']!='')
			{
				if($this->input->post('old_image')!='')
			{
			$oldfile=$this->input->post('old_image');
			$vair=unlink( './assets/upload/'.$oldfile);
			}
				$this->upload();
				$randumtime=time();
				$field_name=trim(addslashes($_FILES['image']['name']));
				$field_name= str_replace(' ', '_', $field_name);
				$field_name=$randumtime.$field_name;
			}
			else
			{
				$field_name=$this->input->post('old_image');
			}			
			$id=$this->input->post('id');
			$record=array(
			'name'=>$this->input->post('name'),
			'position'=>$this->input->post('position'),
			'image'=>$field_name,
			'date'=>date("Y/m/d"));
			$this->load->model('akrsp_model1');
			$result=$this->akrsp_model1->update_logo_record($id,$record);
			if($result)
			{					
				redirect('manage/logos');			
			}
		}
		//code to view single logo 
		public  function view_logo()
		{		
			$id=$this->input->get('id');
			$pas=array('id'=>$id);
			$this->load->model('akrsp_model1');
			$result=$this->akrsp_model1->view_logo_record($pas);
			if($result)
			{
				$data['query']=$this->akrsp_model1->view_logo_record($pas);
				$this->load->view('view_logo_record',$data);
			}   
		}
		
public function add_employeeuser_from()
{		
$this->load->model('akrsp_model1');
$this->load->view('add_employeeuser_from');
}
public function add_employeeuser()
{
	
/*$this->form_validation->set_rules('fname', 'First Name', 'required');
$this->form_validation->set_rules('lname', 'Last Name', 'required');
$this->form_validation->set_rules('email', 'Email', 'required|valid_email');
$this->form_validation->set_rules('password', 'password', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('add_employeeuser_from');
}
else
{*/

$email=$this->input->post('email');
$this->db->where('email',$email);
$query = $this->db->get('njobn_webusers');
if($query->num_rows() > 0)
{ 
echo "<script>alert('Email Address Already Exist');</script>";	
redirect('manage/add_employeeuser_from');
}
/*else
{*/

$user_type =2; // user type: employee
$record=array('user_type'=>$user_type,
'fname'=>$this->input->post('fname'),
'lname'=>$this->input->post('lname'),
'email'=>$this->input->post('email'),
'password'=>md5($this->input->post('password')),
'created_by'=>$this->session->userdata('admin_id'),
'date'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$data['query']=$this->akrsp_model1->insert_webuser_record($record);
$insert_id = $this->db->insert_id();
$result=$data['query'];
$insert_product=mysql_query("insert into njobn_employee set  employee_id='".$insert_id."',date='".date("Y/m/d")."'");
redirect('manage/employeeuser');
/*}
}*/
}
//code for blog
/*CAREER ADVICE BLOG*/
	
	//load blog posts 
	public function view_blog() 
	{
		$this->load->model('akrsp_model1');
		$result=$this->akrsp_model1->read_blogs_record();
		$data['query'] = $result;
		$this->load->view('blogs', $data);
		
	}
	//load add blogpost form
	public function add_blog_post()
	{
		$this->load->model('akrsp_model1');
		$this->load->view('add_blogpost_form');		
	}
	//load blog categories
	public function view_blog_categories() 
	{
		$this->load->model('akrsp_model1');
		$result=$this->akrsp_model1->read_blogs_cat_record();
		$data['query'] = $result;
		$this->load->view('blogs', $data);
		
	}
	//load add blogpost categories from
	public function add_blog_category_form()
	{
		$this->load->model('akrsp_model1');
		$this->load->view('add_blog_category_form');		
	}
	
	
	
	
	//code for to add jobs category
	public function add_blog_category()
	{
		$this->form_validation->set_rules('blogs_category_title', 'Title', 'required');
		$this->form_validation->set_rules('blog_category_details', 'Description', 'required');
		if ($this->form_validation->run() == FALSE)
		{	
			
			$this->load->view('add_blog_category_form');
		}
		else
		{
			$this->upload();
			$randumtime=time();
			$field_name=trim(addslashes($_FILES['image']['name']));
			$field_name= str_replace(' ', '_', $field_name);
			$field_name=$randumtime.$field_name;	
			$record=array('blogs_category_title'=>$this->input->post('blogs_category_title'),
			'blog_category_details'=>$this->input->post('blog_category_details'),
			'created_by'=>$this->session->userdata('admin_id'),
			'updated_by'=>$this->session->userdata('admin_id'),
			'date	'=>date("Y/m/d"));
			$this->load->model('akrsp_model1');
			$data['query']=$this->akrsp_model1->insert_blogcategory_record($record);
			$result=$data['query'];
			redirect('manage/blog_categories');
		}
	}
	
	public function blog_categories()
	{		
		$this->load->model('akrsp_model1');
		$result=$this->akrsp_model1->read_blogscategory_record();
		$data['query'] = $result;
		$this->load->view('blog_categories',$data);
	}	
	
	//delete code for jobscategory
	public function delete_blog_category()
	{
		$id=$this->input->get('id');
		$this->load->model('akrsp_model1');
		$result=$this->akrsp_model1->delete_blogs_category('blogs_category', $id);
		redirect('manage/blog_categories');
	}
	
	public  function edit_blog_category()
	{		
		$id=$this->input->get('id');
		$pas=array('blogs_cat_id'=>$id);
		$this->load->model('akrsp_model1');
		$result=$this->akrsp_model1->read_blog_category_record($pas);
		if($result)
		{
			$data['query']=$this->akrsp_model1->read_blog_category_record($pas);
			$this->load->view('edit_blog_category',$data);
		}   
	}		
	
	
	public function update_blogeidtpage_category()
	{
					
		$id=$this->input->post('blogs_cat_id');
		$record=array('blogs_category_title'=>$this->input->post('blogs_category_title'),
		'blog_category_details'=>$this->input->post('blog_category_details'),
		'updated_by'=>$this->session->userdata('admin_id'),
		'date'=>date("Y/m/d"));
		$this->load->model('akrsp_model1');
		$result=$this->akrsp_model1->update_blogcategory_record($id, $record);
		if($result)
		{					
			redirect('manage/blog_categories');			
		}
	}
	
	public  function view_blog_category()
	{		
		$id=$this->input->get('id');
		$pas=array('blogs_cat_id'=>$id);
		$this->load->model('akrsp_model1');
		$result=$this->akrsp_model1->read_viewblogscategory_record($pas);
		if($result)
		{
			$data['query']=$this->akrsp_model1->read_viewblogscategory_record($pas);
			$this->load->view('view_blog_category',$data);
		}   
	}
	
	//functinoality to add new blog post
	public function add_blogpost()
	{	
		$this->form_validation->set_rules('blog_title', 'Blog Title', 'required');
		$this->form_validation->set_rules('blog_content', 'Blog Details', 'required');
		if ($this->form_validation->run() == FALSE)
		{
			$this->load->view('add_blogpost_form');
		}
		else
		{
			//auto number
			$this->upload();
			$randumtime=time();
			$field_name=trim(addslashes($_FILES['image']['name']));
			$field_name= str_replace(' ', '_', $field_name);
			$field_name=$randumtime.$field_name;
			$record=array(
			'blog_title'=>$this->input->post('blog_title'),
			'blog_content'=>$this->input->post('blog_content'),
			'link'=>$this->input->post('link'),
			'blog_image'=>$field_name,
			'blog_category_id'=>$this->input->post('blog_category_id'),
			'created_by'=>$this->session->userdata('admin_id'),
			'updated_by'=>$this->session->userdata('admin_id'),
			'post_date'=>date("Y/m/d"));
			$this->load->model('akrsp_model1');
			$data['query']=$this->akrsp_model1->insert_blog_add_record($record);
			$result=$data['query'];
			redirect('manage/view_blog');
		}
	}	
	
	
	public function delete_blog_post()
	{
		$id=$this->input->get('id');
		$this->load->model('akrsp_model1');
		$result=$this->akrsp_model1->delete_blog('blogs',$id);
		redirect('manage/view_blog');
	}
	
	public  function view_blog_record()
	{		
		$id=$this->input->get('id');
		$pas=array('blog_id'=>$id);
		$this->load->model('akrsp_model1');
		$result=$this->akrsp_model1->read_viewblog_record($pas);
		if($result)
		{
			$data['query']=$this->akrsp_model1->read_viewblog_record($pas);
			$this->load->view('view_blog', $data);
		}   
	}
	
	public  function edit_blogpost()
	{		
		$id=$this->input->get('id');
		$pas=array('blog_id'=>$id);
		$this->load->model('akrsp_model1');
		$result=$this->akrsp_model1->read_blog_post_record($pas);
		if($result)
		{
			$data['query']=$this->akrsp_model1->read_blog_post_record($pas);
			$this->load->view('edit_blogpost', $data);
		}   
	}
	
	public function update_blog_page()
	{
		if($_FILES['image']['name']!='')
		{
			if($this->input->post('old_image')!='')
			{
			$oldfile=$this->input->post('old_image');
			$vair=unlink( './assets/upload/'.$oldfile);
			}
			$this->upload();
			$randumtime=time();
			$field_name=trim(addslashes($_FILES['image']['name']));
			$field_name= str_replace(' ', '_', $field_name);
			$field_name=$randumtime.$field_name;
		}
		else
		{
			$field_name=$this->input->post('old_image');
		}			
		$id=$this->input->post('blog_id');
		$record=array(
		'blog_title'=>$this->input->post('blog_title'),
		'blog_content'=>$this->input->post('blog_content'),
		'blog_image'=>$field_name,
		'blog_category_id'=>$this->input->post('blog_category_id'),
		'link'=>$this->input->post('link'),
		'updated_by'=>$this->session->userdata('admin_id'),
		'post_date'=>date("Y/m/d"));
		$this->load->model('akrsp_model1');
		$result=$this->akrsp_model1->update_blog_record($id,$record);
		if($result)
		{					
			redirect('manage/view_blog');			
		}
	}
//function for show Webusers
public function employeeuser()
{		
$employeeuser = 2;
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_webuser_record($employeeuser);
$data['query'] = $result;
$this->load->view('employeeuser',$data);
}
public  function edit_employeeuser()
{		
$id=$this->input->get('id');
$pas=array('user_id'=>$id);
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_webedit_record($pas);
if($result)
{
$data['query']=$this->akrsp_model1->read_webedit_record($pas);
$this->load->view('edit_employeeuser',$data);
}   
}
//code for to edit the web user record	
public function update_employeeuser()
{
$id=$this->input->post('user_id');
$employeeuser = 2;
$record=array('user_type'=>$employeeuser,
'fname'=>$this->input->post('fname'),
'lname'=>$this->input->post('lname'),
'email'=>$this->input->post('email'),
'updated_by'=>$this->session->userdata('admin_id'),
'password'=>md5($this->input->post('password')),
'date'=>date("Y/m/d"));
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->update_webuser_record($id,$record);
if($result)
{				
redirect('manage/employeeuser');				
}
//				
}
public function add_candidateuser_form()
{		
$this->load->model('akrsp_model1');
$this->load->view('add_candidateuser_form');
}

		
		public function add_candidateuser()
		{
				
			
		
				$email=$this->input->post('email');
				$this->db->where('email',$email);
				$query = $this->db->get('njobn_webusers');
				if($query->num_rows() > 0)
				{ 
					echo "<script>alert('Email Address Already Exist');</script>";	
					redirect('manage/add_candidateuser_form');
				}
					$user_type = 1; // user type: candidate
					$record=array('user_type'=>$user_type,
					'fname'=>$this->input->post('fname'),
					'lname'=>$this->input->post('lname'),
					'email'=>$this->input->post('email'),
					'password'=>md5($this->input->post('password')),
					'created_by'=>$this->session->userdata('admin_id'),
					'date'=>date("Y/m/d"));
					
					$this->load->model('akrsp_model1');
					$data['query']=$this->akrsp_model1->insert_webuser_record($record);
					$insert_id=$this->db->insert_id();
					$result=$data['query'];
		
$insert_product=mysql_query("insert into njobn_candidate set  candidate_id='".$insert_id."',date='".date("Y/m/d")."'");

					redirect('manage/candidateuser');
				
			
		}
		
		public function candidateuser()
		{		
			$employeeuser = 1;
			$this->load->model('akrsp_model1');
			$result=$this->akrsp_model1->read_webuser_record($employeeuser);
			$data['query'] = $result;
			$this->load->view('candidateuser',$data);
		}
		//function for delete webuser
		public function delete_candidatuser()
		{
			$id=$this->input->get('id');
			$this->load->model('akrsp_model1');
			$result=$this->akrsp_model1->del_webrecuser($id);
			redirect('manage/candidateuser');
		}
		//code for to edit the web user record	
		public function update_candidateuser()
		{
			$id=$this->input->post('user_id');
			$candidateuser = 1;
			$record=array('user_type'=>$candidateuser,
			'fname'=>$this->input->post('fname'),
			'lname'=>$this->input->post('lname'),
			'email'=>$this->input->post('email'),
			'updated_by'=>$this->session->userdata('admin_id'),
			'password'=>md5($this->input->post('password')),
			'date'=>date("Y/m/d"));
			$this->load->model('akrsp_model1');
			$result=$this->akrsp_model1->update_webuser_record($id,$record);
			if($result)
			{				
				redirect('manage/candidateuser');				
			}				
		}
		public  function edit_candidateuser()
		{		
			$id=$this->input->get('id');
			$pas=array('user_id'=>$id);
			$this->load->model('akrsp_model1');
			$result=$this->akrsp_model1->read_webedit_record($pas);
			if($result)
			{
				$data['query']=$this->akrsp_model1->read_webedit_record($pas);
				$this->load->view('edit_candidateuser',$data);
			}   
		}
		public function delete_employeeuser()
{
$id=$this->input->get('id');
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->del_webrecuser($id);
redirect('manage/employeeuser');
}
/*search cv by skill*/
	public function search_by_skill()
	{
		$this->load->model('akrsp_model1');
		$cv=$this->akrsp_model1->read_all_cv();
		$data['query'] = $cv;
		$this->load->view('search_by_skill', $data);
	}
//code for to add cms page
function download_cv()
		{
			$field_name=$this->input->get('document');
			$cand_id=$this->input->get('cand_id');
			$image_path =base_url().'assets/upload/'.$field_name;
			$data = file_get_contents($image_path);
			force_download($field_name, $data);
		}
	public function view_cv()
	{
		$data=$this->input->get('document');
		$this->load->view('view_cv_admin', $data);
	}	
//uplaad mutiple cv code
function uploamutiplecv()
{		
$randumtime=time();

$filesCount = count($_FILES['userFiles']['name']);
//create folder first
$directory_name=$this->input->post('foldername');
if (!is_dir('./assets/upload/'.$directory_name)) 
{
mkdir('./assets/upload/'.$directory_name,0777, TRUE);
}
for($i =0; $i < $filesCount; $i++)
{
//code for mutiple upload
$upload_image_file=trim(addslashes($_FILES['userFiles']['name'][$i]));
$upload_image_file=str_replace(' ', '-', $upload_image_file);
$uploadcvdatabse=move_uploaded_file($_FILES["userFiles"]["tmp_name"][$i],"./assets/upload/".$directory_name."/".$upload_image_file);
$files=$directory_name."/".$upload_image_file;
$org_name=$_FILES["userFiles"]["name"][$i];
if($uploadcvdatabse)
{
//insert code for mutiple upload
$insert=mysql_query("insert into files set file_name='".$files."',
org_name='".$org_name."',folder_name='".$directory_name."',created_by='".$this->session->userdata('admin_id')."',date='".date("Y/m/d")."'");
//code for insert skills
$cv_id = mysql_insert_id();
//error_reporting(0);
foreach ($_POST['skills'] as $selectedOption)
{
if($selectedOption!=0)
{
$sql_insert=mysql_query("insert into njobn_cvskills set cv_id='".$cv_id."',date='".date("Y/m/d")."',skills_id='".$selectedOption."'");
}
}											   									   
}
}
redirect('manage/cvdatabse');
		
	}	
//code for cv databse	
public function cvdatabse()
{		
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_cvdatabse_record();
$data['query'] = $result;
$this->load->view('cvdatabse',$data);
}
public function viewcvdatabse()
{
$folder_name=$this->input->get('folder_name');		
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_viewcvdatabse_record($folder_name);
$data['query'] = $result;
$this->load->view('viewcvdatabse',$data);
}
public function delete_folder()
{
$folder_name=$this->input->get('folder_name');
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->delete_folder($folder_name);
redirect('manage/cvdatabse');
}
//code for viewcv db

//function for cvdatabse delete
public function delete_cvdatabse()
{
$id=$this->input->get('id');
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->del_cvdatasbe($id);
redirect('manage/viewcvdatabse');
}
//code for download folder cv
function download_cv1()
{
/*$cahnge_the_status=mysql_query("update cv_counters set download_by='".$this->session->userdata('user_id')."' where 	candidate_id='".$_GET['cand_id']."'");*/
$field_name=$this->input->get('document');
$cand_id=$this->input->get('id');
//echo $field_name;
$image_path =base_url().'assets/upload/'.$field_name;
//echo $image_path;
ob_clean();
$data = file_get_contents($image_path); // Read the file's contents
force_download($field_name, $data);
/*redirect('manage/webviewuser?id='.$cand_id);*/
}
//code for view folder cv
public function view_cv1()
{
$data=$this->input->get('document');
$this->load->view('view_all_cv', $data);
}
//code for view applications 
public function view_applications()
{		
$job_id=$this->input->get('job_id');
//echo $job_id;
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->read_appl_record($job_id);
$data['query'] = $result;
$this->load->view('view_applications',$data);
}
//code for to delete applications of jobs
public function delete_application()
{
$job_id=$this->input->get('job_id');
$id=$this->input->get('id');
$this->load->model('akrsp_model1');
$result=$this->akrsp_model1->del_viewapplciations($id);
redirect('manage/view_applications?job_id='.$job_id);
}
}

