<?php
class Update_data extends CI_Model{
    
    
    function up_profile($c_id)
    {
        $data = array(
        'c_name' => $this->input->post('c_name'),
        'c_phone' => $this->input->post('c_phone'),
        'c_mobile' => $this->input->post('c_mobile'),
        'c_contactperson' => $this->input->post('c_contactperson'),
        'c_address' => $this->input->post('c_address'),
        'c_email' => $this->input->post('c_email'),
        'c_facebook' => $this->input->post('c_facebook'),
        'c_linkedin' => $this->input->post('c_linkedin'),
        'c_google' => $this->input->post('c_google'),
        );
        //print_r($data); die();
        $this->db->where('c_id',$c_id);
        $this->db->update('company_profile', $data);
    }
     function up_about($a_id)
    {
        $check = $this->input->post('check');        
        $data = array(
        'a_title' => $this->input->post('a_title'),
        'a_description' => $this->input->post('a_description')
        );
        $this->db->where('a_id',$a_id);
        $this->db->update('about', $data);
        
        if($check == 'on')
        {
            move_uploaded_file($_FILES['a_image']['tmp_name'], 'assets/uploads/services/about_'.$a_id.'.jpg');
        }
    }
	 function up_vission($p_id)
    {
        $check = $this->input->post('check');        
        $data = array(
        'p_title' => $this->input->post('p_title'),
        'p_description' => $this->input->post('p_description'),
		//'p_name' => 'Vission'
        );
        $this->db->where('p_id',$p_id);
        $this->db->update('pages', $data);
        
        if($check == 'on')
        {
            move_uploaded_file($_FILES['p_image']['tmp_name'], 'assets/uploads/services/vission_'.$p_id.'.jpg');
        }
    }

     function up_slider($s_id)
    {
        $data = array(
        's_title' => $this->input->post('s_title'),
        's_iamge' => $this->input->post('s_iamge'),        
        's_content' => $this->input->post('s_content')
        );
       
        $this->db->where('s_id',$s_id);
        $this->db->update('slider', $data);
        
        $file_tmp = $_FILES['s_image']['tmp_name'];
        if($file_tmp !='')
        {
            move_uploaded_file($_FILES['s_image']['tmp_name'], 'assets/uploads/slider/'.$s_id.'.jpg');
            
        }
    }

    
	 function up_company($p_id)
    {
        $check = $this->input->post('check');        
        $data = array(
        'p_title' => $this->input->post('p_title'),
        'p_description' => $this->input->post('p_description'),
		//'p_name' => 'Company Profile'
        );
        $this->db->where('p_id',$p_id);
        $this->db->update('pages', $data);
        
        if($check == 'on')
        {
            move_uploaded_file($_FILES['p_image']['tmp_name'], 'assets/uploads/services/company_'.$p_id.'.jpg');
        }
    }
	function up_faq($id)
	{
		$data = array (
			'type'=>trim($this->input->post('type')),
            'que' =>trim($this->input->post('que')),
			'ans'=>trim($this->input->post('ans')),
	 	);
		$this->db->where('id',$id);
        $this->db->update('faq', $data);
	}
     function up_infra($in_id)
    {
        $check = $this->input->post('check');
        $data = array(
       // 'pt_id' =>$this->input->post('pt_id'),
        'in_title' => $this->input->post('in_title'),
        'in_description' => $this->input->post('in_description')
        );
        //print_r($data); die();        
        $this->db->where('in_id',$in_id);
        $this->db->update('infrastucture', $data);
        
         if($check == 'on')
        {
            move_uploaded_file($_FILES['in_image']['tmp_name'], 'assets/uploads/services/infra_'.$in_id.'.jpg');
        }
       
    }
	function up_consultancy($id)
    {        
	    $check = $this->input->post('check');
        $data = array(        
        'name'=>trim($this->input->post('name')),
        'description' =>trim($this->input->post('description'))        
        );

        $this->db->where('id',$id);
        $this->db->update('consultancy',$data);
        if($check == 'on')
        {
            move_uploaded_file($_FILES['s_image']['tmp_name'], 'assets/uploads/consultancy/'.$id.'.jpg');
        }       
    }
	function up_article($a_id)
    {
	 $check = $this->input->post('check');
        $data = array(
        'a_title'=>$this->input->post('a_title'),
		'description'=>$this->input->post('description')
        );
        $this->db->where('a_id',$a_id);
        $this->db->update('articles',$data);
		
		if($check == 'on')
        {
            move_uploaded_file($_FILES['a_image']['tmp_name'], 'assets/uploads/articles/'.$a_id.'.jpg');
        }
    }
	function up_pgallery($id)
    {        
	    $check = $this->input->post('check');
        $data = array(        
        'g_name'=>trim($this->input->post('g_name')),        
        );

        $this->db->where('g_id',$id);
        $this->db->update('project_gallery',$data);
        if($check == 'on')
        {
            move_uploaded_file($_FILES['g_image']['tmp_name'], 'assets/uploads/projects/gallery_'.$id.'.jpg');
        }       
    }
	function up_service($s_id)
    {
        
	    $check = $this->input->post('check');
        $data = array(        
        's_name'=>trim($this->input->post('s_name')),
        'pt_id' =>trim($this->input->post('pt_id')),
        's_description' =>trim($this->input->post('s_description'))
        
        );
        //print_r($data);die();
        $this->db->where('s_id',$s_id);
        $this->db->update('service',$data);
        if($check == 'on')
        {
            move_uploaded_file($_FILES['s_image']['tmp_name'], 'assets/uploads/services/service_'.$s_id.'.jpg');
        }
       
    }
	  function up_product_cat($pt_id)
    {
        
	    $check = $this->input->post('check');
        $data = array(
        
       // 'pt_id'=>$this->input->post('pt_id'),
        'pt_name'=>$this->input->post('pt_name'),
        'pt_description' =>$this->input->post('pt_description'),
        't_type'=>$this->input->post('t_type'),
        't_description'=>$this->input->post('t_description')
        
        );
        //print_r($data);die();
        $this->db->where('pt_id',$pt_id);
        $this->db->update('product',$data);
        if($check == 'on')
        {
            move_uploaded_file($_FILES['pt_image']['tmp_name'], 'assets/uploads/category/ptype_'.$pt_id.'.jpg');
        }
        if($_FILES['t_image']['tmp_name'] !='')
        {
            move_uploaded_file($_FILES['t_image']['tmp_name'], 'assets/uploads/category/table_'.$pt_id.'.jpg');
        }
        
       
    }
	  function up_product($p_id)
    {
        
	    $check = $this->input->post('check');
		$check2 = $this->input->post('check2');
        $data = array(
        
        'pt_id'=>$this->input->post('pt_id'),
        'p_name'=>$this->input->post('p_name'),
        'p_description' =>$this->input->post('p_description')
        
        );
        //print_r($data);die();
        $this->db->where('p_id',$p_id);
        $this->db->update('sub_product',$data);
        if($check == 'on')
        {
            move_uploaded_file($_FILES['p_image']['tmp_name'], 'assets/uploads/news/product_'.$p_id.'.jpg');
        }
        if($check2 == '1')
        {
            move_uploaded_file($_FILES['bro_image']['tmp_name'], 'assets/uploads/news/product_'.$p_id.'.pdf');
        }
    }
	
	  function up_subproduct($p_id)
    {
        $check = $this->input->post('check');
        $data = array(
        'pt_id' =>$this->input->post('pt_id'),
        'p_name' => $this->input->post('p_name'),
        'p_description' => $this->input->post('p_description')
        );
        //print_r($data); die();        
        $this->db->where('p_id',$p_id);
        $this->db->update('sub_product', $data);
        
         if($check == 'on')
        {
            move_uploaded_file($_FILES['p_image']['tmp_name'], 'assets/uploads/services/subproduct_'.$p_id.'.jpg');
        }
       
    }
  /*  function up_subservices($su_id)
    {
       
	    $su_image = 1;
		$su_image_count = count($_FILES['su_image']['tmp_name']);
	    $count = $_FILES['su_image']['tmp_name'];
          
        $data = array(
        //'se_id' =>$this->input->post('se_id'),
        'su_title' => $this->input->post('su_title'),
        'su_description' => $this->input->post('su_description'),
        'su_image' =>$su_image,
        'su_image_count' => $su_image_count
        );
        //print_r($data); die();        
        $this->db->where('su_id',$su_id);
        $this->db->update('sub_service', $data);
        
         $i = 0;
	   foreach($_FILES['su_image']['tmp_name'] as $key => $tmp_name)
	   {
		$i++;
        $file_tmp =$_FILES['su_image']['tmp_name'][$key];
		move_uploaded_file($file_tmp,"assets/uploads/services/subservices_".$su_id."_".$i.'.jpg');
        //move_uploaded_file($_FILES['p_image']['tmp_name'],'assets/uploads/news/product_'.$p_id.'.jpg');
       }
        
       
    }*/
      
    function up_gallery($g_id)
    {
        $check = $this->input->post('check');
        $data = array(
       // 'pt_id' =>$this->input->post('pt_id'),
        'g_name' => $this->input->post('g_name'),
        'g_description' => $this->input->post('g_description')
        );
        //print_r($data); die();        
        $this->db->where('g_id',$g_id);
        $this->db->update('gallery', $data);
        
         if($check == 'on')
        {
            move_uploaded_file($_FILES['g_image']['tmp_name'], 'assets/uploads/news/gallery_'.$g_id.'.jpg');
        }
       
    }
    
   
    
}
