public function db_array() { $db_array = parent::db_array(); if (uri_assoc('mcb_expense_id')) { $db_array['mcb_expense_id'] = uri_assoc('mcb_expense_id'); } else { if ($this->input->post('mcb_expense_id')) { $db_array['mcb_expense_id'] = $this->input->post('mcb_expense_id'); } } $db_array['mcb_expense_date'] = strtotime(standardize_date($db_array['mcb_expense_date'])); $db_array['mcb_expense_amount'] = standardize_number($db_array['mcb_expense_amount']); $db_array['mcb_base_expense_amount'] = standardize_number($db_array['mcb_base_expense_amount']); $db_array['mcb_expense_tax_amount'] = standardize_number($db_array['mcb_expense_tax_amount']); $db_array['mcb_expense_tax2_amount'] = standardize_number($db_array['mcb_expense_tax2_amount']); $db_array['expense_invoice_with_tax2'] = standardize_number($db_array['expense_invoice_with_tax2']); if (isset($db_array['expense_invoice_yesno'])) { $db_array['expense_invoice_yesno'] = $this->_standardize_checkbox($db_array['expense_invoice_yesno']); } else { $db_array['expense_invoice_yesno'] = 0; } if (isset($db_array['expense_payed'])) { $db_array['expense_payed'] = $this->_standardize_checkbox($db_array['expense_payed']); } else { $db_array['expense_payed'] = 0; } if (!isset($db_array['expense_paymentTypeId'])) { $db_array['expense_paymentTypeId'] = 0; } $db_array['expense_invoice_date'] = strtotime(standardize_date($db_array['expense_invoice_date'])); $db_array['expense_invoice_overdue_date'] = strtotime(standardize_date($db_array['expense_invoice_overdue_date'])); return $db_array; }
public function jquery_adjust_stock() { $this->load->model('inventory/mdl_inventory_stock'); $inventory_id = $this->input->post('inventory_id'); $inventory_stock_quantity = standardize_number($this->input->post('inventory_stock_quantity')); $inventory_stock_notes = $this->input->post('inventory_stock_notes'); $this->mdl_inventory_stock->adjust($inventory_id, $inventory_stock_quantity, 0, $inventory_stock_notes); }
public function db_array() { $db_array = parent::db_array(); unset($db_array['client_id_autocomplete_label']); $db_array['client_credit_date'] = strtotime(standardize_date($db_array['client_credit_date'])); $db_array['client_credit_amount'] = standardize_number($db_array['client_credit_amount']); return $db_array; }
public function db_array() { $db_array = parent::db_array(); $db_array['inventory_unit_price'] = standardize_number($db_array['inventory_unit_price']); if (!isset($db_array['inventory_track_stock'])) { $db_array['inventory_track_stock'] = 0; } return $db_array; }
public function save($db_array, $invoice_item_id = NULL) { /* Transform these two vars to standard number format */ $db_array['item_qty'] = standardize_number($db_array['item_qty']); $db_array['item_price'] = standardize_number($db_array['item_price']); parent::save($db_array, $invoice_item_id); if ($this->input->post('save_as_inventory') and $db_array['inventory_id'] == 'please_select') { $db_array = array('inventory_name' => $db_array['item_name'], 'inventory_unit_price' => $db_array['item_price'], 'inventory_description' => $db_array['item_description']); $this->db->insert('mcb_inventory', $db_array); } }
public function save($db_array, $invoice_item_id = NULL) { /* Transformar aquestes dues variables a format numèric estàndard */ $db_array['item_qty'] = standardize_number($db_array['item_qty']); $db_array['item_price'] = standardize_number($db_array['item_price']); parent::save($db_array, $invoice_item_id); if ($this->input->post('save_as_inventory')) { $db_array = array('inventory_name' => $db_array['item_name'], 'inventory_unit_price' => $db_array['item_price'], 'inventory_description' => $db_array['item_description']); $this->db->insert('mcb_inventory', $db_array); } }
public function db_array() { $db_array = parent::db_array(); if (uri_assoc('invoice_id')) { $db_array['invoice_id'] = uri_assoc('invoice_id'); } elseif ($this->input->post('invoice_id')) { $db_array['invoice_id'] = $this->input->post('invoice_id'); } $db_array['payment_date'] = strtotime(standardize_date($db_array['payment_date'])); $db_array['payment_amount'] = standardize_number($db_array['payment_amount']); return $db_array; }
function format_number($num = NULL, $standardize = TRUE, $decimals = 2) { global $CI; if (!$num) { $num = 0; } if ($standardize) { return number_format(standardize_number($num), $decimals, $CI->mdl_mcb_data->setting('decimal_symbol'), $CI->mdl_mcb_data->setting('thousands_separator')); } else { return number_format($num, $decimals, $CI->mdl_mcb_data->setting('decimal_symbol'), $CI->mdl_mcb_data->setting('thousands_separator')); } }
public function save_invoice_options($custom_fields = NULL) { $invoice_id = uri_assoc('invoice_id'); $this->db->where('invoice_id', $invoice_id); $db_array = array('client_id' => $this->input->post('client_id'), 'invoice_date_entered' => strtotime(standardize_date($this->input->post('invoice_date_entered'))), 'invoice_notes' => $this->input->post('invoice_notes'), 'user_id' => $this->input->post('user_id'), 'invoice_number' => $this->input->post('invoice_number')); if (!$this->input->post('invoice_date_entered')) { unset($db_array['invoice_date_entered']); } if (is_numeric($this->input->post('invoice_status_id'))) { $db_array['invoice_status_id'] = $this->input->post('invoice_status_id'); } if ($this->input->post('invoice_due_date')) { $db_array['invoice_due_date'] = strtotime(standardize_date($this->input->post('invoice_due_date'))); } if ($custom_fields) { foreach ($custom_fields as $custom_field) { $db_array[$custom_field->column_name] = $this->input->post($custom_field->column_name); } } $this->db->update($this->table_name, $db_array); $this->db->where('invoice_id', $invoice_id); $this->db->delete('mcb_invoice_tax_rates'); foreach ($this->input->post('tax_rate_id') as $key => $tax_rate_id) { $db_array = array('invoice_id' => $invoice_id, 'tax_rate_id' => $tax_rate_id, 'tax_rate_option' => $_POST['tax_rate_option'][$key]); $this->db->insert('mcb_invoice_tax_rates', $db_array); } $this->load->model('mdl_invoice_tags'); $this->mdl_invoice_tags->save_tags($invoice_id, $this->input->post('tags')); $db_array = array('invoice_shipping' => standardize_number($this->input->post('invoice_shipping')), 'invoice_discount' => standardize_number($this->input->post('invoice_discount'))); $this->db->where('invoice_id', $invoice_id); $this->db->update('mcb_invoice_amounts', $db_array); $this->load->model('invoices/mdl_invoice_history'); $this->mdl_invoice_history->save($invoice_id, $this->session->userdata('user_id'), $this->lang->line('saved_invoice_options')); $this->session->set_flashdata('custom_success', $this->lang->line('invoice_options_saved')); }
function index() { $this->load->model(array('mdl_invoice_search', 'clients/mdl_clients', 'invoice_statuses/mdl_invoice_statuses')); if (!$this->mdl_invoice_search->validate()) { $this->load->model('clients/mdl_clients'); $this->load->model('invoice_statuses/mdl_invoice_statuses'); $client_params = array('select' => 'mcb_clients.client_id, mcb_clients.client_name'); $data = array('clients' => $this->mdl_clients->get($client_params), 'invoice_statuses' => $this->mdl_invoice_statuses->get()); $this->load->view('search', $data); } else { $params = array(); if (!$this->session->userdata('global_admin')) { $params['where']['mcb_invoices.user_id'] = $this->session->userdata('user_id'); } if (!$this->input->post('include_quotes')) { $params['where']['mcb_invoices.invoice_is_quote'] = 0; } /* Parse tags if posted */ if ($this->input->post('tags')) { /* Remove any apostrophes and trim */ $tags = trim(str_replace("'", '', $this->input->post('tags'))); /** * Explode into an array and trim each individual element * if comma separated tags are provided */ if (strpos($tags, ',')) { $tags = explode(',', $tags); foreach ($tags as $key => $tag) { $tags[$key] = trim($tag); } $tags = implode("','", $tags); } /* Add the tag where $params array element */ $params['where'][] = "mcb_invoices.invoice_id IN (SELECT invoice_id FROM mcb_invoice_tags WHERE tag_id IN (SELECT tag_id FROM mcb_tags WHERE tag IN('" . $tags . "')))"; } /* Add any clients if selected */ if ($this->input->post('client_id')) { $params['where_in']['mcb_invoices.client_id'] = $this->input->post('client_id'); } /* Add any invoice statuses if selected */ if ($this->input->post('invoice_status_id')) { $params['where_in']['mcb_invoices.invoice_status_id'] = $this->input->post('invoice_status_id'); } /* Add from date if provided */ if ($this->input->post('from_date')) { $params['where']['mcb_invoices.invoice_date_entered >='] = strtotime(standardize_date($this->input->post('from_date'))); } /* Add to date if provided */ if ($this->input->post('to_date')) { $params['where']['mcb_invoices.invoice_date_entered <='] = strtotime(standardize_date($this->input->post('to_date'))); } /* Add invoice id if provided */ if ($this->input->post('invoice_number')) { $params['where'][] = "mcb_invoices.invoice_number LIKE '%" . $this->input->post('invoice_number') . "%'"; } /* Add amount if provided */ if ($this->input->post('amount_operator') and check_clean_number($this->input->post('amount'))) { if ($this->input->post('amount_operator') != '=') { $params['where']['mcb_invoice_amounts.invoice_total ' . $this->input->post('amount_operator')] = standardize_number($this->input->post('amount')); } else { $params['where']['mcb_invoice_amounts.invoice_total'] = standardize_number($this->input->post('amount')); } } if (!$params) { redirect('invoice_search'); } /* Generate a simple hash value */ $hash = md5(time()); /* Stick this stuff in the users session data */ $userdata = array('search_hash' => array($hash => $params)); $this->session->set_userdata($userdata); /* Redirect to display results */ redirect('invoice_search/search_results/' . $this->input->post('output_type') . '/search_hash/' . $hash); } }