private function _download($shifts) { $app_conf = HC_App::app_conf(); $separator = $app_conf->get('csv_separator'); // header $headers = array(HCM::__('Type'), HCM::__('Date'), HCM::__('Time'), HCM::__('Duration'), HCM::__('Staff'), HCM::__('Location'), HCM::__('Status')); $data = array(); $data[] = join($separator, $headers); $t = HC_Lib::time(); // shifts foreach ($shifts as $sh) { $values = array(); // type $values[] = $sh->present_type(HC_PRESENTER::VIEW_RAW); // date $values[] = $sh->present_date(HC_PRESENTER::VIEW_RAW); // time $values[] = $sh->present_time(HC_PRESENTER::VIEW_RAW); // duration $values[] = $t->formatPeriodExtraShort($sh->get_duration(), 'hour'); // staff $values[] = $sh->present_user(HC_PRESENTER::VIEW_RAW); // location $values[] = $sh->present_location(HC_PRESENTER::VIEW_RAW); // status $values[] = $sh->present_status(HC_PRESENTER::VIEW_RAW); /* add csv line */ $data[] = HC_Lib::build_csv(array_values($values), $separator); } // output $out = join("\n", $data); $file_name = isset($this->conf['export']) ? $this->conf['export'] : 'export'; $file_name .= '-' . date('Y-m-d_H-i') . '.csv'; $this->load->helper('download'); force_download($file_name, $out); return; }