<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Shape extends CI_Controller {
    
    public function __construct() {
        parent::__construct();
         if (! $this->session->userdata ( 'user_logged_in' ) || !company_url($this->session->userdata ('company_slag'))) {
            redirect ( 'login', 'refresh' );
        }
        $this->load->vars ( array (
                'global' => 'Available to all views',
                'header' => 'common/header',
                'left' => 'common/left',
                'footer' => 'common/footer' 
        ) );
        $this->load->model('Color_model');
        
    }
    
    public function index(){
          $data['shape_list'] = $this->Color_model->AllRecordWithWhere('rugs_shape',array('id!='=>''));			
        
//       echo "<pre>";
//        print_r($data);
//        exit();		
		
        $this->load->view('shape_list',$data);
    }
    
    public function newshape(){
        $data=array();
        $token=$this->input->post('token');
        if($token!=''){
            $data['shape_row']=$this->Color_model->GetARecordWithWhereRowDESC("rugs_shape",array('id'=>$token));
        }
        $this->load->view('shape',$data);
    }
    public function addshape(){
        $data=$this->input->post();      
        if($data['id']!=''){
             $rest=$this->Color_model->Edit("rugs_shape",$data,'id',$data['id']);
            echo $rest;
            exit;
            
        }else{
            unset($data['id']);
            $rest=$this->Color_model->Add("rugs_shape",$data);
            echo $rest;
            exit;
            
        }
    }
    public function delshape(){
        $token=$this->input->post('token');
        if(!empty($token)){
            $rest=$this->Color_model->DelWhere('rugs_shape',array('id'=>$token));            
        }
        redirect(base_url().'shape');
    }
}