<?php
class Insert_data extends CI_Model {
    
    
    function set_slider()
    {
        $data = array(
        's_title' => $this->input->post('s_title'),
        's_iamge' => $this->input->post('s_image'),        
        's_content' => $this->input->post('s_content')
        );       
        $this->db->insert('slider', $data);
        $id = $this->db->insert_id();        
        $image = $this->input->post('s_title');	       
        move_uploaded_file($_FILES['s_image']['tmp_name'], 'assets/uploads/slider/'.$id.'.jpg');
    }
    function set_job()
    {
        $data = array(
        'name' => $this->input->post('name'),
        'details' => $this->input->post('details'),
        'date'	  => date('Y-m-d')	
        );       
        $this->db->insert('jobs', $data);
        
    }

    function set_clients()
    {
        $data = array(

        'cl_name' => $this->input->post('cl_name'),

        'cl_status' => '1'
        );
        //print_r($data);die();
        $this->db->insert('clients', $data);
        $cl_id = $this->db->insert_id();
        move_uploaded_file($_FILES['cl_image']['tmp_name'], 'assets/uploads/clients/client_'.$cl_id.'.jpg');
    }
    function set_image()
	 {
		 $data = array(
		 'p_id' => trim($this->input->post('p_id')),
		  'a_status' => '1'
		 );
		 $this->db->insert('add_image', $data);
		 $id = $this->db->insert_id();
		 move_uploaded_file($_FILES['add_image']['tmp_name'], 'assets/'.$id.'.jpg');
	 }
	function set_article()
    {
        $data = array(
        'a_title' => $this->input->post('a_title'),
		'description' => $this->input->post('description')
        );
        $this->db->insert('articles', $data);
		$id = $this->db->insert_id();
		move_uploaded_file($_FILES['a_image']['tmp_name'], 'assets/uploads/articles/'.$id.'.jpg'); 
    }
	function setproduct_cat()
	{
		$data = array (
			'pt_name'=>$this->input->post('pt_name'),
			'pt_description' =>$this->input->post('pt_description'),
			'pt_status' =>'1'
	 	);
		$this->db->insert('product',$data);
		$id=$this->db->insert_id();
		move_uploaded_file($_FILES['pt_image']['tmp_name'], 'assets/uploads/category/ptype'.$image.'_'.$id.'.jpg');
	}
	function set_faq()
	{
		$data = array (
			'type'=>trim($this->input->post('type')),
            'que' =>trim($this->input->post('que')),
			'ans'=>trim($this->input->post('ans')),
			'status' =>'1'
	 	);
		$this->db->insert('faq',$data);
		$id=$this->db->insert_id();
	}
	function set_consultancy()
	{
		$data = array (
			'name'=>trim($this->input->post('name')),
            'description' =>trim($this->input->post('description')),
			'status' =>'1'
	 	);
		$this->db->insert('consultancy',$data);
		$id=$this->db->insert_id();
		move_uploaded_file($_FILES['s_image']['tmp_name'], 'assets/uploads/consultancy/'.$id.'.jpg');
	}
	function set_service()
	{
		$data = array (
			's_name'=>trim($this->input->post('s_name')),
            's_description' =>trim($this->input->post('s_description')),
			's_status' =>'1'
	 	);
		$this->db->insert('service',$data);
		$id=$this->db->insert_id();
		move_uploaded_file($_FILES['s_image']['tmp_name'], 'assets/uploads/services/service_'.$id.'.jpg');
	}
	
	function setproduct()
	{
		$data = array(
			'pt_id' => $this->input->post('pt_id'),
			'p_name' => $this->input->post('p_name'),
			'p_description'=>$this->input->post('p_description'),
			'p_status'=>'1'
		 );
		$this->db->insert('sub_product',$data);
		$id=$this->db->insert_id();
		$image = $this->input->post('s_title');	       
        move_uploaded_file($_FILES['p_image']['tmp_name'], 'assets/uploads/news/product'.$image.'_'.$id.'.jpg');
		 move_uploaded_file($_FILES['p_image']['tmp_name'], 'assets/uploads/news/product_'.$id.'.jpg');
	}
	/*function setproduct()
	{
	    
	   //$p_image_count = 0; 
	   //$p_image = 0;	 
	   $p_image = 1;
	   $p_image_count = count($_FILES['p_image']['tmp_name']);
	   $count = $_FILES['p_image']['tmp_name'];
	   //echo count($count);
	   //die();
		$data = array(			
			'p_name'=> $this->input->post('p_name'),	
			'p_description'=>$this->input->post('p_description'),
			'p_image' => $p_image,
			'p_image_count' => $p_image_count,
			'p_status'=>1
		);
		//print_r($data); die();
		$this->db->insert('sub_product',$data);
		$p_id = $this->db->insert_id();
		//$p_id = mysql_insert_id();
		
		$i = 0;
		foreach($_FILES['p_image']['tmp_name'] as $key => $tmp_name)
		{
			$i++;
			$file_tmp =$_FILES['p_image']['tmp_name'][$key];			
			move_uploaded_file($file_tmp,"assets/uploads/news/product_".$p_id."_".$i.'.jpg');
		    //move_uploaded_file($_FILES['p_image']['tmp_name'],'assets/uploads/news/product_'.$id.'.jpg');
		}
	}*/
	
	function set_certificate()
    {
        $data = array(
        'c_name' => $this->input->post('c_name'),
        'c_status' => '1'
        );
        $this->db->insert('certificates', $data);
        $c_id = $this->db->insert_id();
	    move_uploaded_file($_FILES['c_image']['tmp_name'], 'assets/uploads/certificates/certificate_'.$c_id.'.jpg');

    }
	
	function set_infra()
    {
        $data = array(
        //'pt_id' => $this->input->post('pt_id'),
        'in_title' => $this->input->post('in_title'),
        'in_description' => $this->input->post('in_description'),
        'in_status' => '1'
        );
        //print_r($data);die();
        $this->db->insert('infrastucture', $data);
        $in_id = $this->db->insert_id();
        move_uploaded_file($_FILES['in_image']['tmp_name'], 'assets/uploads/services/infra_'.$in_id.'.jpg');
    }
	function set_projectgallery()
    {
        $data = array(
        'g_name' => $this->input->post('g_name'),        
        'g_status' => '1'
        );
        //print_r($data);die();
        $this->db->insert('project_gallery', $data);
        $g_id = $this->db->insert_id();
        move_uploaded_file($_FILES['g_image']['tmp_name'], 'assets/uploads/projects/gallery_'.$g_id.'.jpg');
    }
	function set_gallery()
    {
        $data = array(
        'gt_id' => $this->input->post('gt_id'),
        'g_name' => $this->input->post('g_name'),
        
        'g_status' => '1'
        );
        //print_r($data);die();
        $this->db->insert('gallery', $data);
        $g_id = $this->db->insert_id();
        move_uploaded_file($_FILES['g_image']['tmp_name'], 'assets/uploads/news/gallery_'.$g_id.'.jpg');
    }
  
	function set_gtype()
	{
		$data = array(
			'gt_type'=>$this->input->post('gt_type'),
			'gt_status' =>'1'
		);
		$this->db->insert('gallery_type',$data);		
	}
	
	function set_video()
	{
		$data = array(
			'v_name'=>$this->input->post('v_name'),
			'v_link'=>$this->input->post('v_link'),
			'v_status' =>'1'
		);
		$this->db->insert('video',$data);		
	}
	
	function set_test()
    {
        $data = array(
        't_comment' => $this->input->post('t_comment'),
        't_name' => $this->input->post('t_name'),        
        't_status' => '1'
        );
        //print_r($data);die();
        $this->db->insert('testimonials', $data);
        $t_id = $this->db->insert_id();
        move_uploaded_file($_FILES['t_image']['tmp_name'], 'assets/uploads/news/testmonial_'.$t_id.'.jpg');
    }
	
  function set_news()
  {
	$n_image = 1;
	$n_image_count = count($_FILES['n_image']['tmp_name']);
	$count = $_FILES['n_image']['tmp_name'];
	$data = array(
		'n_title'=>$this->input->post('n_title'),
		'n_date'=>$this->input->post('n_date'),
		'n_description'=>$this->input->post('n_description'),
		'n_image' => $n_image,
		'n_image_count' => $n_image_count,
		'n_status'=>'1'
		);
	$this->db->insert('news',$data);
	$n_id=$this->db->insert_id();
	$i = 0;
	foreach($_FILES['n_image']['tmp_name'] as $key => $tmp_name)
	{
		$i++;
		$file_tmp =$_FILES['n_image']['tmp_name'][$key];
		move_uploaded_file($file_tmp,"assets/uploads/news/news_".$n_id."_".$i.'.jpg');
	}
  }
 
   function set_pdf()
   {
	$data = array(
		'p_name' =>$this->input->post('p_name'),
		'p_status' => '1'
	);
	$this->db->insert('pdf',$data);
	$p_id=$this->db->insert_id();
	 move_uploaded_file($_FILES['p_pdf']['tmp_name'], 'assets/uploads/pdf/broucher_'.$p_id.'.pdf');
   }
}
