Welcome Guest, Not a member yet? Register   Sign In
CI newbie - Form Validation Helper Problem
#4

[eluser]liz217[/eluser]
from controller:

Code:
function sub()
    {            
            if(!$this->session->userdata('logged_in')){
            //header('Location: /login/index');
            redirect('/login/index','location',301);
        }
        $this->form_validation->set_rules('work_order_type','Work Order Type:','required|xss_clean');            
        $this->form_validation->set_rules('customer_account','Customer Account #:','required|is_numeric');            
        $this->form_validation->set_rules('receiver_type','Receiver Type:','xss_clean');    
        $this->form_validation->set_rules('receiver_type','Receiver Type:','xss_clean');        
        $this->form_validation->set_rules('access_card','Access Card #:','is_numeric|trim');
        $this->form_validation->set_rules('serial_num','Serial #:','');    
        $this->form_validation->set_rules('serial_num_D','Serial #:','');            
        $this->form_validation->set_rules('dish_type_consumed','Dish Type Consumed:','');            
        $this->form_validation->set_rules('multiswitch_consumed','MultiSwitch Consumed:','');            
        $this->form_validation->set_rules('payment_for','Payment For:','trim|xss_clean');            
        $this->form_validation->set_rules('comissioned','Comissioned:','is_numeric');                    $this->form_validation->set_rules('amount','Amount:','is_numeric');            
        $this->form_validation->set_rules('detail','Detail any custom labor or parts:','xss_clean');            
        $this->form_validation->set_rules('notes','Notes:','required|trim|xss_clean');
            
        $this->form_validation->set_error_delimiters('<br /><span class="error">', '</span>');
    
        if ($this->form_validation->run() == FALSE) // validation hasn'\t been passed
        {
        $data='';
            $this->load->view('myform_view', $data);
        }
        //else // passed validation proceed to post success logic
        //{
             // build array for the model
            $db_saved=FALSE;
            $form_data='';
            $form_consumables ='';
            $form_pay ='';
            $tbl='';
            $EOD_ID='';

            $form_data = array(
                               'work_order_type' => set_value('work_order_type'),
                               'customer_account' => set_value('customer_account'),
                               'detail' => set_value('detail'),
                               'notes' => set_value('notes'),
                            'user_id' => $this->session->userdata('username')
                        );
            if ($this->myform_model->SaveForm('myform',$form_data) != FALSE) // the information has therefore been successfully saved in the db
            {
            //$this->myform_model->db->insert_id();
                $db_saved=TRUE;   // or whatever logic needs to occur
                $EOD_ID=$this->myform_model->SaveForm('myform',$form_data);
            }
                    else
            {
                $db_saved=$this->myform_model->SaveForm('myform',$form_data);
                echo '<br>db saved = ';
                echo $db_saved;
            }
            $form_receiver = array(        
                            'EOD_ID'=>$EOD_ID,                  
                            'product_cat'=>'receiver',
                            'item_name' => set_value('receiver_type'),
                               'serial' => set_value('access_card'),
                            'wb_serial' => set_value('serial_num')
            );
            if ($this->myform_model->SaveForm('eod_consumed',$form_receiver) != FALSE) // the information has therefore been successfully saved in the db
            {
                $db_saved=TRUE;   // or whatever logic needs to occur
            }
                    else
            {
                $db_saved=$this->myform_model->SaveForm('eod_consumed',$form_receiver);
                echo '<br>db saved = ';
                echo $db_saved;
            }
            $form_dish = array(
                               'EOD_ID'=>$EOD_ID,
                               'product_cat'=>'dish',
                            'item_name' => set_value('dish_type_consumed'),
                            'wb_serial' => set_value('serial_num_D')
            );
            if ($this->myform_model->SaveForm('eod_consumed',$form_dish) != FALSE) // the information has therefore been successfully saved in the db
            {
                $db_saved=TRUE;   // or whatever logic needs to occur
            }
                    else
            {
                $db_saved=$this->myform_model->SaveForm('eod_consumed',$form_dish);
                echo '<br>db saved = ';
                echo $db_saved;
            }
            $form_multi = array(
                            'EOD_ID'=>$EOD_ID,
                               'product_cat'=>'multiswitch',
                            'item_name'=> set_value('multiswitch_consumed')
                        );
            if ($this->myform_model->SaveForm('eod_consumed',$form_multi) != FALSE) // the information has therefore been successfully saved in the db
            {
                $db_saved=TRUE;   // or whatever logic needs to occur
            }
            else
            {
                $db_saved=$this->myform_model->SaveForm('eod_consumed',$f


Messages In This Thread
CI newbie - Form Validation Helper Problem - by El Forum - 11-11-2009, 09:04 PM
CI newbie - Form Validation Helper Problem - by El Forum - 11-11-2009, 09:37 PM
CI newbie - Form Validation Helper Problem - by El Forum - 11-11-2009, 09:54 PM
CI newbie - Form Validation Helper Problem - by El Forum - 11-11-2009, 10:01 PM
CI newbie - Form Validation Helper Problem - by El Forum - 11-11-2009, 10:03 PM
CI newbie - Form Validation Helper Problem - by El Forum - 11-12-2009, 02:59 AM
CI newbie - Form Validation Helper Problem - by El Forum - 11-12-2009, 08:25 AM
CI newbie - Form Validation Helper Problem - by El Forum - 11-12-2009, 08:26 AM
CI newbie - Form Validation Helper Problem - by El Forum - 11-12-2009, 02:52 PM
CI newbie - Form Validation Helper Problem - by El Forum - 11-14-2009, 11:07 PM



Theme © iAndrew 2016 - Forum software by © MyBB