public function save_data()
 {
     $ObjQuery = new queryModel();
     $ObjPreQualify = new preQualifyModel();
     $lpq_id = Input::get('lpq_id');
     $list_id = Input::get('list_id');
     $year = Input::get('year');
     $month = Input::get('month');
     $day = Input::get('day');
     $organization_date = $year . '-' . $month . '-' . $day;
     $business_type = Input::get('business_type');
     $business_type = serialize($business_type);
     $fed_tax_id = Input::get('fed_tax_id');
     $disadvantaged_status = Input::get('disadvantaged_status');
     $disadvantaged_status = serialize($disadvantaged_status);
     $financial_company_secure_bond = Input::get('financial_company_secure_bond');
     $financial_surety_company = Input::get('financial_surety_company');
     $financial_agents_fullname = Input::get('financial_agents_fullname');
     $financial_agents_email = Input::get('financial_agents_email');
     $financial_available_bonding_capacity = Input::get('financial_available_bonding_capacity');
     $financial_available_bonding_rate = Input::get('financial_available_bonding_rate');
     $bank = Input::get('bank');
     $bank_agents_fullname = Input::get('bank_agents_fullname');
     $bank_agents_email = Input::get('bank_agents_email');
     $insurance_com = Input::get('insurance_com');
     $insurance_com_agents_fullname = Input::get('insurance_com_agents_fullname');
     $insurance_com_agents_email = Input::get('insurance_com_agents_email');
     $insurance_com_gen_liability_limit = Input::get('insurance_com_gen_liability_limit');
     $insurance_com_workers_comp_limit = Input::get('insurance_com_workers_comp_limit');
     $safety_drug_free_workplace = Input::get('safety_drug_free_workplace');
     $safety_workers_comp_experience = Input::get('safety_workers_comp_experience');
     $ref_vendors_company_name1 = Input::get('ref_vendors_company_name1');
     $ref_vendors_contact_name1 = Input::get('ref_vendors_contact_name1');
     $ref_vendors_email1 = Input::get('ref_vendors_email1');
     $ref_vendors_company_name2 = Input::get('ref_vendors_company_name2');
     $ref_vendors_contact_name2 = Input::get('ref_vendors_contact_name2');
     $ref_vendors_email2 = Input::get('ref_vendors_email2');
     $ref_vendors_company_name3 = Input::get('ref_vendors_company_name3');
     $ref_vendors_contact_name3 = Input::get('ref_vendors_contact_name3');
     $ref_vendors_email3 = Input::get('ref_vendors_email3');
     $ref_contractors_company_name1 = Input::get('ref_contractors_company_name1');
     $ref_contractors_contact_name1 = Input::get('ref_contractors_contact_name1');
     $ref_contractors_email1 = Input::get('ref_contractors_email1');
     $ref_contractors_company_name2 = Input::get('ref_contractors_company_name2');
     $ref_contractors_contact_name2 = Input::get('ref_contractors_contact_name2');
     $ref_contractors_email2 = Input::get('ref_contractors_email2');
     $ref_contractors_company_name3 = Input::get('ref_contractors_company_name3');
     $ref_contractors_contact_name3 = Input::get('ref_contractors_contact_name3');
     $ref_contractors_email3 = Input::get('ref_contractors_email3');
     $data = array('list_id' => $list_id, $ObjPreQualify->tblpref . 'organization_date' => $organization_date, $ObjPreQualify->tblpref . 'business_type' => $business_type, $ObjPreQualify->tblpref . 'fed_tax_id' => $fed_tax_id, $ObjPreQualify->tblpref . 'disadvantaged_status' => $disadvantaged_status, $ObjPreQualify->tblpref . 'financial_company_secure_bond' => $financial_company_secure_bond, $ObjPreQualify->tblpref . 'financial_surety_company' => $financial_surety_company, $ObjPreQualify->tblpref . 'financial_agents_fullname' => $financial_agents_fullname, $ObjPreQualify->tblpref . 'financial_agents_email' => $financial_agents_email, $ObjPreQualify->tblpref . 'financial_available_bonding_capacity' => $financial_available_bonding_capacity, $ObjPreQualify->tblpref . 'financial_available_bonding_rate' => $financial_available_bonding_rate, $ObjPreQualify->tblpref . 'bank' => $bank, $ObjPreQualify->tblpref . 'bank_agents_fullname' => $bank_agents_fullname, $ObjPreQualify->tblpref . 'bank_agents_email' => $bank_agents_email, $ObjPreQualify->tblpref . 'insurance_com' => $insurance_com, $ObjPreQualify->tblpref . 'insurance_com_agents_fullname' => $insurance_com_agents_fullname, $ObjPreQualify->tblpref . 'insurance_com_agents_email' => $insurance_com_agents_email, $ObjPreQualify->tblpref . 'insurance_com_gen_liability_limit' => $insurance_com_gen_liability_limit, $ObjPreQualify->tblpref . 'insurance_com_workers_comp_limit' => $insurance_com_workers_comp_limit, $ObjPreQualify->tblpref . 'safety_drug_free_workplace' => $safety_drug_free_workplace, $ObjPreQualify->tblpref . 'safety_workers_comp_experience' => $safety_workers_comp_experience, $ObjPreQualify->tblpref . 'ref_vendors_company_name1' => $ref_vendors_company_name1, $ObjPreQualify->tblpref . 'ref_vendors_contact_name1' => $ref_vendors_contact_name1, $ObjPreQualify->tblpref . 'ref_vendors_email1' => $ref_vendors_email1, $ObjPreQualify->tblpref . 'ref_vendors_company_name2' => $ref_vendors_company_name2, $ObjPreQualify->tblpref . 'ref_vendors_contact_name2' => $ref_vendors_contact_name2, $ObjPreQualify->tblpref . 'ref_vendors_email2' => $ref_vendors_email2, $ObjPreQualify->tblpref . 'ref_vendors_company_name3' => $ref_vendors_company_name3, $ObjPreQualify->tblpref . 'ref_vendors_contact_name3' => $ref_vendors_contact_name3, $ObjPreQualify->tblpref . 'ref_vendors_email3' => $ref_vendors_email3, $ObjPreQualify->tblpref . 'ref_contractors_company_name1' => $ref_contractors_company_name1, $ObjPreQualify->tblpref . 'ref_contractors_contact_name1' => $ref_contractors_contact_name1, $ObjPreQualify->tblpref . 'ref_contractors_email1' => $ref_contractors_email1, $ObjPreQualify->tblpref . 'ref_contractors_company_name2' => $ref_contractors_company_name2, $ObjPreQualify->tblpref . 'ref_contractors_contact_name2' => $ref_contractors_contact_name2, $ObjPreQualify->tblpref . 'ref_contractors_email2' => $ref_contractors_email2, $ObjPreQualify->tblpref . 'ref_contractors_company_name3' => $ref_contractors_company_name3, $ObjPreQualify->tblpref . 'ref_contractors_contact_name3' => $ref_contractors_contact_name3, $ObjPreQualify->tblpref . 'ref_contractors_email3' => $ref_contractors_email3);
     if (filter_var($data[$ObjPreQualify->tblpref . 'bank_agents_email'], FILTER_VALIDATE_EMAIL) == FALSE) {
         $message = 'Bank Agents Email must have a valid email format.';
     } elseif (filter_var($data[$ObjPreQualify->tblpref . 'insurance_com_agents_email'], FILTER_VALIDATE_EMAIL) == FALSE) {
         $message = 'Insurance Company Agents Email must have a valid email format.';
     } elseif (filter_var($data[$ObjPreQualify->tblpref . 'ref_vendors_email1'], FILTER_VALIDATE_EMAIL) == FALSE) {
         $message = 'Vendors Email 1st must have a valid email format.';
     } else {
         if ($lpq_id) {
             $result = $ObjPreQualify->update_data($data, $lpq_id);
             if ($result) {
                 $message = 'Save data successful.';
             } else {
                 $message = 'Save data unsuccessful.';
             }
         } else {
             $lpq_id = $ObjPreQualify->insert_data($data);
             if ($lpq_id) {
                 $message = 'Save data successful.';
             } else {
                 $message = 'Save data unsuccessful.';
             }
         }
     }
     return Redirect::to('pre_qualify_form/' . $list_id . '/' . $lpq_id)->with('message', $message);
 }