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

[eluser]Roy MJ[/eluser]
Code:
function addtomarket(){
        //if data submitted
        $this->data['productcategory'] = $this->Mypackages_model->select_category();
        $this->data['productstack'] = $this->Mypackages_model->select_stack();    
        if(($this->session->userdata('user_id'))!=NULL)
        {
            $row    =      $this->Profile_model->get_selected($this->session->userdata('user_id'));
            $this->data['username'] = $row->username;
            echo $member_name = $this->data['screenname'] = $row->screenname;
        }
        if($this->input->post('Submit')){
            $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')
                        );
            $this->form_validation->set_rules($config);
            if ($this->form_validation->run() == FALSE)
            {
                
                $row    =    array();
                $this->load->view('mypackages/addtomarket','');
                
            }else{
                if($_FILES['userfile']['name']!=''){
                   //upload thumbnail
                    $config['upload_path'] = site_path().'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/addtomarket', $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['thumb_marker'] = 'thumb_';
                        $config1['maintain_ratio'] = FALSE;
                        $this->image_lib->initialize($config1);
                        $this->image_lib->resize();
                        $this->remove_existing_thumb($this->input->post('selected_package'));
                        $this->Mypackages_model->save('Addtomarket', $filename, $state_n );
                        redirect('mypackages/index/'.$this->input->post('pgoffset'));
                    }
                }else{
                    $this->Mypackages_model->save('Addtomarket', '', $member_name);
                    redirect('mypackages/index/'.$this->input->post('pgoffset'));
                }
            }
        }else{
            $selected_package    =    $this->input->post('selected_package');
            
            
            $row    =    array();
            $row    =      $this->Mypackages_model->get_selected($selected_package);
            $data['package_title'] = $row->package_title;
            $data['price'] = $row->price;
            $data['product_group'] = $row->product_group;
            $data['product_stack'] = $row->product_stack;
            $data['selected_package'] = $selected_package;
            
            $data['pgoffset'] = $this->input->post('pgoffset');
            
            $this->load->view('mypackages/addtomarket', $data);
        }
    }
    function delete($selected_package=''){
        $pgoffset    =    $this->input->post('pgoffset');
        $this->remove_existing_thumb($this->input->post('selected_package'));
        $this->Mypackages_model->delete();
        redirect('mypackages/index/'.$pgoffset);
    }
   function get_common(){
        if(($this->session->userdata('user_id'))!=NULL)
        {
            $row    =      $this->Profile_model->get_selected($this->session->userdata('user_id'));
            $this->data['username'] = $row->username;
        }
        $this->site_settings->get_site_settings();
        $this->data['productcategory'] = $this->Mypackages_model->select_category();
        $this->data['productstack'] = $this->Mypackages_model->select_stack();    
    }
    
}


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