<?php

class Websitemanagement extends Admin_Controller {

  public function __construct() {
    parent::__construct();
    $this->load->model(array('products/product_model'));
    $this->config->set_item('menu_highlight', 'product management');
  }

  public function index($page = NULL) {
    $data['heading_title'] = 'Website Link Management';
    $cust_id =  $this->input->get('cust_id');
    
    $res = $this->db->query("select * from wps_website_link_management where cust_id = '".$cust_id."'")->row_array();
    if($this->input->post('action')=='submit'){
        $posted_data = array(
            'cust_id' => $cust_id,
            'company_profile' => $this->input->post('company_profile', TRUE),
            'our_products' => $this->input->post('our_products', TRUE),
            'our_services' => $this->input->post('our_services', TRUE),
            'our_gallery' => $this->input->post('our_gallery', TRUE),
            'photo_gallery' => $this->input->post('photo_gallery', TRUE),
            'video_gallery' => $this->input->post('video_gallery', TRUE),
            'careers' => $this->input->post('careers', TRUE),
            'our_clients' => $this->input->post('our_clients', TRUE),
            'blogs' => $this->input->post('blogs', TRUE),
            'contact_us' => $this->input->post('contact_us', TRUE),
        );
        if(count($res)>0){
            $where = "cust_id = '" . $cust_id . "'";
            $this->product_model->safe_update('wps_website_link_management', $posted_data, $where, FALSE);
            redirect('sitepanel/websitemanagement?cust_id=' . $cust_id, '');
        }else{
            $this->product_model->safe_insert('wps_website_link_management', $posted_data, FALSE);
            redirect('sitepanel/websitemanagement?cust_id=' . $cust_id, '');
        }
    }

    $data['res'] = $res;
    $this->load->view('catalog/website_link_management', $data);
  }


  

}

// End of controller