public function get($from_date = NULL, $to_date = NULL, $client_id = NULL) { $from_date = $from_date ? strtotime(standardize_date($from_date)) : NULL; $to_date = $from_date ? strtotime(standardize_date($to_date)) : NULL; $this->db->select(' mcb_invoice_items.item_name, mcb_invoice_items.item_price, SUM(mcb_invoice_items.item_qty) AS sum_item_qty, SUM(mcb_invoice_item_amounts.item_subtotal) AS sum_item_subtotal, SUM(mcb_invoice_item_amounts.item_total) AS sum_item_total'); $this->db->join('mcb_invoice_items', 'mcb_invoice_items.invoice_id = mcb_invoices.invoice_id'); $this->db->join('mcb_invoice_item_amounts', 'mcb_invoice_item_amounts.invoice_item_id = mcb_invoice_items.invoice_item_id'); $this->db->group_by('mcb_invoice_items.item_name, mcb_invoice_items.item_price'); $this->db->order_by('item_name'); if ($from_date) { $this->db->where('item_date >=', $from_date); } if ($to_date) { $this->db->where('item_date <=', $to_date); } if ($client_id) { $this->db->where('client_id', $client_id); } $this->db->where('invoice_is_quote', 0); if (!$this->session->userdata('global_admin')) { $this->db->where('mcb_invoices.user_id', $this->session->userdata('user_id')); } return $this->db->get('mcb_invoices')->result(); }
public function standardize_date() { $date = $this->input->post('date'); log_message('DEBUG', 'Date Received: ' . $date); log_message('DEBUG', 'Date Sent: ' . standardize_date($date)); echo strtotime(standardize_date($date)); }
function save() { /* * As per the config file, this function will * execute when the core system settings are saved. */ if ($this->input->post('dashboard_show_open_invoices')) { $this->mdl_mcb_data->save('dashboard_show_open_invoices', 'TRUE'); } else { $this->mdl_mcb_data->save('dashboard_show_open_invoices', 'FALSE'); } if ($this->input->post('dashboard_show_closed_invoices')) { $this->mdl_mcb_data->save('dashboard_show_closed_invoices', 'TRUE'); } else { $this->mdl_mcb_data->save('dashboard_show_closed_invoices', 'FALSE'); } if ($this->input->post('dashboard_show_pending_invoices')) { $this->mdl_mcb_data->save('dashboard_show_pending_invoices', 'TRUE'); } else { $this->mdl_mcb_data->save('dashboard_show_pending_invoices', 'FALSE'); } if ($this->input->post('dashboard_show_overdue_invoices')) { $this->mdl_mcb_data->save('dashboard_show_overdue_invoices', 'TRUE'); } else { $this->mdl_mcb_data->save('dashboard_show_overdue_invoices', 'FALSE'); } $this->mdl_mcb_data->save('dashboard_override', $this->input->post('dashboard_override')); $this->mdl_mcb_data->save('dashboard_total_paid_cutoff_date', strtotime(standardize_date($this->input->post('dashboard_total_paid_cutoff_date')))); }
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; }
function update_date($id, $new_date) { /* Standardize the SQL date format. */ $new_date = standardize_date($new_date); /* Create a blog object. */ $blog = new Blog(createPDO()); /* Attempt to update the date. */ return $blog->update_post_date(intval($id), $new_date); }
public function db_array() { $db_array = parent::db_array(); $db_array['invoice_id'] = uri_assoc('invoice_id', 4); if (!$this->input->post('is_taxable')) { $db_array['is_taxable'] = 0; } $db_array['item_date'] = strtotime(standardize_date($db_array['item_date'])); return $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; }
public function invoice_params() { $params = array('where' => array('mcb_invoices.invoice_date_entered >=' => strtotime(standardize_date($this->input->post('from_date'))), 'mcb_invoices.invoice_date_entered <=' => strtotime(standardize_date($this->input->post('to_date'))))); if ($this->input->post('client_id') != 'all') { $params['where']['mcb_invoices.client_id'] = $this->input->post('client_id'); } if ($this->input->post('status_select') == 'open') { $params['where']['mcb_invoices.invoice_status_id'] = 1; } elseif ($this->input->post('status_select') == 'pending') { $params['where']['mcb_invoices.invoice_status_id'] = 2; } elseif ($this->input->post('status_select') == 'closed') { $params['where']['mcb_invoices.invoice_status_id'] = 3; } return $params; }
function save() { $db_array = parent::db_array(); if (!uri_assoc('task_id', 3)) { $db_array['user_id'] = $this->session->userdata('user_id'); } if (isset($db_array['due_date']) and $db_array['due_date']) { $db_array['due_date'] = strtotime(standardize_date($db_array['due_date'])); } if (isset($db_array['complete_date']) and $db_array['complete_date']) { $db_array['complete_date'] = strtotime(standardize_date($db_array['complete_date'])); } $db_array['start_date'] = strtotime(standardize_date($db_array['start_date'])); parent::save($db_array, uri_assoc('task_id', 3)); }
<!-- POSTS --> <div class="row column"> <?php /* Set defaults for the post query. */ $start_date = standardize_date("-3 years"); $end_date = standardize_date(); /* The site will paginate posts based on an array begin and end index. */ $array_start = 0; $array_end = POSTS_PER_PAGE; /* If the GET variables start_date and end_date are defined in the URL, use those in * the query. */ if (isset($_GET["start_date"])) { $start_date = standardize_date($_GET["start_date"]); } if (isset($_GET["end_date"])) { $end_date = standardize_date($_GET["end_date"]); } /* The begin and end indices for pagination may be passed as a GET variable * Pages start at 0. */ if (isset($_GET["page"])) { $array_start = intval($_GET["page"]) * POSTS_PER_PAGE; $array_end = $array_start + POSTS_PER_PAGE; } /* Get the posts from the database and slice the array according to given pagination * rules. */ $posts = $blog->query_posts($start_date, $end_date); $posts_view = array_slice($posts, $array_start, $array_end); /* Begin rendering the posts using PHP's alternate control structure syntax. */ ?> <?php
public function quote_to_invoice($invoice_id, $invoice_date_entered, $invoice_group_id) { $this->load->model(array('mdl_invoice_groups', 'inventory/mdl_inventory_stock')); $db_array = array('invoice_is_quote' => 0, 'invoice_date_entered' => strtotime(standardize_date($invoice_date_entered))); $this->db->where('invoice_id', $invoice_id); $this->db->update('mcb_invoices', $db_array); $this->mdl_invoice_groups->adjust_invoice_number($invoice_id, $invoice_group_id); $this->db->where('invoice_id', $invoice_id); $items = $this->db->get('mcb_invoice_items')->result(); foreach ($items as $item) { if ($item->inventory_id) { $this->mdl_inventory_stock->adjust($item->inventory_id, $item->item_qty * -1, $item->invoice_item_id); } } }
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); } }
public function ajax_search() { $date_form = $this->input->post('date_form'); $date_to = $this->input->post('to_date'); $params = array(); if ($date_form) { $params['where']['mcb_expense_date >='] = strtotime(standardize_date($date_form)); } if ($date_to) { $params['where']['mcb_expense_date <='] = strtotime(standardize_date($date_to)); } else { if ($date_form && $date_to) { $params['where']['mcb_expense_date BETWEEN '] = strtotime(standardize_date($date_form)) . '" AND "' . strtotime(standardize_date($date_to)) . '"'; } } $data = array('expenses' => $this->mdl_expenses->get($params)); $data["e"] = "sucessful"; $this->load->view('expense_search_view', $data); }
public function quote_to_invoice($invoice_id, $invoice_date_entered, $invoice_group_id) { $db_array = array('invoice_is_quote' => 0, 'invoice_date_entered' => strtotime(standardize_date($invoice_date_entered))); $this->db->where('invoice_id', $invoice_id); $this->db->update('mcb_invoices', $db_array); $this->load->model('mdl_invoice_groups'); $this->mdl_invoice_groups->adjust_invoice_number($invoice_id, $invoice_group_id); }
public function save_expense($id) { $data = array('mcb_expense_name' => $this->input->post('mcb_expense_name'), 'expense_category_id' => $this->input->post('expense_category_id'), 'mcb_expense_date' => strtotime(standardize_date($this->input->post('mcb_expense_date'))), 'mcb_expense_amount' => $this->input->post('mcb_expense_amount'), 'mcb_expense_note' => $this->input->post('mcb_expense_note'), 'client_id' => $this->input->post('client_id'), 'mcb_expense_payto' => $this->input->post('mcb_expense_payto')); $this->db->insert('mcb_expense', $data); return $this->db->insert_id(); }