public function fetchAll($limit, $offset, $args = array()) { $return = array('rows' => array(), 'num_rows' => array()); $this->db->start_cache(); if (sizeof($args) > 1) { if (strlen($args['search_string'])) { $this->db->like('funder', $args['search_string'])->or_like('address', $args['search_string'])->or_like('city', $args['search_string'])->or_like('state', $args['search_string'])->or_like('zip', $args['search_string'])->or_like('website', $args['search_string']); } foreach ($args['filters']['search_type'] as $key => $a) { $search = ''; switch ($args['filters']['search_type'][$key]) { case 'equals': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->where($args['filters']['search_val'][$key], date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; case 'not_equal': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->where($args['filters']['search_val'][$key] . ' !=', date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; case 'less_than': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->where($args['filters']['search_val'][$key] . ' <', date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; case 'less_than_equal': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->where($args['filters']['search_val'][$key] . ' <=', date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; case 'greater_than': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->where($args['filters']['search_val'][$key] . ' >', date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; case 'greater_than_equal': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->where($args['filters']['search_val'][$key] . ' >=', date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; case 'like': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->like($args['filters']['search_val'][$key], date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; } } } $this->db->stop_cache(); $data = $this->db->select('*')->from('lasr_support_group')->limit($limit, $offset)->get(); if ($data->num_rows > 0) { $return['rows'] = $data->result(); } $c = $this->db->select('count(*) as count', false)->from('lasr_support_group'); $tmp = $c->get()->result(); $return['num_rows'] = $tmp[0]->count; $this->db->flush_cache(); return $return; }
public function update_project($id, $data, $uploads) { $user = $this->users_model->get_user($data['res_staff']); $main = array('project_type' => $data['project_type'], 'date_created' => date('Y-m-d H:i:s'), 'first_name' => $user->meta['first_name'], 'last_name' => $user->meta['last_name'], 'grant_title' => $data['grant_title'], 'current_status' => $data['current_status'], 'fin_dept_title' => $data['fin_dept_title'], 'total_amt_grant' => $data['total_amt_grant'], 'start_date' => date_for_db($data['start_date']), 'end_date' => date_for_db($data['end_date']), 'res_staff' => $data['res_staff'], 'py_bal_fwd' => $data['py_bal_fwd'], 'grantor' => $data['grantor'], 'org_request' => $data['org_request'], 'date_of_request' => date_for_db($data['date_of_request']), 'decision_date' => date_for_db($data['decision_date']), 'fund_date' => date_for_db($data['fund_date']), 'amount_pending' => $data['amount_pending'], 'program_area' => $data['program_area'], 'add_info' => $data['add_info'], 'comments' => $data['comments']); if (strlen($uploads['account_list'])) { $main['account_list'] = $uploads['account_list']; } $this->db->where('ID', $id)->update('grant_fund_projects', $main); foreach ($data['schedule'] as $dummy => $value) { foreach ($value as $key => $val) { $this->create_meta($id, $key, $val, 'finance_schedule'); } } foreach ($data['expenses'] as $dummy => $value) { foreach ($value as $key => $val) { $this->create_meta($id, $key, $val, 'finance_expenses'); } } foreach ($data['cumulative_expenses'] as $dummy => $value) { foreach ($value as $key => $val) { $this->create_meta($id, $key, $val, 'finance_cumulative_expenses'); } } foreach ($data['income'] as $dummy => $value) { foreach ($value as $key => $val) { $this->create_meta($id, $key, $val, 'finance_income'); } } foreach ($data['cumulative_total'] as $dummy => $value) { foreach ($value as $key => $val) { $this->create_meta($id, $key, $val, 'finance_cumulative_total'); } } foreach ($uploads['report'] as $dummy => $value) { foreach ($value as $key => $val) { $this->create_meta($id, $key, $val, 'finance_reports'); } } }
public function update_timesheet($temp, $ts_id, $user_id, $type = 'real') { if ($type != 'real') { $info = $this->users_model->get_user($user_id); $data['first_name'] = $info->meta['first_name']; $data['last_name'] = $info->meta['last_name']; $data['manager'] = $info->user_manager; $data['current_status'] = 'In Process'; $data['period_start'] = date_for_db('0000/00/00'); $data['period_end'] = date_for_db('0000/00/00'); } else { $data['first_name'] = $temp['first_name']; $data['last_name'] = $temp['last_name']; $data['manager'] = $temp['manager']; $data['period_start'] = date_for_db($temp['period_start']); $data['period_end'] = date_for_db($temp['period_end']); $data['accounts'] = base64_encode(serialize($this->users_model->get_labor_accounts($user_id))); } if (isset($this->user->meta['grant_matching']) && $this->user->meta['grant_matching'] == 'Yes') { $data['gweek1'] = base64_encode(serialize($temp['gweek1'])); $data['gweek2'] = base64_encode(serialize($temp['gweek2'])); } $data['week1'] = base64_encode(serialize($temp['week1'])); $data['week2'] = base64_encode(serialize($temp['week2'])); $data['week1_total'] = $temp['week1']['total_hours_total']; $data['week2_total'] = $temp['week2']['total_hours_total']; $data['last_edit'] = date('Y-m-d H:i:s'); $data['type'] = $type; $data['chargable_hours'] = $temp['summary']['chargable_hours']; $data['holiday'] = $temp['summary']['holiday']; $data['unpaid_time_off'] = $temp['summary']['unpaid_time_off']; $data['personal_time'] = $temp['summary']['personal_time']; $data['total_hours'] = $temp['summary']['total_hours']; $data['vacation'] = $temp['summary']['vacation']; $data['sicktime'] = $temp['summary']['sicktime']; $data['birthday'] = $temp['summary']['birthday']; $data['other'] = $temp['summary']['other']; if ($temp['submit_request'] == 'Submit for Approval') { $data['current_status'] = 'Submitted for Approval'; user_notifier::set_data($data); user_notifier::set_user($user_id); user_notifier::set_template('timesheet', 'submit_for_approval'); } else { if ($temp['submit_request'] == 'Approve') { $data['current_status'] = 'Approved'; user_notifier::set_data($data); user_notifier::set_user($user_id); user_notifier::set_template('timesheet', 'approve'); } else { if ($temp['submit_request'] == 'Create New Timesheet for the Current Pay Period from this Template') { $data['current_status'] = 'In Process'; $data['period_start'] = date('Y/m/j', strtotime('saturday last week', time())); $data['period_end'] = date('Y/m/j', strtotime('friday next week', time())); $data['accounts'] = base64_encode(serialize($this->users_model->get_labor_accounts($user_id))); } else { if ($temp['submit_request'] == 'Send Back to User' || !isset($temp['current_status'])) { $data['current_status'] = 'In Process'; user_notifier::set_data($data); user_notifier::set_user($user_id); user_notifier::set_template('timesheet', 'send_back_to_user'); } else { $data['current_status'] = $temp['current_status']; } } } } if ($type == 'real') { user_notifier::send(); } $this->db->where('ID', $ts_id)->update('timesheets', $data); }
public function update_caller($data) { $id = $data['update_caller']; $update_data = array('entered_by' => $data['entered_by'], 'took_call' => $data['took_call'], 'date_of_call' => date_for_db($data['date_of_call']), 'first_name' => $data['first_name'], 'last_name' => $data['last_name'], 'address' => $data['address'], 'city' => $data['city'], 'state' => $data['state'], 'zip' => $data['zip'], 'phone' => $data['phone'], 'email' => $data['email'], 'gender' => $data['gender'], 'dob' => date_for_db($data['dob']), 'language' => $data['language'], 'ethnicity' => $data['ethnicity'], 'education' => $data['education'], 'relationship' => $data['relationship'], 'reason' => $data['reason'], 'pwd_gender' => $data['pwd_gender'], 'pwd_birthday' => date_for_db($data['pwd_birthday']), 'pwd_ethnicity' => $data['pwd_ethnicity'], 'pwd_education' => $data['pwd_education'], 'pwd_diagnosis_date' => date_for_db($data['pwd_diagnosis_date']), 'pwd_diagnosis_type' => $data['pwd_diagnosis_type'], 'call_created_by' => serialize($data['call_created_by']), 'call_date' => serialize($data['call_date']), 'call_status' => serialize($data['call_status']), 'call_notes' => serialize($data['call_notes'])); $this->db->where('ID', $id)->update('helpline_callers', $update_data); }
public function get_timeoff_requests($user_id, $limit, $offset, $args = array()) { $return = array('rows' => array(), 'num_rows' => array()); $this->db->start_cache(); if ($user_id > 0) { $this->db->where(" (`user_id` = {$user_id} OR `manager` = {$user_id})", NULL, FALSE); } if (sizeof($args) > 1) { if (strlen($args['search_string'])) { $this->db->like('first_name', $args['search_string'])->or_like('last_name', $args['search_string'])->or_like('request_start', date_for_db($args['search_string']))->or_like('request_end', date_for_db($args['search_string']))->or_like('date_created', date_for_db($args['search_string']))->or_like('current_status', $args['search_string']); } foreach ($args['filters']['search_type'] as $key => $a) { $search = ''; switch ($args['filters']['search_type'][$key]) { case 'equals': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->where($args['filters']['search_val'][$key], date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; case 'not_equal': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->where($args['filters']['search_val'][$key] . ' !=', date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; case 'less_than': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->where($args['filters']['search_val'][$key] . ' <', date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; case 'less_than_equal': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->where($args['filters']['search_val'][$key] . ' <=', date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; case 'greater_than': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->where($args['filters']['search_val'][$key] . ' >', date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; case 'greater_than_equal': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->where($args['filters']['search_val'][$key] . ' >=', date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; case 'like': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->like($args['filters']['search_val'][$key], date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; } } } $this->db->stop_cache(); $this->db->limit($limit, $offset); if ($this->input->get('sort')) { foreach ($this->input->get('sort') as $sort) { $sort = explode('|', $sort); $this->db->order_by($sort[0], $sort[1]); } } else { $this->db->order_by('date_created', 'desc'); } $t = $this->db->get('timeoff_requests'); if ($t->num_rows > 0) { $return['rows'] = $t->result(); } $c = $this->db->select('count(*) as count', false)->from('timeoff_requests'); $tmp = $c->get()->result(); $return['num_rows'] = $tmp[0]->count; $this->db->flush_cache(); return $return; }
public function update_budget($temp, $id) { $meta = $temp['meta']; $data['title'] = $temp['title']; $data['fund'] = $temp['fund']; $data['location'] = $temp['location']; $data['division'] = $temp['division']; $data['dept'] = $temp['dept']; $data['grant'] = $temp['grant']; $data['project'] = $temp['project']; $data['prior_year'] = $temp['prior_year']; $data['ex_comp_date'] = date_for_db($temp['ex_comp_date']); $data['status'] = $temp['status']; $data['manager'] = $temp['manager']; $data['director'] = $temp['director']; $data['prep_status'] = $temp['prep_status']; $data['comment'] = $temp['comment']; $this->db->where('ID', $id); $this->db->update('budget', $data); foreach ($meta as $key => $val) { $this->db->where(array('meta_key' => $key, 'budget_id' => $id)); $this->db->update('budget_meta', array('meta_value' => is_array($meta[$key]) ? base64_encode(serialize($meta[$key])) : $val)); } }
public function get_travel_requests($user_id = 0, $limit, $offset, $args = array()) { $return = array('rows' => array(), 'num_rows' => array()); $this->db->start_cache(); if ($user_id > 0) { $this->db->where('user_id', $user_id); $this->db->or_where('manager', $user_id); } if (sizeof($args) > 1) { if (strlen($args['search_string'])) { $this->db->like('first_name', $args['search_string'])->or_like('last_name', $args['search_string'])->or_like('for_month', $args['search_string'])->or_like('date_created', date_for_db($args['search_string']))->or_like('current_status', $args['search_string']); } foreach ($args['filters']['search_type'] as $key => $a) { $search = ''; switch ($args['filters']['search_type'][$key]) { case 'equals': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->where($args['filters']['search_val'][$key], date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; case 'not_equal': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->where($args['filters']['search_val'][$key] . ' !=', date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; case 'less_than': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->where($args['filters']['search_val'][$key] . ' <', date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; case 'less_than_equal': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->where($args['filters']['search_val'][$key] . ' <=', date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; case 'greater_than': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->where($args['filters']['search_val'][$key] . ' >', date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; case 'greater_than_equal': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->where($args['filters']['search_val'][$key] . ' >=', date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; case 'like': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->like($args['filters']['search_val'][$key], date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; } } } $this->db->stop_cache(); $this->db->limit($limit, $offset); if ($this->input->get('sort')) { foreach ($this->input->get('sort') as $sort) { $sort = explode('|', $sort); $this->db->order_by($sort[0], $sort[1]); } } else { $this->db->order_by('date_created', 'desc'); } $t = $this->db->get('travel_requests'); $return = array(); $i = 0; if ($t->num_rows > 0) { $c = $this->db->select('count(*) as count', false)->from('travel_requests'); $tmp = $c->get()->result(); $return['num_rows'] = $tmp[0]->count; $this->db->flush_cache(); foreach ($t->result() as $result) { $return['rows'][$i]['details'] = $result; $d = $this->db->where('travel_id', $result->ID)->get('travel_request_details'); foreach ($d->result() as $m) { $return['rows'][$i]['details']->travel_to .= $m->travel_to . '<br />'; $return['rows'][$i]['details']->travel_from .= $m->travel_from . '<br />'; } $i++; } return $return; } $this->db->flush_cache(); return array(); }
public function getVolunteerList($limit, $offset, $args = array()) { $return = array('rows' => array(), 'num_rows' => array()); $this->db->start_cache(); if ($this->input->get('sort')) { foreach ($this->input->get('sort') as $sort) { $sort = explode('|', $sort); $this->db->order_by($sort[0], $sort[1]); } } else { $this->db->order_by('ID', 'ASC'); } if (sizeof($args) > 1) { if (strlen($args['search_string'])) { $this->db->like('name', $args['search_string'])->or_like('address', $args['search_string'])->or_like('city', $args['search_string'])->or_like('zip', $args['search_string'])->or_like('email', $args['search_string'])->or_like('sex', $args['search_string'])->or_like('called', $args['search_string'])->or_like('skills', $args['search_string'])->or_like('skilled', $args['search_string'])->or_like('experience', $args['search_string'])->or_like('interests', $args['search_string'])->or_like('interests_other', $args['search_string'])->or_like('avail_days', $args['search_string'])->or_like('date', date_for_db($args['search_string']))->or_like('birthday', date_for_db($args['search_string'])); } foreach ($args['filters']['search_type'] as $key => $a) { $search = ''; switch ($args['filters']['search_type'][$key]) { case 'equals': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->where($args['filters']['search_val'][$key], date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; case 'not_equal': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->where($args['filters']['search_val'][$key] . ' !=', date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; case 'less_than': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->where($args['filters']['search_val'][$key] . ' <', date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; case 'less_than_equal': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->where($args['filters']['search_val'][$key] . ' <=', date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; case 'greater_than': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->where($args['filters']['search_val'][$key] . ' >', date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; case 'greater_than_equal': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->where($args['filters']['search_val'][$key] . ' >=', date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; case 'like': if (strlen($args['filters']['search_value'][$args['filters']['search_val'][$key]]) > 0) { $this->db->like($args['filters']['search_val'][$key], date_for_db($args['filters']['search_value'][$args['filters']['search_val'][$key]])); } break; } } } $this->db->stop_cache(); $data = $this->db->select('*')->from('volunteers')->join('volunteer_references', 'volunteers.ID = volunteer_references.volunteer_id', 'left')->join('volunteer_office', 'volunteers.ID = volunteer_office.volunteer_id', 'left')->limit($limit, $offset)->get(); if ($data->num_rows > 0) { $return['rows'] = $data->result(); } $c = $this->db->select('count(*) as count', false)->from('volunteers'); $tmp = $c->get()->result(); $return['num_rows'] = $tmp[0]->count; $this->db->flush_cache(); return $return; }
public function update_order($order, $data) { $main = array('order_locations' => isset($data['available_order_locations']) ? $data['available_order_locations'] : '', 'shipping_options' => isset($data['shipping_options']) ? $data['shipping_options'] : '', 'date_rec_com' => isset($data['date_rec_com']) ? date_for_db($data['date_rec_com']) : '', 'date_inv_rec' => isset($data['date_inv_rec']) ? date_for_db($data['date_inv_rec']) : '', 'inv_num' => isset($data['inv_num']) ? $data['inv_num'] : '', 'inv_amount' => isset($data['inv_amount']) ? $data['inv_amount'] : '', 'chk_req_sub' => isset($data['chk_req_sub']) ? date_for_db($data['chk_req_sub']) : '', 'comments' => $data['comments'], 'aprox_total' => $data['grand_total'][0], 'form_data' => base64_encode(serialize($data['custom_option']))); if ($data['submit_request'] == 'Submit for Approval') { $main['current_status'] = 'Submitted for Approval'; user_notifier::set_data($main); user_notifier::set_user($user_id); user_notifier::set_template('procurement', 'submit_for_approval'); } else { if ($data['submit_request'] == 'Approve') { $main['current_status'] = 'Approved'; user_notifier::set_data($main); user_notifier::set_user($user_id); user_notifier::set_template('procurement', 'aprove'); } else { if ($data['submit_request'] == 'Send Back to User' || !isset($main['current_status'])) { $main['current_status'] = 'In Process'; user_notifier::set_data($main); user_notifier::set_user($user_id); user_notifier::set_template('procurement', 'send_back_to_user'); } else { $main['current_status'] = $main['current_status']; } } } $this->db->where('ID', $order); $this->db->update('chapter_procurement_orders', $main); $this->db->where('order_id', $order); $this->db->delete('chapter_procurement_order_products'); if (isset($data['item_name']) && sizeof($data['item_name'] > 0)) { foreach ($data['item_name'] as $key => $val) { if (strlen($data['item_name'][$key]) > 0) { $p_data = array('order_id' => $order, 'item_name' => $data['item_name'][$key], 'item_id' => $data['item_id'][$key], 'unit_type' => $data['unit_type'][$key], 'price' => $data['price'][$key], 'quantity' => $data['quantity'][$key], 'total' => $data['total'][$key]); $this->db->insert('chapter_procurement_order_products', $p_data); } } } }