<?php

	defined('BASEPATH') or exit('No Direct Script is Allowed');

	/**
	 * 
	 */
    class SeoController extends CI_Controller
	    {
		    function __construct(){
                parent::__construct();
                    if(!$this->session->id){
                    redirect(site_url('admin/login'));
                }
            }
            
            public function index(){
                $data['seos'] = $this->db->get('tbl_seo')->result();
                $this->db->where('adm_id', $this->session->id);
			    $user['data'] = $this->db->get('tbl_admin')->row();	
                    $this->load->view('backend/global/header',$user);
                    $this->load->view('backend/global/menu');
                    $this->load->view('backend/seo/list',$data);
                    $this->load->view('backend/global/footer');
                
            } 
            
            
            public function edit(){
                $this->db->where('id', $this->input->get('bid'));
				$data['seoE'] = $this->db->get('tbl_seo')->row();
			    $this->db->where('adm_id', $this->session->id);
			    $user['data'] = $this->db->get('tbl_admin')->row();	
                    $this->load->view('backend/global/header',$user);
                    $this->load->view('backend/global/menu');
                    $this->load->view('backend/seo/seo',$data);
                    $this->load->view('backend/global/footer');
                
            } 
            
            public function update(){
               $data = array(
						'meta_title' => $this->input->post('meta_title'),
						'meta_keyword' => $this->input->post('meta_keyword'),
						'meta_description' => strtoupper($this->input->post('meta_description')),
						'status' => strtoupper($this->input->post('status')),
					);
				    $this->db->where('id', $this->input->post('id'));
					$query = $this->db->update('tbl_seo', $data);
				    if($query){
                        $this->session->set_flashdata('success', 'Sucessfully Updated');
                        redirect('admin/seo');
                    }else{
                        $this->session->set_flashdata('error', 'Something is wrong. Error!!');
                       	redirect('admin/seo');
                    }
                
                }
            public function delete(){
                $this->db->where('id', $this->input->get('bid'));
			    $this->db->delete('tbl_seo');
				redirect('admin/seo');
               
            }
	}