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);
 }
Exemple #2
0
 public function update_travel_request($temp, $to_id)
 {
     $data['for_month'] = $temp['for_month'];
     $data['manager'] = $temp['manager'];
     if ($temp['submit_request'] == 'Submit for Approval') {
         $data['current_status'] = 'Submitted for Approval';
         user_notifier::set_data($data);
         user_notifier::set_user($temp['user_id']);
         user_notifier::set_template('travel', 'submit_for_approval');
     } else {
         if ($temp['submit_request'] == 'Approve') {
             $man = $this->users_model->get_user_meta($temp['manager']);
             user_notifier::set_data($data);
             user_notifier::set_user($temp['user_id']);
             user_notifier::set_template('travel', 'approve');
             $data['current_status'] = 'Approved';
             $data['manager_signature'] = $man['first_name'] . ' ' . $man['last_name'];
         } 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($temp['user_id']);
                 user_notifier::set_template('travel', 'send_back_to_user');
             } else {
                 $data['current_status'] = $temp['current_status'];
             }
         }
     }
     if (strlen($temp['manager_signature'])) {
         $data['manager_signature'] = $temp['manager_signature'];
     }
     user_notifier::send();
     $this->db->where('ID', $to_id)->update('travel_requests', $data);
     $this->db->where('travel_id', $to_id)->delete('travel_request_details');
     $this->db->where('travel_id', $to_id)->delete('travel_out_of_town_details');
     foreach ($temp['travel_date'] as $key => $val) {
         if (strlen($temp['travel_date'][$key])) {
             $data = array();
             $data['travel_id'] = $to_id;
             $data['travel_date'] = date('Y-m-d H:i:s', strtotime($temp['travel_date'][$key]));
             $data['travel_from'] = $temp['travel_from'][$key];
             $data['travel_to'] = $temp['travel_to'][$key];
             $data['purpose'] = $temp['purpose'][$key];
             $data['roundtrip'] = isset($temp['roundtrip'][$key]) ? implode(',', $temp['roundtrip'][$key]) : 'No';
             $data['total_miles'] = $temp['total_miles'][$key];
             $data['home_adjustment'] = $temp['home_adjustment'][$key];
             $data['net_mileage'] = $temp['net_mileage'][$key];
             $data['parking'] = $temp['parking'][$key];
             $data['account_number'] = $temp['account_number'][$key];
             $data['total_amount'] = $temp['total_amount'][$key];
             $this->db->insert('travel_request_details', $data);
         }
     }
     foreach ($temp['ot_travel_date'] as $key => $val) {
         if (strlen($temp['ot_travel_date'][$key])) {
             $data = array();
             $data['travel_id'] = $to_id;
             $data['travel_date'] = date('Y-m-d H:i:s', strtotime($temp['ot_travel_date'][$key]));
             $data['purpose'] = $temp['ot_purpose'][$key];
             $data['account_number'] = $temp['ot_account_number'][$key];
             $data['air'] = $temp['air'][$key];
             $data['hotel'] = $temp['hotel'][$key];
             $data['meals'] = $temp['meals'][$key];
             $data['misc'] = $temp['misc'][$key];
             $data['transit'] = $temp['transit'][$key];
             $data['total'] = $temp['total'][$key];
             $this->db->insert('travel_out_of_town_details', $data);
         }
     }
 }
Exemple #3
0
 public function update_timeoff_request($temp, $to_id)
 {
     $data['first_name'] = $temp['first_name'];
     $data['last_name'] = $temp['last_name'];
     $data['manager'] = $temp['manager'];
     if (isset($temp['manager_signature'])) {
         $data['manager_signature'] = $temp['manager_signature'];
     }
     $data['request_start'] = date('Y-m-d H:i:s', strtotime($temp['request_start']));
     $data['request_end'] = date('Y-m-d H:i:s', strtotime($temp['request_end']));
     $data['request_type'] = $temp['request_type'];
     $data['combination'] = $temp['combination'];
     $data['days_or_hours'] = $temp['days_or_hours'];
     $data['comments'] = $temp['comments'];
     if ($temp['submit_request'] == 'Submit for Approval') {
         $data['current_status'] = 'Submitted for Approval';
         user_notifier::set_data($data);
         user_notifier::set_user($temp['user_id']);
         user_notifier::set_template('timeoff', 'submit_for_approval');
     } else {
         if ($temp['submit_request'] == 'Approve') {
             $data['current_status'] = 'Approved';
             user_notifier::set_data($data);
             user_notifier::set_user($temp['user_id']);
             user_notifier::set_template('timeoff', 'approve');
         } 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($temp['user_id']);
                 user_notifier::set_template('timeoff', 'send_back_to_user');
             } else {
                 $data['current_status'] = $temp['current_status'];
             }
         }
     }
     user_notifier::send();
     $this->db->where('ID', $to_id)->update('timeoff_requests', $data);
 }
 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);
             }
         }
     }
 }