<?php 
class modules extends CI_Controller {
	function modules ()	 
	{  
    parent::__construct();		
    $this->load->Model('functions', 'fun');  //function in model 
    } 
	
	function index()
	{
		$this->load->view('header');
        $menu=array();
		$menu_q= $this->fun->get_modules();
		$menu['mods']=$menu_q;
		$status='all';
		$menu['status']=$status;
		$this->load->view('left',$menu);

		$row=array();
		
		
		$this->load->model('modules_model');  /// model file name
		if($q=$this->modules_model->get_modules())   ///////model class --->model func
		{
		$row['records']=$q;
		}
		$this->load->view('modules',$row);
		$this->load->view('footer');
	}
	
	
	function add_module()
	{
	    $this->load->view('header');
        $menu=array();
		$menu_q= $this->fun->get_modules();
		$menu['mods']=$menu_q;
		$status='all';
		$menu['status']=$status;
		$this->load->view('left',$menu);
		$this->load->view('add_module');
		$this->load->view('footer');

	}
	function save_add_module()
	{
	$data=array(
	    'name'=>$this->input->post('name'),
	    'title'=>$this->input->post('title'),
	    'have_name'=>$this->input->post('have_name'),
	    'have_short'=>$this->input->post('have_short'),
	    'have_details'=>$this->input->post('have_details'),
	    'have_pic'=>$this->input->post('have_pic'),
	    'have_cats'=>$this->input->post('have_cats'),
	    'have_gallery'=>$this->input->post('have_gal'),
	     'txts'=>$this->input->post('txts'),
	    'txts_names'=>$this->input->post('txts_names'),
	    'areas'=>$this->input->post('areas'),
	    'areas_names'=>$this->input->post('areas_names'),
	    'up'=>$this->input->post('up'),
	    'up_names'=>$this->input->post('up_names')
	    );
	    
	    $this->load->model('modules_model');   ///model file name
	    $this->modules_model->add_new_module($data);  /////model class --->model func
	    $this->index();

	    
	}




	function edit_module($id)
	{ 	
	    $data['qry'] = $this->fun->getone("modules", $id); 
	    
	    $this->load->view('header');
        $menu=array();
		$menu_q= $this->fun->get_modules();
		$menu['mods']=$menu_q;
		$status='all';
		$menu['status']=$status;
		$this->load->view('left',$menu);
	    $this->load->view('edit_module', $data);
	    $this->load->view('footer');
	
	}
	
	function save_edite_module($id)
	{
	$data=array(
	    'name'=>$this->input->post('name'),
	    'title'=>$this->input->post('title'),
	    'have_name'=>$this->input->post('have_name'),
	    'have_short'=>$this->input->post('have_short'),
	    'have_details'=>$this->input->post('have_details'),
	    'have_pic'=>$this->input->post('have_pic'),
	    'have_cats'=>$this->input->post('have_cats'),
	    'have_gallery'=>$this->input->post('have_gal'),
	     'txts'=>$this->input->post('txts'),
	    'txts_names'=>$this->input->post('txts_names'),
	    'areas'=>$this->input->post('areas'),
	    'areas_names'=>$this->input->post('areas_names'),
	     'up'=>$this->input->post('up'),
	    'up_names'=>$this->input->post('up_names')


	    );
	    
	    $this->load->model('modules_model');   ///model file name
	    $this->modules_model->update_module($data,$id);  /////model class --->model func
	    echo "<script type=\"text/javascript\"> alert(\" Edited successfully \") ;window.location.href= \"../edit_module/".$id."\";</script>";
                		         
	   

	
	}
	function delete_module($id)
	{ 	
	    $q= $this->fun->delete_one("modules", $id); 
	    
	    if($q)
	    {
	     echo "<script type=\"text/javascript\"> alert(\" Deleted successfully \") ;window.location.href= \"../\";</script>";
	    }
	    else
	    {
	    echo "<script type=\"text/javascript\"> alert(\" Dont Deleted Please Try Again \") ;window.location.href= \"../\";</script>";
	    }
	    $this->index();
	   // $this->load->view('header');
		//$this->load->view('left');
	    //$this->load->view('edit_module', $data);
	    //$this->load->view('footer');
	
	}
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */