Exemplo n.º 1
0
 function build($id = FALSE)
 {
     if ($_POST) {
         unset($_POST['send']);
         $_POST["user_id"] = $this->user->id;
         if ($id != FALSE) {
             $quote = Customquote::find_by_id($id);
             $quote = $quote->update_attributes($_POST);
             if (!$quote) {
                 $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_quotation_form_update_error'));
             } else {
                 $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_quotation_form_update_success'));
             }
         } else {
             $quote = Customquote::create($_POST);
             if (!$quote) {
                 $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_quotation_form_add_error'));
             } else {
                 $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_quotation_form_add_success'));
             }
         }
         redirect('quotations/quoteforms');
     }
     $this->view_data['submenu'] = array($this->lang->line('application_back') => 'quotations');
     $this->content_view = 'quotations/formbuilder';
 }