Welcome Guest, Not a member yet? Register   Sign In
Retrieving problem..!!!
#3

[eluser]Roy MJ[/eluser]
the whole controller..

Code:
class Mypackages extends Controller {
    function Mypackages(){
        parent::Controller();
        $this->load->model('Mypackages_model');
        $this->load->model('Aboutus_model');
        $this->load->model('Profile_model');
        $this->load->helper(array('form'));
        $this->load->library(array('form_validation','pagination'));
        $this->get_common();
    }
    function index($pgoffset=''){
    
        if(($this->session->userdata('user_id'))!=NULL)
        {
            $config['per_page'] = $this->config->item('records_per_page');
            $config['total_rows'] = $this->Mypackages_model->get_total();
            $config['base_url'] = base_url().'index.php/mypackages/index/';
            $config['uri_segment'] = 3;
            $data['count_no'] = ($this->uri->segment(3)=='')? 0 : $this->uri->segment(3);
            $data['events']=  $this->Mypackages_model->get_all($config['per_page'], $pgoffset);
            $data['pgoffset'] = $pgoffset;
            $this->pagination->initialize($config);
            $row    =      $this->Profile_model->get_selected($this->session->userdata('user_id'));
            $this->data['username'] = $row->username;
            $this->load->view('mypackages/list', $data);
        }
        else{
            $data['alert'] = "Not Logged in..!! Please login to access the features";
            $this->load->view('profile/signin', $data);
        }
    }
    
    function add(){
        //if data submitted ' '
        $this->data['productcategory'] = $this->Mypackages_model->select_category();
        $this->data['productstack'] = $this->Mypackages_model->select_stack();        
        $row    =      $this->Mypackages_model->get_user($this->session->userdata('user_id'));
        $this->data['username'] = $row->username;
        if($this->input->post('Submit')){
            
            $product_id = $_REQUEST['product_id'];
            if($product_id!=NULL && $product_id!=11111){
            $config = array(
                           array('field'   => 'package_title','label'   => 'Product Name', 'rules'   => 'trim|required'),
                           array('field'   => 'price','label'   => 'Price', 'rules'   => 'trim|numeric|required'),
                           array('field'   => 'product_group','label'   => 'Group', 'rules'   => 'trim|required'),
                           array('field'   => 'product_id','label'   => 'Stack', 'rules'   => 'trim|required')
                        );
                        }
                    else{
                        $config = array(
                           array('field'   => 'package_title','label'   => 'Product Name', 'rules'   => 'trim|required'),
                           array('field'   => 'price','label'   => 'Price', 'rules'   => 'trim|numeric|required'),
                           array('field'   => 'product_group','label'   => 'Group', 'rules'   => 'trim|required'),
                           array('field'   => 'product_idd','label'   => 'Stack', 'rules'   => 'trim|required')
                        );        
                    }
            $this->form_validation->set_rules($config);
            if ($this->form_validation->run() == FALSE)
            {
                $this->load->view('mypackages/add', $this->data);
            }else{
                    if($_FILES['userfile']['name']!=''){
                   //upload thumbnail
                    $config['upload_path'] = site_path().'packages/';
                    //$config['upload_path'] = 'C://xampp/htdocs/paul/packages/';
                    $config['allowed_types'] = 'gif|jpg|png';
                    $config['max_size']    = '1024';
                    $this->load->library('upload', $config);    
                    if (!$this->upload->do_upload())
                    {
                        $data['alert'] = $this->upload->display_errors();    
                        $this->load->view('mypackages/add', $this->data);
                    }    
                    else
                    {
                        $upload_data = $this->upload->data();
                        
                        $filename = $upload_data['file_name'];
                        $width = $upload_data['image_width'];
                        $height = $upload_data['image_height'];
                        $config1 = array();
                        $this->load->library('image_lib');
                        $config1['source_image'] = site_path().'packages/'.$filename;
                        $config1['maintain_ratio'] = TRUE;
                        
                        $config1['width'] = 83;
                        $config1['height'] = 66;
                        $config1['create_thumb'] = TRUE;
                        $config1['maintain_ratio'] = FALSE;
                        $config1['thumb_marker'] = 'thumb_';
                        $this->image_lib->initialize($config1);
                        $this->image_lib->resize();
                        
                        $this->Mypackages_model->save('Add', $filename);
                        redirect('mypackages');
                    }
                }else{
                    $this->Mypackages_model->save('Add', '');
                    redirect('mypackages');
                }
            }
        }else{
                $this->load->view('mypackages/add', $this->data);
        }
        
    }


Messages In This Thread
Retrieving problem..!!! - by El Forum - 03-30-2011, 12:41 AM
Retrieving problem..!!! - by El Forum - 03-30-2011, 07:45 AM
Retrieving problem..!!! - by El Forum - 03-30-2011, 09:42 PM
Retrieving problem..!!! - by El Forum - 03-30-2011, 09:43 PM
Retrieving problem..!!! - by El Forum - 03-30-2011, 09:44 PM
Retrieving problem..!!! - by El Forum - 03-30-2011, 09:48 PM
Retrieving problem..!!! - by El Forum - 03-31-2011, 07:34 AM
Retrieving problem..!!! - by El Forum - 03-31-2011, 07:37 AM
Retrieving problem..!!! - by El Forum - 03-31-2011, 09:57 AM



Theme © iAndrew 2016 - Forum software by © MyBB