예제 #1
0
 function form($support_ticket_id = false)
 {
     $this->load->helper('form');
     $this->load->helper('date_helper');
     $this->load->library('form_validation');
     $this->template->set('title', "Support Tickets");
     // Get topics lists discussion from this topic - List and the form to Update the Topic.
     $data['topics'] = $this->ticket_model->get_supportticket_topics($support_ticket_id);
     // Get categories list on the view topic page of Tickets
     $categories = $this->ticket_model->get_ticketscategory();
     $data['category_list'] = $categories;
     $this->form_validation->set_rules('message', 'reply', 'trim|required');
     $this->form_validation->set_rules('close', 'close');
     if ($this->form_validation->run() == FALSE) {
         $this->template->load('templates/admin/brainlight', 'admin/tickets/ticket_form', $data);
     } else {
         $save['item'] = $this->input->post('message');
         $save['added_on'] = now_time();
         $save['support_ticket_id'] = $support_ticket_id;
         $save['support'] = 1;
         if ($this->input->post('close') == "1") {
             $save_ticket['date_closed'] = now_time();
         }
         $save_ticket['priority'] = $this->input->post('priority');
         $this->ticket_model->save_ticket($save, $save_ticket);
         $this->session->set_flashdata('message', 'Your reply to the discussion posted successfully.');
         // go back to the customer list
         redirect('admin/tickets/form/' . $support_ticket_id);
     }
 }
예제 #2
0
 function form($id = false)
 {
     $this->load->helper('form');
     $this->load->helper('date_helper');
     $this->load->library('form_validation');
     $this->template->set('title', lang('customer_form'));
     //default values are empty if the customer is new
     $data['id'] = '';
     $data['group_id'] = '';
     $data['firstname'] = '';
     $data['lastname'] = '';
     $data['email'] = '';
     $data['phone'] = '';
     $data['company'] = '';
     $data['email_subscribe'] = '';
     $data['active'] = false;
     // get group list
     $groups = $this->customer_model->get_groups();
     foreach ($groups as $group) {
         $group_list[$group->id] = $group->name;
     }
     $data['group_list'] = $group_list;
     //update customer
     if ($id) {
         $this->customer_id = $id;
         $customer = $this->customer_model->get_customer($id);
         //if the customer does not exist, redirect them to the customer list with an error
         if (!$customer) {
             $this->session->set_flashdata('error', lang('error_not_found'));
             redirect('admin/customers');
         }
         //set values to db values
         $data['id'] = $customer->id;
         $data['group_id'] = $customer->group_id;
         $data['firstname'] = $customer->firstname;
         $data['lastname'] = $customer->lastname;
         $data['email'] = $customer->email;
         $data['phone'] = $customer->phone;
         $data['company'] = $customer->company;
         $data['active'] = $customer->active;
         $data['email_subscribe'] = $customer->email_subscribe;
     }
     $this->form_validation->set_rules('firstname', 'firstname', 'trim|required|max_length[32]');
     $this->form_validation->set_rules('lastname', 'lastname', 'trim|required|max_length[32]');
     $this->form_validation->set_rules('email', 'email', 'trim|required|valid_email|max_length[128]|callback_check_email');
     $this->form_validation->set_rules('phone', 'phone', 'trim|required|max_length[32]');
     $this->form_validation->set_rules('company', 'company', 'trim|max_length[128]');
     $this->form_validation->set_rules('active', 'active');
     $this->form_validation->set_rules('group_id', 'group', 'numeric');
     $this->form_validation->set_rules('email_subscribe', 'ubscribe', 'numeric|max_length[1]');
     //if this is a new account require a password, or if they have entered either a password or a password confirmation
     if ($this->input->post('password') != '' || $this->input->post('confirm') != '' || !$id) {
         $this->form_validation->set_rules('password', 'password', 'required|min_length[6]|sha1');
         $this->form_validation->set_rules('confirm', 'confirm password', 'required|matches[password]');
     }
     if ($this->form_validation->run() == FALSE) {
         $this->template->load('templates/admin/brainlight', 'admin/customers/customer_form', $data);
     } else {
         $save['id'] = $id;
         $save['group_id'] = $this->input->post('group_id');
         $save['firstname'] = $this->input->post('firstname');
         $save['lastname'] = $this->input->post('lastname');
         $save['email'] = $this->input->post('email');
         $save['phone'] = $this->input->post('phone');
         $save['company'] = $this->input->post('company');
         $save['active'] = $this->input->post('active');
         $save['registered_on'] = now_time();
         $save['email_subscribe'] = $this->input->post('email_subscribe');
         if ($this->input->post('password') != '' || !$id) {
             $save['password'] = $this->input->post('password');
         }
         $this->customer_model->save($save);
         $this->session->set_flashdata('message', lang('message_saved_customer'));
         //go back to the customer list
         redirect('admin/customers');
     }
 }