<?php
/**
 * 领导机构CSV下载
 * $Id: government_list_csv_download.php
 * @author lixq
 * @access public
 * @package manager.public_html
 */

header("Cache-Control:no-cache,must-revalidate,no-store");
header("Pragma:no-cache");
header("Expires:-1");
 
// 底层包含
require_once("manager_include.inc");

// 登录检查
require_once("check_login.inc");

// 权限检查
if (!checkAuthority("ADMIN")) {
  // エラー表示
  $layout_pages = array();
  $layout_pages["left"] = "menu.inc";
  $layout_pages["right"] = "error.inc";
  $message = "权限不足，请联系系统管理员。";
  require_once(MANAGER_TEMPLATE_DIR_PATH . "/layout/leftmenu_layout.inc");
  exit;
}

$government_mst = GovernmentMst::getList();

ini_set("memory_limit", "1024M");
$data = array();
$header = array("区域(省级)","区域(市级)","区域(区县)","名称");
array_push($data, $header);

if (count($government_mst) > 0) {
  foreach($government_mst as $tmp) {
    array_push($data, array($tmp->province,$tmp->city,$tmp->district,$tmp->title));
  }
}
// 出力
$output_file_name = "领导机构". date("YmdHis") . ".csv";

$csv = new CsvFormat($data);
$csv->setEncodingConvert(true,"UTF-8");
$csv->setFileName($output_file_name);
$csv->printOut();
exit;
?>