%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/ugotscom/public_html/sterren/application/modules/users/controllers/
Upload File :
Create Path :
Current File : /home/ugotscom/public_html/sterren/application/modules/users/controllers/users.php

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Users extends CI_Controller {
	
	function __construct()
    {
        parent::__construct();
		$this->load->model('User_model','user');
		if(isset($_SESSION['user_id']) ){
			
		}else{
			redirect('login');
		}
		//$this->load->model('Dashboard_model');
    }
	/////////////////////////////////LISTING///////////////////////////////////////
	public function index()
	{	

		$data['users_list']=$this->user->all_users();
		$data['page_scripts'] 	= $this->load->view('common/list_scripts', '', true);
		$data['content'] 		= $this->load->view('userslist', $data, true);
		$this->load->view('common/list_scripts',$data);
		$this->load->view('common/layout',$data);
	}
	/////////////////////////////////Add ////////////////////////////////////////////
	public function add()
	{	
		if ($_POST) {
			$password 			= $_POST['password'];
			$_POST['password'] 	= md5($_POST['password']);
			$_POST['added_user']= $_SESSION['user_id'];
			$insert_result 		= $this->user->insert_data($_POST);
            $email_id           =$_POST['email'];
            if($_POST['password']!="")
            {
            $admin_email        = "info@ugotechnologies.com";
             $page_link=base_url().'login';
            $this->load->library('email'); 
            $subject = "User Registration";     
            
            $message  = "Dear ".$_POST['name'].", <br/>";
            $message .="\r\n";
            $message .= "Welcome to Bos Natural<br/>";
            $message .="\r\n";
            $message .= "Username : ".$_POST['username'];
            $message .="<br/>";
            $message .= "New Password : ".$password;
            $message .="<br/>";
            $message .="<a href=".$page_link.">Click on this link to verify your account.</a><br/>";
            $message .="\r\n\r\n";
            $message .="Thanks and Regards,<br/>";
            $message .="\r\n";
            $message .="Bos Natural Team";

            $this->email->from($admin_email,'Bos Natural');
            $this->email->to($email_id);
            $this->email->subject($subject);
            $this->email->set_header('MIME-Version', '1.0');
	        $this->email->set_header('Content-type', 'text/html; charset=iso-8859-1');
            $this->email->message($message);
            $this->email->send();
        }
			if ($insert_result) {
				$this->session->set_flashdata('add','Data Added Successfully');
				redirect('user/');
			}
		}

		$data['user_type_list']=$this->user->user_type_list();
		//echo "<pre>";print_r($data);exit();
		$data['page_scripts'] 	= $this->load->view('form_scripts', '', true);
        $data['page_styles'] 	="";
        $data['content'] 		= $this->load->view('add', $data, true);
        $this->load->view('common/layout',$data);
	}
	/////////////////////////////////View///////////////////////////////////////
	public function view($user_id)
	{	
		$data['details'] 	= $this->user->user_details($user_id);
		$data['goals']		= $this->user->driving_goals($user_id);
		$data['driving_activity']	= $this->user->driving_activity_list($user_id);
		//echo "<pre>";print_r($data);exit();
		$data['content'] 	= $this->load->view('view', $data, true);
		$this->load->view('common/layout',$data);
	}
	/////////////////////////////////Edit ////////////////////////////////////////////
	public function edit($user_id)
	{	
		if ($_POST) {
			$category_id 		=$_POST['category_id'];
			unset($_POST['category_id']);
			if ($_POST['password']) {
				 $admin_email        = "info@ugotechnologies.com";
				  $page_link=base_url().'login'; 
            $this->load->library('email'); 
            $subject = "User Registration";     
            
            $message  = "Dear ".$_POST['name'].", <br/>";
            $message .="\r\n";
            $message .= "Welcome to Bos Natural<br/>" ;
            $message .="\r\n";
            $message .= "Username : ".$_POST['username'];
            $message .="<br/>";
            $message .= "New Password : ".$_POST['password'];
            $message .="<br/>";
            $message .="<a href=".$page_link.">Click on this link to verify your account.</a><br/>";
            $message .="\r\n\r\n";
            $message .="Thanks and Regards,<br/>";
            $message .="\r\n";
            $message .="Bos Natural Team<br/>";

            $this->email->from($admin_email,'Bos Natural');
            $this->email->to($_POST['email']);
            $this->email->subject($subject);
            $this->email->message($message);
            $this->email->set_header('MIME-Version', '1.0');
	        $this->email->set_header('Content-type', 'text/html; charset=iso-8859-1');
            $this->email->send();
				$_POST['password']=md5($_POST['password']);
			}else{
				unset($_POST['password']);
			}
			$res 		= $this->user->delete_category($user_id);
			foreach ($category_id as $key => $value) {
				$insert_data= array('category_id' => $value,
									'user_id' 	=> $user_id,  );
				$res 		= $this->user->insert_category($insert_data);
			}
			$result 		= $this->user->update_data($_POST,$user_id);
			if ($result) {
				$this->session->set_flashdata('add','Data Added Successfully');
				redirect('user/edit/'.$user_id);
			}
		}

		$data['details'] 		= $this->user->user_details($user_id);
		$data['category_list'] 	=$this->user->category_list();
		$data['user_category'] 	=$this->user->user_category($user_id);
		$data['user_type_list'] =$this->user->user_type_list();
		//echo "<pre>";print_r($data);exit();
		$data['page_scripts'] 	= $this->load->view('form_scripts', '', true);
        $data['page_styles'] 	="";
        $data['content'] 		= $this->load->view('edit', $data, true);
        $this->load->view('common/layout',$data);
	}
	/////////////////////////////////View///////////////////////////////////////
	public function profile()
	{	
		$user_id 			=$_SESSION['user_id'];
		$data['details'] 	= $this->user->user_details($user_id);

		if ($_SESSION['user_type']==2) {
			$parent_id=$_SESSION['user_id'];
		}else if ($_SESSION['user_type']==3) {
			$parent_id=$_SESSION['company_id'];
		}
		$data['department_list']=$this->user->department_list($parent_id);
		//echo "<pre>";print_r($data);exit();
		$this->load->view('profile',$data);
	}
	//////////////////////Profile update///////////////////////
	public function profile_update($user_id,$type="")
	{	
		if ($_POST) {
			//echo "<pre>";print_r($_POST);echo "<pre>";print_r($_FILES);exit();
			if ($_FILES) {	
				$path 			="project_assets/user_images";
				$_POST['image']	=$this->common_data->file_upload($path,"image");

				unset($_POST['old_image']);
			}else{
				if (isset($_POST['old_image'])) {
					$_POST['image']=$_POST['old_image'];
				}
				unset($_POST['old_image']);
			}
			
			$result 		= $this->user->update_data($_POST,$user_id);
			if ($result) {
				$this->session->set_flashdata('add','Data updated Successfully');
				redirect('user/profile/#'.$type);
			}
		}

		$data['details'] 	= $this->user->user_details($user_id);
		if ($_SESSION['user_type']==2) {
			$parent_id=$_SESSION['user_id'];
		}else if ($_SESSION['user_type']==3) {
			$parent_id=$_SESSION['company_id'];
		}
		$data['department_list']=$this->user->department_list($parent_id);
		//echo "<pre>";print_r($data);exit();
		$this->load->view('edit',$data);
	}
	/////////////////////////////////Work History///////////////////////////////////////
	public function work_history()
	{	
		if ($_POST) {
			$year=date('Y');
			$month=$_POST['month'];
		}else{
			$year=date('Y');
			$month=date('m');
			//$month='06';
		}
		$data['month']=$month;
		$parent_id 			=$this->common_data->get_parent();
		$data['users_list']=$this->user->all_users($parent_id,'1');
		//echo "<pre>";print_r($data);exit();
		foreach ($data['users_list'] as $key => $value) {
			$data['users_list'][$key]['work_time']="";
			$data['users_list'][$key]['work_days_array']=$this->user->task_duration_list($value['user_id'],$year,$month);
				$data['users_list'][$key]['hour_array']=array();
				$data['users_list'][$key]['minute_array']=array();
				foreach ($data['users_list'][$key]['work_days_array'] as $keyds => $valueds) {
					$date1s=date_create($valueds['start_time']);
					$date2s=date_create($valueds['end_time']);
					$dDiffs=date_diff($date1s,$date2s);
					array_push($data['users_list'][$key]['hour_array'], $dDiffs->h);
					array_push($data['users_list'][$key]['minute_array'], $dDiffs->i);

					$data['users_list'][$key]['total_hours']=array_sum($data['users_list'][$key]['hour_array']);
					$data['users_list'][$key]['total_minutes']=array_sum($data['users_list'][$key]['minute_array']);
					/*array_push($data['users_list'][$key]['total_hours'], $data['users_list'][$key]['total_hours']);
					array_push($data['users_list'][$key]['total_minutes'], $data['users_list'][$key]['total_minutes']);*/
					$hour_sum 		=$data['users_list'][$key]['total_hours'];
					$minute_sum 	=$data['users_list'][$key]['total_minutes'];
					$hours     		= floor($minute_sum / 60);
		            $minutes 		= $minute_sum - ($hours * 60);
		            $total_hours    =$hour_sum+$hours;
		            $data['users_list'][$key]['work_time']=$total_hours."Hrs ".$minutes."Min";
				}
				
		}
		$data['month_list']=$this->user->month_list();
		//echo "<pre>";print_r($data);exit();
		$this->load->view('work_history',$data);
	}
	/////////////////////////Status Change/////////////////////////////////////////
	public function change_status($id,$status=null)
    { 
        if($status==1){
            $insert_data=array('status'=>'2');
        }else{
            $insert_data=array('status'=>'1');
        }
        $result=$this->user->update_data($insert_data,$id);
        if($result){
            $this->session->set_flashdata('change','Status changed successfully');
            redirect('user');
        } 
    }   
	///////////////////////////////////////////////////////////////////////////
}

Zerion Mini Shell 1.0