public function execute() { $this->form_validation->set_rules('event', 'Event', 'trim'); $this->form_validation->set_rules('date_from', 'Date From', 'trim'); $this->form_validation->set_rules('date_to', 'Date To', 'trim'); if ($this->form_validation->run() === false) { $this->session->set_flashdata('alert', '<div class="alert alert-danger">' . validation_errors() . '</div>'); $data['content'] = $this->load->view('export', '', true); $this->load->view('template', $data); } else { ini_set('memory_limit', '-1'); require_once "../assets/phpexcel/PHPExcel.php"; $excel = new PHPExcel(); $excel->setActiveSheetIndex(0); $active_sheet = $excel->getActiveSheet(); $active_sheet->setTitle('Candidate'); //style $active_sheet->getStyle("A1:AC1")->getFont()->setBold(true); //header $active_sheet->setCellValue('A1', 'No'); $active_sheet->setCellValue('B1', 'Event'); $active_sheet->setCellValue('C1', 'Serial Number'); $active_sheet->setCellValue('D1', 'Name of Contacts'); $active_sheet->setCellValue('E1', 'Job Title'); $active_sheet->setCellValue('F1', 'Departement'); $active_sheet->setCellValue('G1', 'Company'); $active_sheet->setCellValue('H1', 'Telephone'); $active_sheet->setCellValue('I1', 'Mobile'); $active_sheet->setCellValue('J1', 'Actcode'); $active_sheet->setCellValue('K1', 'New Name'); $active_sheet->setCellValue('L1', 'New Title'); $active_sheet->setCellValue('M1', 'New Telephone'); $active_sheet->setCellValue('N1', 'New Mobile'); $active_sheet->setCellValue('O1', 'Email'); $active_sheet->setCellValue('P1', 'Mobile Sms'); $active_sheet->setCellValue('Q1', 'Distribution Date'); $active_sheet->setCellValue('R1', 'Status'); $active_sheet->setCellValue('S1', 'Call History'); $event = $this->input->post('event'); $date_from = format_ymd($this->input->post('date_from')); $date_to = format_ymd($this->input->post('date_to')); $result = $this->export_model->export($event, $date_from, $date_to)->result(); $i = 2; foreach ($result as $r) { $active_sheet->setCellValue('A' . $i, $i - 1); $active_sheet->setCellValue('B' . $i, $r->event_name); $active_sheet->setCellValueExplicit('C' . $i, $r->sn); $active_sheet->setCellValue('D' . $i, $r->name); $active_sheet->setCellValue('E' . $i, $r->title); $active_sheet->setCellValue('F' . $i, $r->dept); $active_sheet->setCellValue('G' . $i, $r->company); $active_sheet->setCellValueExplicit('H' . $i, $r->tlp); $active_sheet->setCellValueExplicit('I' . $i, $r->mobile); $active_sheet->setCellValue('J' . $i, $r->actcode); $active_sheet->setCellValue('K' . $i, $r->name_new); $active_sheet->setCellValue('L' . $i, $r->title_new); $active_sheet->setCellValueExplicit('M' . $i, $r->tlp_new); $active_sheet->setCellValueExplicit('N' . $i, $r->mobile_new); $active_sheet->setCellValue('O' . $i, $r->email); $active_sheet->setCellValueExplicit('P' . $i, $r->mobile_sms); $active_sheet->setCellValue('Q' . $i, PHPExcel_Shared_Date::PHPToExcel(date_to_excel($r->dist_date))); $active_sheet->getStyle('Q' . $i)->getNumberFormat()->setFormatCode('dd/mm/yyyy'); $active_sheet->setCellValue('R' . $i, $r->status_name); $active_sheet->setCellValue('S' . $i, $this->callhis_model->get_note($r->id)); $i++; } $filename = 'Candidate_' . date('Ymd_His') . '.xlsx'; header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename="' . $filename . '"'); header('Cache-Control: max-age=0'); $objWriter = PHPExcel_IOFactory::createWriter($excel, 'Excel2007'); $objWriter->save('php://output'); } }
public function status() { $this->db->select(' B.name as event, sum(if(A.status=0,1,0)) as proses, sum(if(A.status=11,1,0)) as att, sum(if(A.status=12,1,0)) as con_att, sum(if(A.status=13,1,0)) as not_att, sum(if(A.status=14,1,0)) as wn, sum(if(A.status=15,1,0)) as cb, sum(if(A.status in (11,12,13,14,15),1,0)) as total_c, sum(if(A.status=21,1,0)) as na, sum(if(A.status=22,1,0)) as bus, sum(if(A.status=23,1,0)) as rej, sum(if(A.status=24,1,0)) as fn, sum(if(A.status in (21,22,23,24),1,0)) as total_n, sum(if(A.id is not null,1,0)) as total '); $this->db->from('reminder_candidate A'); $this->db->join('event B', 'A.event=B.id'); if ($this->input->get('date_from') != '' && $this->input->get('date_to') != '') { $this->db->where('A.dist_date >=', format_ymd($this->input->get('date_from'))); $this->db->where('A.dist_date <=', format_ymd($this->input->get('date_to'))); } $this->db->group_by('event'); return $this->db->get()->result(); }
function where_date($input, $field) { $from = $this->input->get($input . '_from'); $to = $this->input->get($input . '_to'); if ($from != '' && $to != '') { $data[] = $this->db->where($field . ' >=', format_ymd($from)); $data[] = $this->db->where($field . ' <=', format_ymd($to)); } }
function delete() { $date_from = format_ymd($this->input->get("date_from")); $date_to = format_ymd($this->input->get("date_to")); $event = $this->input->get("event"); $this->db->where('event', $event); $this->db->where('tanggal >= ', $date_from); $this->db->where('tanggal <= ', $date_to); $this->db->delete($this->tbl_name); }
function printout() { $tgl = explode(' - ', $this->input->post('tanggal')); $this->load->library('pdf'); $this->pdf->SetHeaderData('slide.jpg', 9, 'SAUNG AL-BAROKAH', 'Majalengka'); $this->pdf->AddPage(); $this->pdf->SetFont('helvetica', '', 8); $item['periode'] = $this->input->post('tanggal'); $item['source'] = $this->laporan_model->get_data(format_ymd($tgl[1]), format_ymd($tgl[0])); $html = $this->load->view('report', $item, TRUE); $this->pdf->writeHTML($html, true, false, false, false, ''); $this->pdf->Output('output.pdf', 'I'); }
function upload_file() { $config['upload_path'] = './temp_upload/weekly_plan/'; $config['allowed_types'] = '*'; $this->load->library('upload', $config); if (!$this->upload->do_upload('userfile')) { $json = array('status' => 0, 'alert' => $this->upload->display_errors()); //$this->session->set_flashdata('alert', 'Insert failed. Please check your file, only .xls file allowed.'); } else { $data = array('error' => false); $upload_data = $this->upload->data(); $this->load->library('excel_reader'); $this->excel_reader->setOutputEncoding('CP1251'); $file = $upload_data['full_path']; $this->excel_reader->read($file); error_reporting(E_ALL ^ E_NOTICE); // Sheet 1 $data = $this->excel_reader->sheets[0]; $dataexcel = array(); for ($i = 1; $i <= $data['numRows']; $i++) { if ($data['cells'][$i][1] == '') { break; } $dataexcel[$i - 1]['date'] = format_ymd($data['cells'][$i][1]); $dataexcel[$i - 1]['name'] = $data['cells'][$i][2]; $dataexcel[$i - 1]['work_classification'] = $data['cells'][$i][3]; $dataexcel[$i - 1]['job_code'] = $data['cells'][$i][4]; $dataexcel[$i - 1]['work_category'] = $data['cells'][$i][5]; $dataexcel[$i - 1]['description'] = $data['cells'][$i][6]; $dataexcel[$i - 1]['plan_from'] = $data['cells'][$i][7]; $dataexcel[$i - 1]['plan_to'] = $data['cells'][$i][8]; } //cek data $check = $this->weekly_report_model->search_duplicate($dataexcel); if ($check > 0) { $ss = $this->weekly_report_model->update_plan($dataexcel); $json = array('status' => 1, 'alert' => 'Update plan list success'); } else { $ss = $this->weekly_report_model->insert_plan($dataexcel); $json = array('status' => 1, 'alert' => 'Insert plan list success'); } } echo json_encode($json); }
function check() { $this->form_validation->set_error_delimiters('<span class="text-danger">', '</span>'); $this->form_validation->set_rules('nama', 'nama', 'required'); $this->form_validation->set_rules('kelompok', 'kelompok', 'required'); if ($this->form_validation->run() == FALSE) { $item['no_diagnosa'] = no_diagnosa($this->db->count_all('diagnosa')); $item['opt_gejala'] = $this->diagnosa_model->opt_gejala(); $data['content'] = $this->load->view('form', $item, TRUE); $data['script'] = $this->load->view('script', '', TRUE); $this->load->view('template', $data); } else { $pasien['nama'] = $this->input->post('nama'); $pasien['kelompok'] = $this->input->post('kelompok'); $diagnosa['no_diagnosa'] = $this->input->post('no_diagnosa'); $diagnosa['gejala'] = implode('|', $this->input->post('gejala')); $diagnosa['tanggal'] = format_ymd($this->input->post('tanggal')); $this->diagnosa_model->save_data($pasien, $diagnosa); redirect('diagnosa/periksa/' . $diagnosa['no_diagnosa']); } }
private function filter() { $data = array(); $status = $this->input->get('status'); $search = $this->input->get('search'); $event = $this->input->get('event'); $date_from = $this->input->get('date_from'); $date_to = $this->input->get('date_to'); $valid = $this->input->get('valid'); $audit = $this->input->get('audit'); $proses = $this->input->get('proses'); $telemarketer = $this->input->get('telemarketer'); if ($status != '') { $data[] = $this->db->where('A.status', $status); } if ($event != '') { $data[] = $this->db->where('A.event', $event); } if ($search != '') { $data[] = $this->db->where('( A.sn like "%' . $search . '%" or A.name like "%' . $search . '%" or A.title like "%' . $search . '%" or A.company like "%' . $search . '%" or A.tlp like "%' . $search . '%") '); } if ($telemarketer != '') { $data[] = $this->db->where('A.telemarketer', $telemarketer); } if ($date_from != '' && $date_to != '') { $data[] = $this->db->where('A.dist_date >=', format_ymd($date_from)); $data[] = $this->db->where('A.dist_date <=', format_ymd($date_to)); } if ($valid != '') { $data[] = $this->db->where('A.valid', $valid); } if ($audit != '') { $data[] = $this->db->where('A.audit', $audit); } if ($proses != '') { $data[] = $this->db->where('A.audit', 0); $data[] = $this->db->where('A.valid', 0); } return $data; }
function date_check() { if ($this->input->post('disable_on') != '') { if (format_ymd($this->input->post('disable_on')) <= format_ymd($this->input->post('enable_on'))) { $this->form_validation->set_message('date_check', lang('date_error')); return FALSE; } } return TRUE; }
public function _header($pdf) { $date_from = $this->input->get("date_from"); $date_to = $this->input->get("date_to"); $event = $this->event_model->get_event_name($this->input->get("event")); $pdf->SetFont('Arial', '', 10); $pdf->Cell(0, 5, 'Periode Tanggal : ' . $date_from . ' s/d ' . $date_to, 0, 0, 'C'); $pdf->Ln(5); $pdf->Cell(0, 5, 'Event : ' . $event, 0, 0, 'L'); $pdf->Ln(10); $pdf->SetFont('Arial', 'B', 10); $pdf->SetDrawColor(0, 0, 0); $pdf->SetTextColor(0, 0, 0); $pdf->Cell(10, 21, 'No', 1, 0, 'C'); $pdf->Cell(40, 21, 'Moderator', 1, 0, 'C'); $from = date_create(format_ymd($date_from)); $to = date_create(format_ymd($date_to)); $j = 0; while ($from <= $to) { $pdf->SetXY(60 + $j, 35); $pdf->Cell(18, 7, get_day(date_format($from, "N")), 1, 0, 'C'); $pdf->SetXY(60 + $j, 42); $pdf->Cell(18, 7, date_format($from, "d/m/y"), 1, 0, 'C'); $pdf->SetXY(60 + $j, 49); $pdf->Cell(6, 7, "S", 1, 0, 'C'); $pdf->Cell(6, 7, "M", 1, 0, 'C'); $pdf->Cell(6, 7, "T", 1, 0, 'C'); date_add($from, date_interval_create_from_date_string('1 days')); $j += 18; } $pdf->SetXY($j + 60, 35); $pdf->Cell(25, 21, 'Siang', 1, 0, 'C'); $pdf->Cell(25, 21, 'Malam', 1, 0, 'C'); $pdf->Cell(25, 21, 'Training', 1, 0, 'C'); $pdf->Cell(0, 21, 'Total', 1, 0, 'C'); $pdf->Ln(21); }
private function _field() { $data = array('nomor' => $this->input->post('nomor'), 'kendaraan' => $this->input->post('kendaraan'), 'tanggal' => format_ymd($this->input->post('tanggal')), 'tipe' => $this->input->post('tipe'), 'kilometer' => $this->input->post('kilometer')); return $data; }
function banner_form($banner_collection_id, $id = false) { $config['upload_path'] = 'uploads'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = $this->config->item('size_limit'); $config['encrypt_name'] = true; $this->load->library('upload', $config); $this->load->helper(array('form', 'date')); $this->load->library('form_validation'); //set the default values $data = array('banner_id' => $id, 'banner_collection_id' => $banner_collection_id, 'name' => '', 'enable_date' => '', 'disable_date' => '', 'image' => '', 'link' => '', 'new_window' => false); if ($id) { $data = array_merge($data, (array) $this->banner_model->banner($id)); $data['enable_date'] = format_mdy($data['enable_date']); $data['disable_date'] = format_mdy($data['disable_date']); $data['new_window'] = (bool) $data['new_window']; } $data['page_title'] = lang('banner_form'); $this->form_validation->set_rules('name', 'lang:name', 'trim|required|full_decode'); $this->form_validation->set_rules('enable_date', 'lang:enable_date', 'trim'); $this->form_validation->set_rules('disable_date', 'lang:disable_date', 'trim|callback_date_check'); $this->form_validation->set_rules('image', 'lang:image', 'trim'); $this->form_validation->set_rules('link', 'lang:link', 'trim'); $this->form_validation->set_rules('new_window', 'lang:new_window', 'trim'); if ($this->form_validation->run() == false) { $data['error'] = validation_errors(); $this->view(config_item('admin_folder') . '/banner_form', $data); } else { $uploaded = $this->upload->do_upload('image'); $save['banner_collection_id'] = $banner_collection_id; $save['name'] = $this->input->post('name'); $save['enable_date'] = format_ymd($this->input->post('enable_date')); $save['disable_date'] = format_ymd($this->input->post('disable_date')); $save['link'] = $this->input->post('link'); $save['new_window'] = $this->input->post('new_window'); if ($id) { $save['banner_id'] = $id; //delete the original file if another is uploaded if ($uploaded) { if ($data['image'] != '') { $file = 'uploads/' . $data['image']; //delete the existing file if needed if (file_exists($file)) { unlink($file); } } } } else { if (!$uploaded) { $data['error'] = $this->upload->display_errors(); $this->view(config_item('admin_folder') . '/banner_form', $data); return; //end script here if there is an error } } if ($uploaded) { $image = $this->upload->data(); $save['image'] = $image['file_name']; } $this->banner_model->save_banner($save); $this->session->set_flashdata('message', lang('message_banner_saved')); redirect(config_item('admin_folder') . '/banners/banner_collection/' . $banner_collection_id); } }
private function _field() { $data = array('norek' => $this->input->post('norek'), 'tanggal' => format_ymd($this->input->post('tanggal')), 'tipe' => $this->input->post('tipe'), 'jumlah' => str_replace(',', '', $this->input->post('jumlah'))); return $data; }