public function adjust_invoice_number($invoice_id, $invoice_group_id) { $invoice = $this->mdl_invoices->get_by_id($invoice_id); if ($invoice->invoice_group_id != $invoice_group_id) { $group = parent::get_by_id($invoice_group_id); $invoice_number = ''; $date_prefix = FALSE; if ($group->invoice_group_prefix_year) { $invoice_number .= date('Y'); $date_prefix = TRUE; } if ($group->invoice_group_prefix_month) { $invoice_number .= date('m'); $date_prefix = TRUE; } if ($date_prefix) { $invoice_number .= '-'; } $invoice_number .= $group->invoice_group_prefix . str_pad($group->invoice_group_next_id, $group->invoice_group_left_pad, '0', STR_PAD_LEFT); /* Update the invoice group record with the incremented next invoice id */ $this->db->set('invoice_group_next_id', $group->invoice_group_next_id + 1); $this->db->where('invoice_group_id', $group->invoice_group_id); $this->db->update('mcb_invoice_groups'); /* Assign the invoice number to the invoice */ $this->db->set('invoice_number', $invoice_number); $this->db->set('invoice_group_id', $invoice_group_id); $this->db->where('invoice_id', $invoice_id); $this->db->update('mcb_invoices'); } }
/** * Get role by id * * @param int $id * @return object resource */ function get_by_id($id) { $row = parent::get_by_id($id); if ($row) { $row->parents = $this->get_parents($row->id); } return $row; }
/** * Description: Gets array of elements by any colum * @param string column(Column name of the current table) * @param any id (Any value of the column) * @return Array of objects */ public function get_by_id($column, $id) { $lesson_array = array($column => $id); $result = parent::get_by_id($lesson_array, false); return $result; }
public function get_by_id($primary_key_value, $fields = '') { $fields_hack = '*,(select brand_description from product_brands pb where pb.brand_id = products.product_brand_id) brand_name'; return parent::get_by_id($primary_key_value, $fields_hack); }
/** * Get user by id * * @param int $id * @return array|boolean */ function get_by_id($id) { $this->db->select($this->table . '.*, ' . $this->role_table . '.name AS role_name')->join($this->role_table, $this->role_table . '.id = ' . $this->table . '.role_id', 'left'); return parent::get_by_id($id); }