public function index() { $this->data['invoices'] = $this->payment_model->getFilteredInvoices($this->input->get('search_key') ? $this->input->get('search_key') : NULL, $this->input->get('start_date') ? mysqlDateFormat($this->input->get('start_date')) : NULL, $this->input->get('end_date') ? mysqlDateFormat($this->input->get('end_date')) : NULL); if ($this->input->is_ajax_request()) { $this->load->view('invoice_list', $this->data); } else { $this->ims_template->build('invoice_list', $this->data); } }
function service_fees_report($xml_attribute = '') { $this->load->model('payment/payment_model'); $this->data['breakdown_by'] = array('centres' => 'Centres', 'services' => 'Services', 'age' => 'Age', 'gender' => 'Gender'); $datas = $this->report_model->getServiceFeesReport(mysqlDateFormat($this->input->get('from_date')), mysqlDateFormat($this->input->get('to_date')), $this->input->get('exclude_direct_centres'), $this->input->get('breakdown_by_students')); $this->data['pie_chart'] = $this->_process_service_datas_for_pie($datas); $royalty_datas = $this->report_model->getServiceFeesReport($this->input->get('from_date'), $this->input->get('to_date'), TRUE, $this->input->get('breakdown_by_students'), TRUE); $this->data['royalty_pie_chart'] = $this->_process_service_datas_for_pie($royalty_datas); foreach ($datas as $key => &$data) { $data->payment_received_date = $this->report_model->getLatestPaymentDate($data->receipt_number); } if ($this->input->get('breakdown_by') == 'services') { $line_chart = $this->_process_services_service_datas_for_line($datas); } elseif ($this->input->get('breakdown_by') == 'age') { $line_chart = $this->_process_age_service_datas_for_line($datas); } elseif ($this->input->get('breakdown_by') == 'gender') { $line_chart = $this->_process_gender_service_datas_for_line($datas); } else { $line_chart = $this->_process_centre_service_datas_for_line($datas); } $this->data['line_chart'] = $line_chart; $total_datas = $this->report_model->getServiceFeesReport(mysqlDateFormat($this->input->get('from_date')), mysqlDateFormat($this->input->get('to_date')), $this->input->get('exclude_direct_centres'), $this->input->get('breakdown_by_students'), FALSE, TRUE); $total_service_fee = 0; $total_service_fee_subjected_to_royalty = 0; $total_service_fee_collected = 0; $centre_table_items = array(); $student_table_items = array(); foreach ($total_datas as $key => $value) { $total_service_fee += $value->service_amount; if ($value->is_franchisee == '1') { $total_service_fee_subjected_to_royalty += $value->service_amount; } $invoice_balance = $this->payment_model->getInvoiceBalance($value->receipt_number); $total_service_fee_collected += $invoice_balance; if (!isset($centre_table_items[$value->true_service_id . '_' . $value->centre_id])) { $centre_table_items[$value->true_service_id . '_' . $value->centre_id] = array('centre_name' => $value->centre_fullname . ' (' . $value->centre . ')', 'service_type' => $value->service_name, 'service_amount' => 0, 'amount_collected' => array(), 'subjected_to_royalty' => $value->is_franchisee ? 'Yes' : 'No', 'students' => array()); } $centre_table_items[$value->true_service_id . '_' . $value->centre_id]['service_amount'] += $value->service_amount; $centre_table_items[$value->true_service_id . '_' . $value->centre_id]['amount_collected'][] = $invoice_balance; if (!in_array($value->student_id, $centre_table_items[$value->true_service_id . '_' . $value->centre_id]['students'])) { $centre_table_items[$value->true_service_id . '_' . $value->centre_id]['students'][] = $value->student_id; } if (!isset($student_table_items[$value->student_id . '_' . $value->true_service_id])) { $student_table_items[$value->student_id . '_' . $value->true_service_id] = array('student_name' => $value->student_name, 'service_type' => $value->service_name, 'child_key' => $value->child_key, 'centre_name' => $value->centre_fullname . ' (' . $value->centre . ')', 'service_amount' => 0, 'amount_collected' => array(), 'subjected_to_royalty' => $value->is_franchisee ? 'Yes' : 'No'); } $student_table_items[$value->student_id . '_' . $value->true_service_id]['service_amount'] += $value->service_amount; $student_table_items[$value->student_id . '_' . $value->true_service_id]['amount_collected'][] = $invoice_balance; } $this->data['total_students'] = count($student_table_items); $this->data['total_service_fee'] = $total_service_fee; $this->data['total_service_fee_subjected_to_royalty'] = $total_service_fee_subjected_to_royalty; $this->data['total_service_fee_collected'] = $total_service_fee_collected; $this->data['centre_table_items'] = $centre_table_items; $this->data['student_table_items'] = $student_table_items; if ($xml_attribute == 'centre') { $this->exportRepordCardz($centre_table_items, 'centre'); die; } elseif ($xml_attribute == 'student') { $this->exportRepordCardz($student_table_items, 'student'); die; } if ($this->input->is_ajax_request()) { $this->load->view('service_fees_report', $this->data); } else { $this->ims_template->build('parent_account/blank', $this->data); } }
public function add() { if ($this->input->post()) { /* Add new kin for drop-off */ $drop_off = $this->input->post('drop_off'); $pickup_type = $this->input->post('pickup_type'); $pick_up_details = $this->input->post('pick_up_details'); $this->load->model('kin/kin_model'); if (!empty($drop_off)) { foreach ($drop_off as $key => $value) { if ($pickup_type[$key] == 2) { // general if (!empty($value)) { if (!is_numeric($value)) { $ifExists = $this->kin_model->countWhere(array('full_name' => $value, 'child_id' => $key), IMS_DB_PREFIX . 'drop_off_person'); if ($ifExists == 0) { $drop_id = time() + rand(0, 99999); $parent_kin = array('id' => $drop_id, 'full_name' => $value, 'child_id' => $key, 'class_id' => $this->input->post('classId'), 'year_term_id' => $this->default_yearterm->id); $this->kin_model->insertRow($parent_kin, IMS_DB_PREFIX . 'drop_off_person'); $this->kin_model->insertRow(array('pd_id' => $drop_id, 'child_id' => $key), IMS_DB_PREFIX . 'pickup_dropoff_child_relation'); $drop_off[$key] = $drop_id; } } else { $ifExists = $this->kin_model->countWhere(array('pd_id' => $value, 'child_id' => $key), IMS_DB_PREFIX . 'pickup_dropoff_child_relation'); if ($ifExists == 0) { $this->kin_model->insertRow(array('pd_id' => $value, 'child_id' => $key), IMS_DB_PREFIX . 'pickup_dropoff_child_relation'); } } } } else { if ($pickup_type[$key] == 1) { // kin if (!empty($value) && !is_numeric($value)) { $parent_kin = array('full_name' => $value); $insert_id = $this->kin_model->insertRow($parent_kin, IMS_DB_PREFIX . 'kin'); $drop_off[$key] = $insert_id; if ($insert_id) { $kin_log = array('kin_id' => $insert_id, 'date' => date("Y-m-d H:i:s"), 'type' => 1, 'user_role_id' => $this->current_centre_role->r_id); $this->kin_model->insertRow($kin_log, IMS_DB_PREFIX . 'kin_log'); $this->kin_model->insertRow(array('child_id' => $key, 'kin_id' => $insert_id), IMS_DB_PREFIX . 'child_kin_relation'); } } } } } } /* Add new kin for drop-off */ $classId = $this->input->post('classId'); $date = mysqlDateFormat($this->input->post('attendace_date')); $attendanceType = $this->input->post('attendance_type'); $success = false; if ($classId != -1) { $year_term_child_class = $this->attendance_model->checkAttendanceYearTerm($classId, $date, $attendanceType, $this->current_centre_role->centre_id, $this->default_yearterm->id); $data_insert_day = array('center_id' => $this->current_centre_role->centre_id, 'date' => $date, 'term' => $year_term_child_class); $day = $this->attendance_model->getOneWhere($data_insert_day, IMS_DB_PREFIX . 'day'); $day_id = $day ? $day->id : $this->attendance_model->insertRow($data_insert_day, IMS_DB_PREFIX . 'day'); if ($day_id) { $attendance_data = array('day_id' => $day_id, 'class_id' => $classId, 'attendance_type' => $attendanceType); $attendance = $this->attendance_model->getOneWhere($attendance_data, IMS_DB_PREFIX . 'attendance'); if ($attendance) { $attendance_id = $attendance->id; } else { $attendance_data['user_id'] = $this->current_user->id; $attendance_id = $this->attendance_model->insertRow($attendance_data, IMS_DB_PREFIX . 'attendance'); } if ($attendance_id) { $this->attendance_model->deleteWhere(array('attendance_id' => $attendance_id), IMS_DB_PREFIX . 'attendance_child'); $present = $this->input->post('present'); $remarks = $this->input->post('remarks'); if (!empty($remarks) && is_array($remarks) && count($remarks) > 0) { foreach ($remarks as $k => $v) { $data_to_insert[] = array('attendance_id' => $attendance_id, 'child_id' => $k, 'present' => isset($present[$k]) && $present[$k] == 'on' ? "1" : "0", 'remark' => $remarks[$k], 'drop_off_id' => $drop_off[$k], 'dropoff_type' => $pickup_type[$k], 'pickup_id' => $pick_up_details[$k]); } $this->attendance_model->insertRows($data_to_insert, IMS_DB_PREFIX . 'attendance_child'); $success = true; } } } } else { $class_attendance = $this->input->post('remarks'); $present = $this->input->post('present'); foreach ($class_attendance as $class_id => $remarks) { $year_term_child_class = $this->attendance_model->checkAttendanceYearTerm($class_id, $date, $attendanceType, $this->current_centre_role->centre_id, $this->default_yearterm->id); $data_insert_day = array('center_id' => $this->current_centre_role->centre_id, 'date' => $date, 'term' => $year_term_child_class); $day = $this->attendance_model->getOneWhere($data_insert_day, IMS_DB_PREFIX . 'day'); $day_id = $day ? $day->id : $this->attendance_model->insertRow($data_insert_day, IMS_DB_PREFIX . 'day'); if ($day_id) { $attendance_data = array('day_id' => $day_id, 'class_id' => $class_id, 'attendance_type' => $attendanceType); $attendance = $this->attendance_model->getOneWhere($attendance_data, IMS_DB_PREFIX . 'attendance'); if ($attendance) { $attendance_id = $attendance->id; } else { $attendance_data['user_id'] = $this->current_user->id; $attendance_id = $this->attendance_model->insertRow($attendance_data, IMS_DB_PREFIX . 'attendance'); } if ($attendance_id) { $this->attendance_model->deleteWhere(array('attendance_id' => $attendance_id), IMS_DB_PREFIX . 'attendance_child'); if (!empty($remarks) && is_array($remarks) && count($remarks) > 0) { foreach ($remarks as $k => $v) { $data_to_insert[] = array('attendance_id' => $attendance_id, 'child_id' => $k, 'present' => isset($present[$class_id][$k]) && $present[$class_id][$k] == 'on' ? "1" : "0", 'remark' => $v); } $this->attendance_model->insertRows($data_to_insert, IMS_DB_PREFIX . 'attendance_child'); $success = true; } } else { $success = false; break; } } } } echo $success ? 'success' : 'fail'; } else { redirect(site_url('attendance')); } }
function add() { $this->breadcrumb->append_crumb(lang('receipts'), site_url('receipts/index')); $this->breadcrumb->append_crumb(lang('add_receipt')); $levels_row = $this->levels_model->getLevels(); $this->data['levels'] = $levels_row['levels']; $items = $this->variables_model->getVariables('payment_item'); $this->data['payment_items'] = $items['allVariables']; $services = $this->variables_model->getVariables('payment_service'); $this->data['payment_services'] = $services['allVariables']; $types = $this->variables_model->getVariables('payment_type'); $this->data['payment_types'] = $types['allVariables']; if ($this->input->post()) { if ($this->_validate_receipt()) { $services = $this->input->post('services'); $items = $this->input->post('items'); $services_amount = $this->input->post('services_amount'); $items_amount = $this->input->post('items_amount'); $receipt = array('child_id' => ucfirst($this->input->post('child_id')), 'amount' => ucfirst($this->input->post('amount')), 'date' => ucfirst(mysqlDateFormat($this->input->post('date'))), 'payment_method' => ucfirst($this->input->post('payment_method')), 'remarks' => ucfirst($this->input->post('remarks'))); $services_arr = array(); if (!empty($services)) { foreach ($services as $key => $service) { $services_arr[$key] = array('service' => $service, 'amount' => $services_amount[$key]); } $receipt['services'] = serialize($services_arr); } $items_arr = array(); if (!empty($items)) { foreach ($items as $key => $item) { $items_arr[$key] = array('item' => $item, 'amount' => isset($items_amount[$key]) ? $items_amount[$key] : 0); } $receipt['items'] = serialize($items_arr); } $insert_id = $this->receipts_model->insertRow($receipt); $this->_set_flashdata(lang('receipt_added_successfully')); die(json_encode(array('status' => 'success', 'receipt_id' => $insert_id))); } else { $response = array('status' => 'validation_error', 'error' => array('child_id' => form_error('child_id'), 'amount' => form_error('amount'), 'date' => form_error('date'), 'payment_method' => form_error('payment_method'), 'services' => form_error('services'), 'items' => form_error('items'))); if (form_error('total_credit')) { $response['error'][] = form_error('total_credit'); } die(json_encode($response)); } } if ($this->input->is_ajax_request()) { $this->load->view('add_edit_receipts_form', $this->data); } else { $this->ims_template->build('parent_account/blank', $this->data); } }
public function _valid_leave_date() { $start = $this->input->post('start_date') . ' ' . $this->input->post('start_time'); $end = $this->input->post('end_date') . ' ' . $this->input->post('end_time'); if (strtotime($start) >= strtotime($end)) { $this->form_validation->set_message('_valid_leave_date', 'End date must be greater than start date...'); return false; } $check_leave_request_day = $this->leave_model->check_leave_request_day($this->input->post('staff_id'), mysqlDateFormat($this->input->post('start_date')), mysqlDateFormat($this->input->post('end_date'))); if (!empty($check_leave_request_day)) { if ($check_leave_request_day->status == 1) { $this->form_validation->set_message('_valid_leave_date', 'Sorry You have already taken leave on this date...'); } else { if ($check_leave_request_day->status == 0) { $this->form_validation->set_message('_valid_leave_date', 'Sorry You have already make request on this date but your request is on pending...'); } else { $this->form_validation->set_message('_valid_leave_date', "No valid leave..."); } } return false; } $days = (strtotime($this->input->post('end_date')) - strtotime($this->input->post('start_date'))) / (60 * 60 * 24) + 1; $awh = $this->_get_awh($this->input->post('staff_id')); $this->leave_hours_requested = $days * $awh; $balance = $this->leave_model->getUserBalance($this->input->post('staff_id'), $this->input->post('leave_type_id'), $this->input->post('selected_year')); if ($balance == 0) { $this->form_validation->set_message('_valid_leave_date', 'Sorry You have no balance...'); return false; } if ($this->leave_hours_requested > $balance) { $this->form_validation->set_message('_valid_leave_date', 'Sorry Your balance is less than your request hour...'); return false; } return true; }
function end_recurring_service() { $service_id = $this->input->post('service_id'); $service_end_date = mysqlDateFormat($this->input->post('service_end_date')); $this->payment_model->updateWhere(array('id' => $service_id), array('end_date' => $service_end_date), IMS_DB_PREFIX . 'child_services'); die('success'); }
function update($kin_id) { if ($this->input->post()) { if ($this->_validate_parents_kins($kin_id)) { $parent_kin = array('full_name' => $this->input->post('full_name'), 'secondary_name' => $this->input->post('secondary_name'), 'id_key' => $this->input->post('id_key'), 'id_type_id' => $this->input->post('id_type_id'), 'dob' => mysqlDateFormat($this->input->post('date_of_birth')), 'mobile_no' => $this->input->post('mobile_no'), 'email' => $this->input->post('email_address'), 'nation_id' => $this->input->post('nation_id'), 'race' => $this->input->post('race'), 'occupation' => $this->input->post('occupation'), 'company_name' => $this->input->post('company_name'), 'company_address' => $this->input->post('company_address'), 'office_number' => $this->input->post('office_number'), 'kin_image' => $this->input->post('kin_image'), 'kin_image_hash' => $this->input->post('kin_image_hash')); $update_kin = $this->kin_model->updateWhere(array('id' => $kin_id), $parent_kin, IMS_DB_PREFIX . 'kin'); $affected_rows = $this->db->affected_rows(); if ($update_kin) { if ($this->input->post('child')) { $childs = $this->input->post('child'); $can_pick = $this->input->post('can_pick'); foreach ($childs as $child) { if (isset($can_pick[$child])) { $update_can_pick = $this->kin_model->updateWhere(array('id' => $child), array('can_pickup' => 1), IMS_DB_PREFIX . 'child_kin_relation'); $affected_rows += $this->db->affected_rows(); } else { $update_can_pick = $this->kin_model->updateWhere(array('id' => $child), array('can_pickup' => 0), IMS_DB_PREFIX . 'child_kin_relation'); $affected_rows += $this->db->affected_rows(); } } } } if ($affected_rows > 0) { $kin_log = array('kin_id' => $kin_id, 'date' => date("Y-m-d H:i:s"), 'type' => 2, 'user_role_id' => $this->current_centre_role->r_id); $this->kin_model->insertRow($kin_log, IMS_DB_PREFIX . 'kin_log'); } $this->_set_flashdata('Kin Updated Successfully!'); redirect(site_url('kin/detail/' . $kin_id)); } else { if (file_exists(FCPATH . '/uploads/kin/' . $this->input->post('kin_image'))) { unlink('/uploads/kin/' . $this->input->post('kin_image')); } } } $this->breadcrumb->append_crumb('Update', site_url('kin/update/' . $kin_id)); $this->data['kin_id'] = $kin_id; $this->data['kin_info'] = $this->kin_model->getOneWhere(array('id' => $kin_id), IMS_DB_PREFIX . 'kin'); $kin_ids = array($kin_id); $this->data['related_childs'] = $this->kin_model->get_child_of_kin($kin_ids); $this->data['id_from_variable'] = $this->variables_model->getVariablesIdType('child'); $this->data['id_from_variable_subscriber'] = $this->variables_model->getVariablesIdType('subscriber'); $nations = $this->variables_model->getVariables('nationality'); $races = $this->variables_model->getVariables('races'); $relations = $this->variables_model->getVariables('kins_relation'); $this->data['relations'] = $relations['allVariables']; $this->data['races'] = $races['allVariables']; $this->data['nations'] = $nations['allVariables']; $this->data['audit_trials'] = $this->kin_model->get_all_kin_log($kin_id); $this->data['can_edit'] = (!_is('Supervisor') and !_is('Teacher')); if (!$this->data['can_edit']) { $this->_set_flashdata('Premission Denied', 'error'); redirect('dashboard'); } if ($this->input->is_ajax_request()) { $this->load->view('update', $this->data); } else { $this->ims_template->build('update', $this->data); } }
echo $buttonText; ?> </button> </form> <?php } ?> <?php if (count($article['comments']) && $id) { ?> <?php foreach ($article['comments'] as $comment) { ?> <article class="comment"> <p>Wrote on <?php echo mysqlDateFormat($comment['date_comment']); ?> by <?php echo $comment['author_comment']; ?> </p> <p> <?php echo $comment['content_comment']; ?> </p> <?php if (isset($_SESSION['id_user'])) { ?> <a href="<?php echo "comments.php?id=" . $comment['id_comment']; ?>
function inventory_report() { $product_id = ""; $prod_id = ""; $product_alls = ""; $top_selling_product = ""; $interval_type = "daily"; $product = array(); if ($this->input->post()) { if ($this->input->post('from_date') != '') { $start_date = mysqlDateFormat($this->input->post('from_date')); } else { $start_date = date("y-m-d", strtotime('-10 days')); } if ($this->input->post('to_date') != '') { $end_date = mysqlDateFormat($this->input->post('to_date')); } else { $end_date = date('Y-m-d'); } $centre_id = $this->input->post('Centre'); if ($this->input->post('product') and $this->input->post('product') != 'null') { $product = $this->input->post('product'); } if ($this->input->post('top_selling') != '') { $top_selling_product_id = $this->input->post('top_selling'); } if ($this->input->post('interval')) { $interval_type = $this->input->post('interval'); } } else { $centre_id = $this->current_centre_role->centre_id; $start_date = ""; $end_date = ""; $interval_type = "daily"; } $this->data['centres'] = $this->data['centres'] = $this->inventory_model->getAllCentres(); /*stock level breakdown by products starts pie chart*/ $inventorys = $this->inventory_report_model->get_all_products($centre_id); $this->data['products'] = $inventorys; $this->data['no_of_products'] = count($inventorys); $inventory_from_inventory = $this->inventory_model->get_all_inventory($perpage = '', $offset = '', $search = '', $sort = '', $min_price = '', $max_price = '', $centre_id); $this->data['inventory_details'] = $inventory_from_inventory['inventory']; if (!empty($inventorys)) { $total_inventory_details = $inventory_from_inventory['total']->count; $json_array = $this->_process_data_for_pie_chart($inventorys); $this->data['pie_chart'] = $json_array; } else { $json_array = array(); $this->data['pie_chart'] = $json_array; } /*end of piechart data*/ $top_selling = $this->inventory_report_model->top_ten_sold_products($start_date, $end_date, $centre_id); if (!empty($top_selling)) { $top_tens_by_volume_and_sales = $this->_datas_for_top_tens($top_selling); $this->data['top_ten_sold'] = $top_ten = $top_tens_by_volume_and_sales['top_ten_sold']; $this->data['top_ten_by_sales'] = $top_ten_by_sales = $top_tens_by_volume_and_sales['top_ten_by_sales']; } else { $top_ten = array(); $this->data['top_ten_sold'] = $top_ten; $top_ten_by_sales = array(); $this->data['top_ten_by_sales'] = $top_ten_by_sales; } $top_selling_product_id = isset($top_selling_product_id) ? $top_selling_product_id : ''; if ($top_selling_product_id == 'all_tops_by_sales') { $this->data['top_selling_drop'] = "top_by_sales"; } else { if ($top_selling_product_id == 'all_tops_by_volume') { $this->data['top_selling_drop'] = "top_by_volume"; } else { if ($top_selling_product_id == 'low_stock_by_volume') { $this->data['top_selling_drop'] = "top_by_low_stock"; } else { $this->data['top_selling_drop'] = "all_tops"; } } } $inventory_report = array(); if (!empty($inventorys)) { if (!empty($product)) { if (count($product) >= 10) { if ($top_selling_product_id == 'all_tops_by_sales') { if (!empty($top_ten_by_sales)) { $tops = array(); foreach ($top_ten_by_sales as $top_by_sale) { $tops[] = $top_by_sale['id']; } $inven_with_es = $this->_process_data_for_products_not_with_all_products($tops, $centre_id, $start_date, $end_date); $inventory_es = $inven_with_es['inventory_es']; $inventory_report = $inven_with_es['inventory_report']; } $this->data['top_selling_drop'] = "top_by_sales"; } else { if ($top_selling_product_id == 'all_tops_by_volume') { if (!empty($top_ten)) { $tops = array(); foreach ($top_ten as $top_by_sale) { $tops[] = $top_by_sale['id']; } $inven_with_es = $this->_process_data_for_products_not_with_all_products($tops, $centre_id, $start_date, $end_date); $inventory_es = $inven_with_es['inventory_es']; $inventory_report = $inven_with_es['inventory_report']; } $this->data['top_selling_drop'] = "top_by_volume"; } else { if ($top_selling_product_id == 'low_stock_by_volume') { $tops = array(); $low_stock_by_volume = $this->inventory_report_model->get_low_stocks($centre_id); if (!empty($low_stock_by_volume)) { $limit = 0; foreach ($low_stock_by_volume as $topss) { if ($limit <= 9) { $tops[] = $topss->id; } $limit = $limit + 1; } $inven_with_es = $this->_process_data_for_products_not_with_all_products($tops, $centre_id, $start_date, $end_date); $inventory_es = $inven_with_es['inventory_es']; $inventory_report = $inven_with_es['inventory_report']; } $this->data['top_selling_drop'] = "top_by_low_stock"; } else { if (!empty($top_ten_by_sales)) { $tops = array(); foreach ($top_ten_by_sales as $top_by_sale) { $tops[] = $top_by_sale['id']; } $inven_with_es = $this->_process_data_for_products_not_with_all_products($tops, $centre_id, $start_date, $end_date); $inventory_es = $inven_with_es['inventory_es']; $inventory_report = $inven_with_es['inventory_report']; } $this->data['top_selling_drop'] = "all_tops"; } } } } else { if (in_array('all_in_multiple', $product)) { $inventory_report_ = $this->_process_data_for_multiple_select($top_ten, $centre_id, $start_date, $end_date); $inventory_es = $inventory_report_['inventory_es']; $inventory_report = $inventory_report_['inventory_report']; $product_alls = 'all_in_multiple'; } else { $inven_with_es = $this->_process_data_for_products_not_with_all_products($product, $centre_id, $start_date, $end_date); $inventory_es = $inven_with_es['inventory_es']; $inventory_report = $inven_with_es['inventory_report']; } } } else { $inventory_es = $this->inventory_report_model->get_all_products($centre_id); foreach ($inventory_es as $inventory) { $inv_id = $inventory->id; $inventory_report[$inventory->item_name] = $this->inventory_report_model->get_inventory_report($start_date, $end_date, $centre_id, $inv_id); } } } $inventory_array = array(); if (!empty($inventorys)) { if (array_filter($inventory_report)) { $this->sort_array_of_array($inventory_report, 'date'); $final_array = $this->_process_data_for_line_chart($inventory_report, $inventory_es, $start_date, $end_date, $interval_type); } else { $final_array = array(); } } else { $final_array = array(); } $this->session->set_userdata('inventory_start_date', $start_date); $this->session->set_userdata('inventory_end_date', $end_date); $this->session->set_userdata('inventory_centre_id', $centre_id); $this->data['start_date'] = $start_date; $this->data['end_date'] = $end_date; $this->data['centre_id'] = $centre_id; $this->data['product_alls'] = $product_alls; $this->data['prod_id'] = $prod_id; $this->data['products_for_selected'] = $product; $this->data['json_array'] = $final_array; if ($this->input->is_ajax_request()) { $this->load->view('centres_franchises/inventory_report', $this->data); } else { $this->ims_template->build('parent_account/blank', $this->data); } }
public function index() { $this->load->model('classes/Classes_model'); $this->load->model('child/child_model'); $this->load->model('kin/kin_model'); if (!$this->input->is_ajax_request()) { $this->ims_template->build('parent_account/blank', $this->data); } else { $this->data['unavailable_dates'] = $this->pickup_model->getUnavailableDate(); //Any Day with Academic Events are unavailable dates $redirect_url_info = $this->session->userdata('redirect_url_info'); if (is_array($redirect_url_info) and !empty($redirect_url_info)) { $this->data['attendance_date'] = $attendance_date = $redirect_url_info['date']; $this->data['attendanceType'] = $attendanceType = 1; $this->data['classId'] = $classId = $redirect_url_info['class_id']; $this->session->unset_userdata('redirect_url_info'); } else { $this->data['attendance_date'] = $attendance_date = $this->input->post('attendace_date') === false ? date('Y-m-d') : $this->input->post('attendace_date'); $this->data['attendanceType'] = $attendanceType = $this->input->post('attendanceType') === false ? 1 : $this->input->post('attendanceType'); $this->data['classId'] = $classId = $this->input->post('classId') === false ? 0 : $this->input->post('classId'); } if (_is('Teacher')) { $this->data['ClassLevel'] = $this->pickup_model->getAttendancePermission($this->current_user->id, $this->current_centre_role->centre_id, $this->default_yearterm->id); } else { $this->data['ClassLevel'] = $this->Classes_model->getClassLevel($this->current_centre_role->centre_id); } /* Check if child exist */ $year = date('Y'); $month = date('m'); $year_term = $this->default_yearterm->id; $centre_id = $this->current_centre_role->centre_id; if (!empty($this->data['ClassLevel'])) { foreach ($this->data['ClassLevel'] as $key => $value) { //$attendance = $this->pickup_model->getAttendanceListByMonth($year, $month, $value->id); // debug_continue($this->pickup_model->db->last_query()); $child_count = $this->child_model->getClassListByMonth($value->id, $year, $month); $this->data['ClassLevel'][$key]->childCount = count($child_count); } } /* Check if child exist */ $this->data['date'] = $date = mysqlDateFormat($attendance_date); if ($classId != -1) { $lvlId = ''; if ($classId != 0) { foreach ($this->data['ClassLevel'] as $ClassLevel) { if ($classId == $ClassLevel->id) { $lvlId = $ClassLevel->id; $this->data['class_level_name'] = $ClassLevel; break; } } $this->data['attendance_disabled'] = false; if (valid_date($attendance_date) and !in_array(date('Y-n-j', strtotime($date)), $this->data['unavailable_dates'])) { //date is valid and not an event day $classAttendanceDescription = $this->pickup_model->checkAttendance($classId, $date, $attendanceType, $this->current_centre_role->centre_id, $lvlId); if (!empty($classAttendanceDescription)) { //Edit Mode $this->data['child_attendance'] = array(); foreach ($classAttendanceDescription['childAttendance'] as $child_attendance) { $this->data['child_attendance'][$child_attendance->child_id] = $child_attendance; } $this->data['classAttendance'] = $classAttendanceDescription['attendance']; $year_term_child_class = $this->data['classAttendance']->term; } else { //Insert Mode $year_term_child_class = $this->default_yearterm->id; } if ($attendanceType == 1) { //$this->data['classDetails'] = $this->child_model->getClassListByDate($classId, $date); $class_details = $this->child_model->getClassListByDate($classId, $date); /* Get all kins related to the child */ if (!empty($class_details)) { foreach ($class_details as $key => $value) { if (isset($this->data['child_attendance'][$value->id]->pickup_type) && $this->data['child_attendance'][$value->id]->pickup_type == 1) { // get kin $kin_details = $this->kin_model->get_all_kin_by_child($value->id); } else { if (isset($this->data['child_attendance'][$value->id]->pickup_type) && $this->data['child_attendance'][$value->id]->pickup_type == 2) { // get general $kin_details = $this->kin_model->get_pickup_dropoff_person_by_child($value->id); } else { $kin_details = $this->kin_model->get_all_kin_by_child($value->id); } } $this->data['classDetails'][] = $value; $this->data['classDetails'][$key]->kinDetails = $kin_details; } } /* Get all kins related to the child */ } } else { $this->data['attendance_disabled'] = true; } } } else { $lvlId = ''; foreach ($this->data['ClassLevel'] as $all_class) { foreach ($this->data['ClassLevel'] as $ClassLevel) { if ($all_class->id == $ClassLevel->id) { $lvlId = $ClassLevel->id; $this->data['all_class'][$all_class->id]['class_level_name'] = $ClassLevel; break; } } $this->data['attendance_disabled'] = false; if (valid_date($attendance_date) and !in_array(date('Y-n-j', strtotime($date)), $this->data['unavailable_dates'])) { $classAttendanceDescription = $this->pickup_model->checkAttendance($all_class->id, $date, $attendanceType, $this->current_centre_role->centre_id); if (!empty($classAttendanceDescription)) { $this->data['all_class'][$all_class->id]['child_attendance'] = array(); foreach ($classAttendanceDescription['childAttendance'] as $child_attendance) { $this->data['all_class'][$all_class->id]['child_attendance'][$child_attendance->child_id] = $child_attendance; } $this->data['all_class'][$all_class->id]['classAttendance'] = $classAttendanceDescription['attendance']; $year_term_child_class = $this->data['all_class'][$all_class->id]['classAttendance']->term; } else { $year_term_child_class = $this->default_yearterm->id; } if ($attendanceType == 1) { $this->data['all_class'][$all_class->id]['classDetails'] = $this->child_model->getClassListByDate($all_class->id, $date); } } else { $this->data['attendance_disabled'] = true; } } } $this->load->view('pickup', $this->data); } }