Example #1
0
 function set_option(&$options, $key)
 {
     if ($value = urldecode($this->input->get($key))) {
         bake_cookie($key, $value);
         $options[$key] = $value;
     } else {
         burn_cookie($key);
     }
 }
Example #2
0
 function search()
 {
     $this->load->model("vendor_model", "vendor");
     $vendors = $this->vendor->get_all("vendor");
     $data["vendors"] = get_keyed_pairs($vendors, array("id", "name"), TRUE);
     $methods = $this->po->get_distinct("method");
     $data["methods"] = get_keyed_pairs($methods, array("method", "method"));
     $payment_types = $this->po->get_distinct("payment_type");
     $data["payment_types"] = get_keyed_pairs($payment_types, array("payment_type", "payment_type"));
     $categories = $this->po->get_distinct("category");
     $data["categories"] = get_keyed_pairs($categories, array("category", "category"));
     $users = $this->ion_auth->users()->result();
     $data["users"] = get_keyed_pairs($users, array("id", "first_name"), TRUE);
     $data["target"] = "po/search";
     $data["title"] = "Search Purchase Orders";
     $data["po"] = FALSE;
     $variables = array("vendor_id", "po", "method", "po_date", "payment_type", "category", "orderer_id", "billing_contact", "description", "sku", "quote");
     $where = NULL;
     foreach ($variables as $variable) {
         if ($my_variable = $this->input->get($variable)) {
             $where[$variable] = $my_variable;
             bake_cookie($variable, $my_variable);
         } else {
             burn_cookie($variable, $my_variable);
         }
     }
     $date_range = array();
     if ($start_date = $this->input->get("start_date")) {
         $date_range["start_date"] = $start_date;
     }
     if ($end_date = $this->input->get("end_date")) {
         $date_range["end_date"] = $end_date;
     }
     $data["refine"] = FALSE;
     $pos = array();
     if ($this->input->get("is_search")) {
         // active search has been submitted
         $pos = $this->po->search($where, $date_range);
         $this->load->model("item_model", "item");
         foreach ($pos as $po) {
             $po->items = $this->item->get_for_po($po->id);
         }
         $data["refine"] = TRUE;
     }
     $data['pos'] = NULL;
     if (count($pos) > 0) {
         $data['pos'] = $pos;
     }
     if ($this->input->get("ajax") == 1) {
         $this->load->view("page/modal", $data);
     } else {
         $this->load->view("page/index", $data);
     }
 }
Example #3
0
 function login()
 {
     $this->data['title'] = "Login";
     $this->data['body_classes'] = array("not-logged-in");
     // validate form input
     $this->form_validation->set_rules('identity', 'Identity', 'required');
     $this->form_validation->set_rules('password', 'Password', 'required');
     if ($this->form_validation->run() == true) {
         // check to see if the user is logging in
         // check for "remember me"
         $remember = (bool) $this->input->post('remember');
         if ($this->ion_auth->login($this->input->post('identity'), $this->input->post('password'), $remember)) {
             // if the login is successful
             // redirect them back to the home page
             $this->session->set_flashdata('message', $this->ion_auth->messages());
             if ($uri = $this->input->cookie("uri")) {
                 redirect($uri);
             } else {
                 redirect('/', 'refresh');
             }
         } else {
             // if the login was un-successful
             // redirect them back to the login page
             $this->session->set_flashdata('message', $this->ion_auth->errors());
             redirect('auth/login', 'refresh');
             // use redirects instead of loading views for compatibility with MY_Controller libraries
         }
     } else {
         // the user is not logging in so display the login page
         // set the flash data error message if there is one
         $this->data['message'] = validation_errors() ? validation_errors() : $this->session->flashdata('message');
         $this->data['identity'] = array('name' => 'identity', 'id' => 'identity', 'type' => 'email', 'value' => $this->form_validation->set_value('identity'));
         $this->data['password'] = array('name' => 'password', 'id' => 'password', 'type' => 'password');
         $this->data['target'] = 'auth/login';
         $this->_render_page('page/index', $this->data);
         bake_cookie("sale_year", get_current_year());
     }
 }
Example #4
0
 function search()
 {
     $this->load->model("vendor_model", "vendor");
     $data["developers"] = $this->_developer_list(TRUE);
     $data["statuses"] = $this->_status_list();
     $data["types"] = $this->_type_list();
     $assets = array();
     $variables = array("type", "status", "vendor_id", "name", "product", "version", "source", "po", "year_acquired", "year_removed", "serial_number");
     $where = NULL;
     foreach ($variables as $variable) {
         if ($my_variable = $this->input->get($variable)) {
             $where[$variable] = $my_variable;
             bake_cookie($variable, $my_variable);
         } else {
             burn_cookie($variable, $my_variable);
         }
     }
     if ($this->input->get("is_search")) {
         // active search has been submitted
         $assets = $this->asset->search($where);
         $data["refine"] = TRUE;
     }
     $data['assets'] = NULL;
     if (count($assets) > 0) {
         $data['assets'] = $assets;
     }
     $data["title"] = "Search Assets";
     if ($this->input->get("export")) {
         $this->load->helper("download");
         $this->load->view('asset/export', $data);
     } else {
         $data['target'] = 'asset/search';
         $this->load->view('page/index', $data);
     }
 }