Пример #1
8
 function do_get_zipcodes($f3, $args)
 {
     $zipcodes = fOption::load_zipcodes(f3()->get('POST')['query']);
     $rtn = array();
     $rtn['html'] = '<option value="">請選擇</option>';
     foreach ($zipcodes as $value) {
         $rtn['html'] .= '<option value="' . $value['town'] . ' ' . $value['zipcode'] . '">' . $value['town'] . ' ' . $value['zipcode'] . '</option>';
     }
     return parent::_return(1, $rtn);
 }
Пример #2
6
 /**
  * adapter for PHPExcel
  *
  * @param  string  $filename -
  * @param  integer $startRow -
  * @param  integer $endRow   -
  * @param  array   $columns  -
  *
  * @return array
  */
 static function readExcel($filename, $startRow, $endRow, $columns)
 {
     $root = f3()->get('ROOT') . f3()->get('BASE');
     // include_once $root . f3()->get('vendors') . 'PHPExcel/IOFactory.php';
     $inputFileName = $root . '' . $filename;
     $filterSubset = new XlsReadFilter($startRow, $endRow, $columns);
     try {
         $inputFileType = PHPExcel_IOFactory::identify($inputFileName);
         $objReader = PHPExcel_IOFactory::createReader($inputFileType);
         $objReader->setReadDataOnly(true);
         $objReader->setReadFilter($filterSubset);
         $objPHPExcel = $objReader->load($inputFileName);
         return $objPHPExcel->getActiveSheet()->toArray(null, true, true, true);
     } catch (PHPExcel_Reader_Exception $e) {
         Reaction::_return("2005", str_replace($root, '', $e->getMessage()));
     }
 }
Пример #3
5
 function do_dl_csv($f3, $args)
 {
     if (!rStaff::_isLogin()) {
         return parent::_return(8001);
     }
     $rows = $this->_db->exec("SELECT * FROM `" . self::fmTbl() . "` ORDER BY insert_ts DESC ");
     if (!$rows) {
         header("Content-Type:text/html; charset=utf-8");
         echo '無結果';
     } else {
         $template = new Template();
         f3()->set('rows', $rows);
         Outfit::_setXls("contact_" . date("YmdHis"));
         echo $template->render('contact.dl.html', "application/vnd.ms-excel");
     }
 }
Пример #4
5
 static function _chkLogin()
 {
     if (!self::_isLogin()) {
         return parent::_return(8001);
     }
 }
Пример #5
3
 function do_save_new_schedules($f3, $args)
 {
     $allData = json_decode(f3()->get('SESSION.uploadPrograms'), true);
     db()->begin();
     foreach ($allData['schedules'] as $prog) {
         $program = Program::get_program_by_codename($prog['c']);
         if (empty($program)) {
             $program['title'] = $prog['c'];
             $program['uri'] = '';
             $program['id'] = 0;
         }
         db()->exec("INSERT INTO `" . tpf() . "schedules`(`title`, `uri`, `program_id`, `start_date`, `end_date`, `status`, `last_ts`, " . "`last_user`, `insert_user`, `insert_ts`) VALUES ('" . $program['title'] . "', '" . $program['uri'] . "', '" . $program['id'] . "', '" . $prog['d'] . " " . $prog['s'] . ":00', '" . $prog['d'] . " " . $prog['e'] . ":00', 'Yes', '" . date('Y-m-d H:i:s') . "', '" . rStaff::_CStaff('id') . "', '" . rStaff::_CStaff('id') . "', '" . date('Y-m-d H:i:s') . "')");
     }
     db()->commit();
     return parent::_return(1, $allData['schedules']);
 }
Пример #6
2
 /**
  * save sorter
  * @param  object $f3   - $f3
  * @param  array  $args - uri params
  * @return array        - std json
  */
 function do_update_sorter($f3, $args)
 {
     rStaff::_chkLogin();
     $req = parent::_getReq();
     foreach ($req['data'] as $row) {
         fMenu::update_sorter($row['id'], $row['sorter']);
     }
     return parent::_return(1, $req);
 }