Esempio n. 1
0
function sheet_create($gc) {

	$gc->mode = $_GET["mode"];
	$gc->company_no = $_GET["company_no"];
	$gc->mbif = $_GET["mbif"];
	$y = substr($gc->mbif, 0, 4);
	$m = substr($gc->mbif, 4, 2);
	$d = substr($gc->mbif, 6, 2);
	$gc->mbif_t = date('Ym01', mktime(0, 0, 0, $m + 1, 0, $y));
	if(!@checkdate($m, $d, $y)){
		$gc->mbif = date("Ym01", time());
	}

	$gc->mbit = $_GET["mbit"];
	$y = substr($gc->mbit, 0, 4);
	$m = substr($gc->mbit, 4, 2);
	$d = substr($gc->mbit, 6, 2);
	$gc->mbit_t = date('Ymd', mktime(0, 0, 0, $m + 1, 0, $y));
	$gc->mbim = date('Ymd', mktime(0, 0, 0, $m + 2, 0, $y));
	if(!@checkdate($m, $d, $y)){
		$gc->mbit = date("Ymt", time());
	}
	$count_company = get_sum_company_count($gc);

	if($count_company > 0){
		$excel = new PHPExcel();
		// シートの設定
		// セルに値を入れる
		$reader = PHPExcel_IOFactory::createReader('Excel2007');
//		$excel = $reader -> load("seikyu_tpl.xlsm");
		$excel = $reader -> load("seikyu_tpl.xlsx");
		$excel->setActiveSheetIndex(0);
		$sheet = $excel->getActiveSheet();
		$sheet->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
		$sheet->setTitle('sheet namea');
		$sheet->setCellValue('AJ2', substr($gc->mbit, 0, 4));
		$sheet->setCellValue('AN2', substr($gc->mbit, 4, 2));
		$sheet->setCellValue('AR2', substr($gc->mbit_t, 6, 2));
		$sheet->setCellValue('B12', '支払は弊社指定銀行に'.substr($gc->mbim, 4, 2).'月'.substr($gc->mbim, 6, 2).'日までに振込みをお願いします。');
		$sheet->setCellValue('F34', 'ご入金期限:'.substr($gc->mbim, 0, 4).'年'.substr($gc->mbim, 4, 2).'月'.substr($gc->mbim, 6, 2).'日');
		$excel->setActiveSheetIndex(1);
		$sheet2 = $excel->getActiveSheet();
		$sheet2->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
		$sheet2->setCellValue('P2', substr($gc->mbif_t, 0, 4));
		$sheet2->setCellValue('T2', substr($gc->mbif_t, 4, 2));
		$sheet2->setCellValue('V2', substr($gc->mbif_t, 6, 2));
		$sheet2->setCellValue('Y2', substr($gc->mbit_t, 0, 4));
		$sheet2->setCellValue('AC2', substr($gc->mbit_t, 4, 2));
		$sheet2->setCellValue('AE2', substr($gc->mbit_t, 6, 2));

		$newSheets = array();
		for ($i = 0; $i < $count_company; $i++) {
			if ($i != 0) {
				$newSheets[] = clone $sheet;
				$newSheets[] = clone $sheet2;
			}
		}
		$cnt = 0;
		foreach ($newSheets as $newSheet) {
			$newSheet->setTitle('sheet name'.($cnt));
			$excel->addSheet($newSheet);
			$cnt++;
		}

		$sql = sql_text_create_s($gc);
		$rs = $gc->db->query($sql);

		$s2_maxrow_1 = 25;
		$s2_maxrow_2 = 25;

		$count_company = 0;
		$d_company = "";
		$sum_kingaku["k"] = 0;
		$sum_kingaku["l"] = 0;
		$sum_kingaku["s"] = 0;
		$sum_kingaku["a"] = 0;
		$sum_kingaku["b"] = 0;
		$sum_kingaku["c"] = 0;
		$cno = 1;
		$s1_row = 21;
		$s2_row = 16;
		$s2_row_2 = 1;
		$s2_sheet_cnt = 1;
		$arr_todoufuken = fsel_get_arr_todoufuken($gc);
		$arr_buken_sbt = fdiv_set_buken_sbt_array();
		$arr_rank = fdiv_set_rank_array();
		$sadd_flg = 0;

		mb_internal_encoding("UTF-8");

		while ($rs->eof==false) {
			if($d_company != $rs->fields["company_no"]){
				$sadd_flg++;
				if($s2_row > 16){
					if(($s2_sheet_cnt == 1) && (($s2_row_2+3) < $s2_maxrow_1)){
						sheet2_blank_add($sheet2,$s2_row,(($s2_maxrow_1)-($s2_row_2+3)));
						$s2_row = $s2_row + ($s2_maxrow_1)-($s2_row_2+3);
					}elseif(($s2_sheet_cnt > 1) && (($s2_row_2+3) < $s2_maxrow_2)){
						sheet2_blank_add($sheet2,$s2_row,(($s2_maxrow_2)-($s2_row_2+3)));
						$s2_row = $s2_row + ($s2_maxrow_2)-($s2_row_2+3);
					}
					sheet_sum_add($sheet,$sheet2,$s2_row,$sum_kingaku["k"]);
					sheet1_data_add($sheet,$sum_kingaku);
				}
				$todoufuken_nm = $arr_todoufuken[$rs->fields["sk_todoufuken_no"]];

				if($rs->fields["sk_zip"] != ""){
					$zip1 = substr($rs->fields["sk_zip"], 0, 3);
					$zip2 = substr($rs->fields["sk_zip"], 4, 4);
				}else{
					$zip1 = "";
					$zip2 = "";
				}

				$excel->setActiveSheetIndex($count_company);

				$sheet = $excel->getActiveSheet();
				$excel->setActiveSheetIndex(($count_company+1));
				$sheet2 = $excel->getActiveSheet();
				$sheet->setTitle(mb_substr($rs->fields["company_nm"], 0, 28)."_雛形");
				$sheet2->setTitle(mb_substr($rs->fields["company_nm"], 0, 28)."_明細");
//				$sheet->setTitle("雛形");
//				$sheet2->setTitle("明細");
				$sheet2->setCellValue('B3', $zip1);

//				$sheet2->setCellValue('E3', $zip2);
$sheet2->setCellValueExplicit( 'E3', $zip2 );

				$sheet2->setCellValue('A4', $todoufuken_nm.$rs->fields["sk_add1"].$rs->fields["sk_add2"]);
				$sheet2->setCellValue('A6', $rs->fields["company_nm"]);
				$sheet2->setCellValue('A8', $rs->fields["sk_tantou"]);
				$sheet->setCellValue('G2', $rs->fields["sk_zip"]);
				$sheet->setCellValue('F3', $todoufuken_nm.$rs->fields["sk_add1"].$rs->fields["sk_add2"]);
				$sheet->setCellValue('F5', $rs->fields["company_nm"]);
				$sheet->setCellValue('F6', $rs->fields["sk_jigyoubu"]);
				$sheet->setCellValue('F7', $rs->fields["sk_tantou"]);

				$cno = 1;
				$sum_kingaku["k"] = 0;
				$sum_kingaku["l"] = 0;
				$sum_kingaku["s"] = 0;
				$sum_kingaku["a"] = 0;
				$sum_kingaku["b"] = 0;
				$sum_kingaku["c"] = 0;
				$s2_sheet_cnt = 1;
				$s1_row = 21;
				$s2_row = 16;
				$s2_row_2 = 1;
				$count_company = $count_company + 2;

			}

			if($s2_row > 16){
				$sheet2->insertNewRowBefore($s2_row, 1);
				sheet2_merge_row($sheet2,$s2_row);
				$sheet2->getStyle('A'.$s2_row)->getFont()->setStrikethrough(false);
				$sheet2->getStyle('B'.$s2_row)->getFont()->setStrikethrough(false);
				$sheet2->getStyle('F'.$s2_row)->getFont()->setStrikethrough(false);
				$sheet2->getStyle('J'.$s2_row)->getFont()->setStrikethrough(false);
				$sheet2->getStyle('N'.$s2_row)->getFont()->setStrikethrough(false);
				$sheet2->getStyle('R'.$s2_row)->getFont()->setStrikethrough(false);
				$sheet2->getStyle('V'.$s2_row)->getFont()->setStrikethrough(false);
				$sheet2->getStyle('Z'.$s2_row)->getFont()->setStrikethrough(false);
			}

			if($s2_sheet_cnt == 1){
				if($s2_row_2 > $s2_maxrow_1){
					$sheet2->insertNewRowBefore($s2_row, 1);
		$sheet2->setBreak( 'A'.$s2_row , PHPExcel_Worksheet::BREAK_ROW );
					$s2_row++;
					$sheet2->insertNewRowBefore($s2_row, 1);
					$s2_row++;
					sheet2_dup_row($sheet2,$s2_row-2,14);
					sheet2_dup_row($sheet2,$s2_row-1,15);

					sheet2_merge_row($sheet2,$s2_row-1);
					$s2_row_2 = 1;
					$s2_sheet_cnt++;
				}else{
				}
			}else{
				if($s2_row_2 > $s2_maxrow_2){
					$sheet2->insertNewRowBefore($s2_row, 1);
		$sheet2->setBreak( 'A'.$s2_row , PHPExcel_Worksheet::BREAK_ROW );
					$s2_row++;
					$sheet2->insertNewRowBefore($s2_row, 1);
					$s2_row++;
					sheet2_dup_row($sheet2,$s2_row-2,14);
					sheet2_dup_row($sheet2,$s2_row-1,15);
					sheet2_merge_row($sheet2,$s2_row-1);
					$s2_row_2 = 1;
					$s2_sheet_cnt++;
				}else{
				}
			}

			$rank_no = get_rank_s($rs);
			$tesuryou = get_tesuryo_s($rs);
			$buken_sbt_nm = $arr_buken_sbt[$rs->fields["buken_sbt"]];
			$todoufuken_nm = $arr_todoufuken[$rs->fields["todoufuken_no"]];

			if($rank_no != "L"){
				$rank_nm = $arr_rank[$rank_no];
			}else{
				$rank_nm = "L";
			}

			$sheet2->setCellValue('A'.$s2_row, $cno);
			$sheet2->setCellValue('B'.$s2_row, $rs->fields["anken_no"]);
			$sheet2->setCellValue('F'.$s2_row, substr($rs->fields["moushikomibi"], 0, 4)."/".substr($rs->fields["moushikomibi"], 5, 2)."/".substr($rs->fields["moushikomibi"], 8, 2));
			$sheet2->setCellValue('J'.$s2_row, $buken_sbt_nm);
			$sheet2->setCellValue('N'.$s2_row, $rank_nm);
			$sheet2->setCellValue('R'.$s2_row, $todoufuken_nm);
			$sheet2->setCellValue('V'.$s2_row, $rs->fields["shikucyouson_nm"]);
			$sheet2->setCellValue('Z'.$s2_row, $tesuryou);

			if($rs->fields["c_mukou_flg"] > 0){
				$sheet2->getStyle('A'.$s2_row)->getFont()->setStrikethrough(true);
				$sheet2->getStyle('B'.$s2_row)->getFont()->setStrikethrough(true);
				$sheet2->getStyle('F'.$s2_row)->getFont()->setStrikethrough(true);
				$sheet2->getStyle('J'.$s2_row)->getFont()->setStrikethrough(true);
				$sheet2->getStyle('N'.$s2_row)->getFont()->setStrikethrough(true);
				$sheet2->getStyle('R'.$s2_row)->getFont()->setStrikethrough(true);
				$sheet2->getStyle('V'.$s2_row)->getFont()->setStrikethrough(true);
				$sheet2->getStyle('Z'.$s2_row)->getFont()->setStrikethrough(true);
				$tesuryou = 0;
			}

			if($rs->fields["kotei_flg"] > 0){
				$sum_kingaku["k"] = $rs->fields["kotei_flg"];
			}
			switch ($rank_nm) {
			case "L":
				if($tesuryou > 0){
					$sum_kingaku["l"] = $sum_kingaku["l"] + $tesuryou;
				}
				break;
			case "S":
				if($tesuryou > 0){
					$sum_kingaku["s"] = $sum_kingaku["s"] + $tesuryou;
				}
				break;
			case "A":
				if($tesuryou > 0){
					$sum_kingaku["a"] = $sum_kingaku["a"] + $tesuryou;
				}
				break;
			case "B":
				if($tesuryou > 0){
					$sum_kingaku["b"] = $sum_kingaku["b"] + $tesuryou;
				}
				break;
			case "C":
				if($tesuryou > 0){
					$sum_kingaku["c"] = $sum_kingaku["c"] + $tesuryou;
				}
				break;
			}

			$cno++;
			$s2_row++;
			$s2_row_2++;

			$d_company = $rs->fields["company_no"];
			$f_company_nm = $rs->fields["company_nm"];
			$rs->move_next();
		}
//echo print_r($rs->fields, true);
		if(($s2_sheet_cnt == 1) && (($s2_row_2+3) < $s2_maxrow_1)){
			sheet2_blank_add($sheet2,$s2_row,(($s2_maxrow_1)-($s2_row_2+3)));
			$s2_row = $s2_row + ($s2_maxrow_1)-($s2_row_2+3);
		}elseif(($s2_sheet_cnt > 1) && (($s2_row_2+3) < $s2_maxrow_2)){
			sheet2_blank_add($sheet2,$s2_row,(($s2_maxrow_2)-($s2_row_2+3)));
			$s2_row = $s2_row + ($s2_maxrow_2)-($s2_row_2+3);
		}
		sheet_sum_add($sheet,$sheet2,$s2_row,$sum_kingaku["k"]);
		sheet1_data_add($sheet,$sum_kingaku);

		$excel->setActiveSheetIndex(0);
		$excel->getActiveSheet()->setSelectedCells('A1');

		header('Content-Type: application/octet-stream');

		if($gc->company_no > 0){
//			$filename = "請求書_".substr($gc->mbit_t, 0, 4)."年".substr($gc->mbit_t, 4, 2)."月_".$f_company_nm.".xlsm";
			$filename = "請求書_".substr($gc->mbit_t, 0, 4)."年".substr($gc->mbit_t, 4, 2)."月_".$f_company_nm.".xlsx";
		}else{
//			$filename = "請求書_".substr($gc->mbit_t, 0, 4)."年".substr($gc->mbit_t, 4, 2)."月.xlsx";
			$filename = "請求書_".substr($gc->mbit_t, 0, 4)."年".substr($gc->mbit_t, 4, 2)."月.xlsx";
		}
		header('Content-Disposition: attachment;filename="'.$filename.'"');

		$writer = PHPExcel_IOFactory::createWriter($excel, "Excel2007");
		$writer->save('php://output');
	}
}
Esempio n. 2
0
function out_html($gc) {

//	$gc->sum_tesuryou = get_sum_tesuryou($gc);
	$gc->sum_tesuryou = get_sum_tesuryou_d($gc);

	$gc->company_nm = fdb_get_name($gc, "m_company", "company_nm", "company_no", $gc->login_company_no);

	$arr_todoufuken = fsel_get_arr_todoufuken($gc);

	$arr_buken_sbt = fdiv_set_buken_sbt_array();

	$sql = sql_text_create_d($gc);

	switch($_GET["si"]) {
	case "ank":
		$sql.= " p.anken_no".(($_GET["sa"]=="desc") ? " DESC" : "")." ";
		break;
	case "mbi":
		$sql.= " p.moushikomibi".(($_GET["sa"]=="desc") ? " DESC" : "")." ";
		break;
	case "sbt":
		$sql.= " p.buken_sbt".(($_GET["sa"]=="desc") ? " DESC" : "")." ";
		break;
	case "men":
		$sql.= " p.menseki".(($_GET["sa"]=="desc") ? " DESC" : "")." ";
		break;
	case "ran":
		$sql.= " p.rank_no".(($_GET["sa"]=="desc") ? " DESC" : "")." ";
		break;
	case "tod":
		$sql.= " s.todoufuken_no".(($_GET["sa"]=="desc") ? " DESC" : "")." ";
		break;
	case "shi":
		$sql.= " p.buken_shikucyouson_no".(($_GET["sa"]=="desc") ? " DESC" : "")." ";
		break;
	case "muk":
		$sql.= " c3.c_mukou_flg".(($_GET["sa"]=="desc") ? " DESC" : "")." ";
		break;
	case "tes":
		$sql.= " p.tesuryou".(($_GET["sa"]=="desc") ? " DESC" : "")." ";
		break;
	default:
		$sql.= " p.moushikomibi desc ";
	}

	$sql.= f_get_limit($gc->pn, $gc->pl, C_ORDER_LIST_COL_CNT);

	$rs = $gc->db->query($sql);
	$row_count = $gc->db->get_row_count();

	//ページャーの設定
	if($row_count > 0){
		$page_arr = f_page_arr("tesuryo_d.php", $row_count, $gc->pl, C_ORDER_LIST_COL_CNT, C_ORDER_PAGE_TAG_CNT);
	}

	//ソート関連
	$sort_mode["ank"] = "";
	$sort_mode["mbi"] = "";
	$sort_mode["sbt"] = "";
	$sort_mode["men"] = "";
	$sort_mode["ran"] = "";
	$sort_mode["tod"] = "";
	$sort_mode["shi"] = "";
	$sort_mode["muk"] = "";
	$sort_mode["tes"] = "";

	foreach ($sort_mode as $key => &$value) {
		if($key == $_GET["si"]){
			if($_GET["sa"] == "desc"){
				$value = " ▼";
			}else{
				$value = " ▲";
			}
		}
	}

?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8" />
<title>手数料一覧</title>
<!-- *** stylesheet *** -->
<link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
<!-- *** javascript *** -->
<script type="text/javascript" src="js/listpage.js" charset="utf-8"></script>
<script language="JavaScript">
<!--
var submit_flg = false;
function run_submit(fname, mode) {
	document.forms[fname].mode.value = mode;
	if(submit_flg==false){
		//ボタン2度押し対応
		submit_flg = true;
		document.forms[fname].submit();
	}
}
function unload_page(){
	submit_flg = false;
}
window.onunload = unload_page;
function search_run(){
	var o;
	o = document.getElementById('mbif_y');
	var mbif_y = o.options[ o.selectedIndex ].value;
	o = document.getElementById('mbif_m');
	var mbif_m = o.options[ o.selectedIndex ].value;
	o = document.getElementById('mbif_d');
	var mbif_d = o.options[ o.selectedIndex ].value;
	o = document.getElementById('mbit_y');
	var mbit_y = o.options[ o.selectedIndex ].value;
	o = document.getElementById('mbit_m');
	var mbit_m = o.options[ o.selectedIndex ].value;
	o = document.getElementById('mbit_d');
	var mbit_d = o.options[ o.selectedIndex ].value;
	document.forms['form_search'].mbif.value = mbif_y + mbif_m + mbif_d;
	document.forms['form_search'].mbit.value = mbit_y + mbit_m + mbit_d;
	run_submit('form_search', 'search');
}

// -->
</script>
</head>
<body>

<!-- Header -->
<div id="header">
	<div class="shell">
		<!-- Logo + Top Nav -->
		<?php tcom_header_logo_nav($gc) ?>
		<!-- End Logo + Top Nav -->
		<!-- Main Nav -->
		<?php tcom_header_main_nav2($gc, 2) ?>
		<!-- End Main Nav -->
	</div>
</div>
<!-- End Header -->

<!-- Container -->
<div id="container">
	<div class="shell">

		<!-- Small Nav -->
		<div class="small-nav">
			<a href="tesuryo_l.php">手数料管理</a>
			<span>&gt;</span>
			手数料一覧
		</div>
		<!-- End Small Nav -->

		<!-- Main -->
		<div id="main">
			<div class="cl">&nbsp;</div>

			<!-- Content -->
			<div id="content">

				<!-- Box -->
				<div class="box">

					<!-- Form -->
					<div class="form">

						<form name="form_search" action="tesuryo_d.php" method="get" onsubmit="return false">
							<input name="mode" type="hidden" value="">
							<input name="mbif" type="hidden" value="">
							<input name="mbit" type="hidden" value="">

							<div class="box-size4 left">
								<p class="inline-field">
									<label style="display:inline;">集計期間:</label>
									<select id="mbif_y" class="field">
										<?php echo fsel_get_date_y($gc, $gc->mbif_y) ?>
									</select><span class="ml05">年</span>
									<select id="mbif_m" class="field">
										<?php echo fsel_get_date_m($gc, $gc->mbif_m) ?>
									</select><span class="ml05">月</span>
									<select id="mbif_d" class="field">
										<?php echo fsel_get_date_d($gc, $gc->mbif_d) ?>
									</select><span class="ml05">日</span>
									~
									<select id="mbit_y" class="field">
										<?php echo fsel_get_date_y($gc, $gc->mbit_y) ?>
									</select><span class="ml05">年</span>
									<select id="mbit_m" class="field">
										<?php echo fsel_get_date_m($gc, $gc->mbit_m) ?>
									</select><span class="ml05">月</span>
									<select id="mbit_d" class="field">
										<?php echo fsel_get_date_d($gc, $gc->mbit_d) ?>
									</select><span class="ml05">日</span>
									<button type="button" class="button color silver ml30" onclick="search_run();">検索</button>

								</p>
							</div>

							<div class="cl">&nbsp;</div>

						</form>

					</div>
					<!-- End Form -->

					<!-- Box Head -->
					<div class="box-head">
						<h2 class="left">抽出条件・手数料合計</h2>
						<div class="right">
							<div class="cl">&nbsp;</div>
						</div>
					</div>
					<!-- End Box Head -->

					<!-- Form -->
					<div class="form">

						<div class="box-size4 left">
							<p class="inline-field">
								<label style="display:inline;">集計期間:</label>
								<?php echo substr($gc->mbif, 0, 4) ?>年<?php echo substr($gc->mbif, 4, 2) ?>月<?php echo substr($gc->mbif, 6, 2) ?>日
								~
								<?php echo substr($gc->mbit, 0, 4) ?>年<?php echo substr($gc->mbit, 4, 2) ?>月<?php echo substr($gc->mbit, 6, 2) ?>日
							</p>
						</div>
						<div style="float:right;">
							<label class="ml40" style="display:inline;">手数料合計:</label>
							<?php echo number_format($gc->sum_tesuryou) ?>円
						</div>

						<div class="cl">&nbsp;</div>

					</div>
					<!-- End Form -->

					<!-- Box Head -->
					<div class="box-head">
						<h2 class="left">手数料一覧</h2>
						<div class="right">
							<a href="tesuryo_csv.php?mode=2&mbif=<?php echo f_hsc($gc->mbif) ?>&mbit=<?php echo f_hsc($gc->mbit) ?>&company_no=<?php echo f_hsc($gc->login_company_no) ?>" class="custom-button"><span>CSV出力</span></a>
						</div>
					</div>
					<!-- End Box Head -->

					<!-- Table -->
					<div class="table">

<?php if($row_count > 0){ ?>
						<!-- Pagging -->
						<div class="pagging">
							<div class="box-l">
								<?php echo $page_arr["cmes_str"].$page_arr["par1_str"].$page_arr["par2_str"]; ?>
							</div>
							<div class="box-c">
								<div class="margin-center">
									<?php echo $page_arr["back_str"].$page_arr["list_str"].$page_arr["deno_str"].$page_arr["next_str"]; ?>
								</div>
							</div>
							<div class="box-r">
								<label>表示件数:</label>
								<?php echo $page_arr["plst_str"] ?>
							</div>
						</div>
						<!-- End Pagging -->
<?php } ?>

						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<tr style="border-top:solid 1px #e0e0e0;">
								<th width="80" class="ac"><a href="tesuryo_d.php<?php echo f_sq("ank") ?>">案件番号</a><?php echo $sort_mode["ank"] ?></th>
								<th width="80" class="ac"><a href="tesuryo_d.php<?php echo f_sq("mbi") ?>">申込日</a><?php echo $sort_mode["mbi"] ?></th>
								<th width="80" class="ac"><a href="tesuryo_d.php<?php echo f_sq("sbt") ?>">種別</a><?php echo $sort_mode["sbt"] ?></th>
								<th width="80" class="ac"><a href="tesuryo_d.php<?php echo f_sq("men") ?>">延床面積</a><?php echo $sort_mode["men"] ?><br />(平米)</th>
								<th width="50" class="ac"><a href="tesuryo_d.php<?php echo f_sq("ran") ?>">ランク</a><?php echo $sort_mode["ran"] ?></th>
								<th width="70"><a href="tesuryo_d.php<?php echo f_sq("tod") ?>">都道府県</a><?php echo $sort_mode["tod"] ?></th>
								<th><a href="tesuryo_d.php<?php echo f_sq("shi") ?>">市区町村</a><?php echo $sort_mode["shi"] ?></th>
								<th width="40" class="ac"><a href="tesuryo_d.php<?php echo f_sq("muk") ?>">状態</a><?php echo $sort_mode["muk"] ?></th>
								<th width="70" class="ac"><a href="tesuryo_d.php<?php echo f_sq("tes") ?>">手数料</a><?php echo $sort_mode["tes"] ?></th>
								<th width="60" class="ac">詳細</th>
							</tr>

<?php

	$i = 0;

	while ($rs->eof==false) {

		$item_no = $rs->fields["item_no"];
		$anken_no = $rs->fields["anken_no"];
		$buken_sbt = $rs->fields["buken_sbt"];
		$purpose_flg = $rs->fields["purpose_flg"];
		$menseki = $rs->fields["menseki"];
		$rank_no = get_rank_d($rs);
//		$rank_no = $rs->fields["rank_no"];
		$todoufuken_no = $rs->fields["todoufuken_no"];
		$buken_shikucyouson_no = $rs->fields["buken_shikucyouson_no"];
		$shikucyouson_nm = $rs->fields["shikucyouson_nm"];
		$mukou_flg = $rs->fields["mukou_flg"];
		$c_mukou_flg = $rs->fields["c_mukou_flg"];
		$m_cnt = $rs->fields["m_cnt"];
		$y_cnt = $rs->fields["y_cnt"];
		$tesuryou = get_tesuryo_d($rs);
//		$tesuryou = $rs->fields["tesuryou"];
		$moushikomibi = $rs->fields["moushikomibi"];

		$menseki = (float)$menseki;

		$moushikomi_d = substr($moushikomibi, 0, 4)."/".substr($moushikomibi, 5, 2)."/".substr($moushikomibi, 8, 2);
		$moushikomi_t = substr($moushikomibi, 11);

		$todoufuken_nm = $arr_todoufuken[$todoufuken_no];

		$buken_sbt_nm = $arr_buken_sbt[$buken_sbt];

		$arr = fdiv_set_rank_array();

		if($rank_no != "L"){
			$rank_nm = $arr[$rank_no];
		}else{
			$rank_nm = "L";
		}
/*
		if($purpose_flg == 1){
			$rank_nm = "L";
		}
*/
		$odd = "";
		if(($i % 2)==1){
			$odd = " class=\"odd\"";
		}

		echo "<tr".$odd.">";
		echo "<td class=\"ac\">".$anken_no."</td>";
		echo "<td class=\"ac\">".$moushikomi_d."<br />".$moushikomi_t."</td>";
		echo "<td class=\"ac\">".f_hsc($buken_sbt_nm)."</td>";
		echo "<td class=\"ac\">".f_hsc($menseki)."</td>";
		echo "<td class=\"ac\">".f_hsc($rank_nm)."</td>";
		echo "<td>".f_hsc($todoufuken_nm)."</td>";
		echo "<td>".f_hsc($shikucyouson_nm)."</td>";
		echo "<td class=\"ac\" style=\"color: ".($c_mukou_flg==1?"red":"blue").";\">".f_hsc($c_mukou_flg==1?"無効":"有効")."</td>";
		echo "<td class=\"ar\">".f_hsc($mukou_flg==1?"0":$tesuryou)."</td>";
//		echo "<td class=\"ar\">".f_hsc($mukou_flg==1?"0":number_format($tesuryou))."</td>";
		echo "<td class=\"ac\"><button type=\"button\" class=\"list-button\" onclick=\"location.href='item_e.php?item_no=".$item_no."&referrer=tesuryo_d&company_no=".$gc->login_company_no."&mbif=".$gc->mbif."&mbit=".$gc->mbit."';\">詳細</button></td>";
		echo "</tr>";

		$rs->move_next();

		$i++;

	}

	$rs->free_result();

	if($row_count==0){
		echo "<tr>";
		echo "<td colspan=\"10\" align=\"center\">データはありません。</td>";
		echo "</tr>";
	}

?>

						</table>

<?php if($row_count > 0){ ?>
						<!-- Pagging -->
						<div class="pagging">
							<div class="box-l">
								&nbsp;
							</div>
							<div class="box-c">
								<div class="margin-center">
									<?php echo $page_arr["back_str"].$page_arr["list_str"].$page_arr["deno_str"].$page_arr["next_str"]; ?>
								</div>
							</div>
							<div class="box-r">
								<label>表示件数:</label>
								<?php echo $page_arr["plst_str"] ?>
							</div>
						</div>
						<!-- End Pagging -->
<?php } ?>

					</div>
					<!-- Table -->

				</div>
				<!-- End Box -->
				<div class="cl">&nbsp;</div>

			</div>
			<!-- End Content -->
			<div class="cl">&nbsp;</div>

		</div>
		<!-- Main -->
	</div>
</div>
<!-- End Container -->

<!-- Footer -->
	<?php tcom_footer($gc) ?>
<!-- End Footer -->

</body>
</html>
<?php
}
function download_csv_file($gc) {

	$crlf = "\r\n";

	$rank = fdiv_set_rank_array();

	$file_str = "";

	unset($line);

	if($_GET["company_no"]){$company_no_f = $_GET["company_no"];}
	else{$company_no_f = 0;}

	$line[] = csv_item_edit("都道府県コード");
	$line[] = csv_item_edit("都道府県名");
	$line[] = csv_item_edit("市区町村コード");
	$line[] = csv_item_edit("市区町村名");
	$line[] = csv_item_edit("ランク");

	$sql = "SELECT SQL_CALC_FOUND_ROWS";
	$sql.= " company_no,";
	$sql.= " company_nm ";
	$sql.= "FROM";
	$sql.= " m_company ";
	if($company_no_f > 0){
		$sql.= "WHERE";
		$sql.= " company_no='".$company_no_f."' ";
	}
	if($company_no_f == 0){
		$sql.= "WHERE keisai_flg='1' ";
		$sql.= "ORDER BY";
		$sql.= " company_no";
	}

	$rs = $gc->db->query($sql);
	$ccnt = 0;
	while ($rs->eof==false) {

		$company_no_arr[$ccnt] = $rs->fields["company_no"];
		$company_nm = $rs->fields["company_nm"];

		$line[] = csv_item_edit("会社コード");
		$line[] = csv_item_edit($company_nm);

		$ccnt++;

		$rs->move_next();
	}

	$rs->free_result();

	$file_str.= implode(",", $line).$crlf;


	$sql = "SELECT SQL_CALC_FOUND_ROWS";
	$sql.= " t.todoufuken_no,";
	$sql.= " t.todoufuken_nm,";
	$sql.= " s.shikucyouson_no,";
	$sql.= " s.shikucyouson_nm,";
	$sql.= " s.rank_no";
	for ($i=0; $i<$ccnt; $i++) {
		$sql.= ", cad".$i.".shikucyouson_kingaku as csk_".$i." ";
	}
	$sql.= "FROM";
	$sql.= " m_shikucyouson s ";
	$sql.= "INNER JOIN";
	$sql.= " m_todoufuken t ";
	$sql.= "ON";
	$sql.= " s.todoufuken_no = t.todoufuken_no ";
	for ($i=0; $i<$ccnt; $i++) {
		$sql.= "left JOIN";
		$sql.= " (select company_no,shikucyouson_no,shikucyouson_kingaku from m_company_area where company_no=".$company_no_arr[$i].") cad".$i;
		$sql.= " ON ";
		$sql.= " cad".$i.".shikucyouson_no = s.shikucyouson_no ";
	}

	$sql.= "WHERE s.rank_no > 0 ";

	$sql.= "ORDER BY";
	$sql.= " t.todoufuken_no, s.shikucyouson_no";

	$rs = $gc->db->query($sql);

	$row_count = $gc->db->get_row_count();

	$i = 0;

	while ($rs->eof==false) {

		unset($line);

		$todoufuken_no = $rs->fields["todoufuken_no"];
		$todoufuken_nm = $rs->fields["todoufuken_nm"];
		$shikucyouson_no = $rs->fields["shikucyouson_no"];
		$shikucyouson_nm = $rs->fields["shikucyouson_nm"];
		$company_no = $rs->fields["company_no"];
		$company_nm = $rs->fields["company_nm"];
		$rank_no = $rs->fields["rank_no"];
//		$shikucyouson_kingaku = $rs->fields["shikucyouson_kingaku"];

		$line[] = csv_item_edit($todoufuken_no);
		$line[] = csv_item_edit($todoufuken_nm);
		$line[] = csv_item_edit($shikucyouson_no);
		$line[] = csv_item_edit($shikucyouson_nm);
		$line[] = csv_item_edit($rank[$rank_no]);
		for ($i=0; $i<$ccnt; $i++) {
			$line[] = csv_item_edit($company_no_arr[$i]);
			if($rs->fields["csk_".$i] == ""){
				$line[] = csv_item_edit("0");
			}else{
				$line[] = csv_item_edit($rs->fields["csk_".$i]);
			}
		}

		$file_str.= implode(",", $line).$crlf;

		$rs->move_next();

		$i++;

	}

	$rs->free_result();

	$file_str = mb_convert_encoding($file_str, "sjis-win", C_ENCODING);

	$file_length = strlen($file_str);

	$file_name = "company_area";
	if($company_no_f > 0){$file_name .= "_".$company_no_f;}

	header("Content-Disposition: attachment; filename=".$file_name.".csv");
	header("Content-Length:".$file_length);
	header("Content-Type: application/octet-stream");

	echo $file_str;

	return true;

}
Esempio n. 4
0
function out_html($gc) {

	$gc->anken_no = $_GET["anken_no"];

	$sql = "SELECT SQL_CALC_FOUND_ROWS";
	$sql.= " i.item_no,";
	$sql.= " i.anken_no,";
	$sql.= " i.buken_sbt,";
	$sql.= " i.menseki,";
	$sql.= " i.rank_no,";
	$sql.= " i.buken_shikucyouson_no,";
	$sql.= " i.mukou_flg,";
	$sql.= " i.moushikomibi, ";
	$sql.= " c.c_mukou_flg ";
	$sql.= "FROM";
	$sql.= " t_item i ";
	$sql.= "INNER JOIN";
	$sql.= " m_shikucyouson s ";
	$sql.= "ON";
	$sql.= " i.buken_shikucyouson_no = s.shikucyouson_no ";
	$sql.= "LEFT JOIN";
	$sql.= " (select item_no,company_no,c_mukou_flg from t_item_company where company_no=".$gc->login_company_no.") as c ";
	$sql.= "ON";
	$sql.= " i.item_no = c.item_no ";
	$sql.= "WHERE 0 = 0 and c.company_no=".$gc->login_company_no." ";
	if($gc->anken_no != ""){
		$sql.= "and i.anken_no like '%".$gc->anken_no."%' ";
	}


	$sql.= "ORDER BY";

	switch($_GET["si"]) {
	case "ank":
		$sql.= " i.anken_no".(($_GET["sa"]=="desc") ? " DESC" : "")." ";
		break;
	case "mbi":
		$sql.= " i.moushikomibi".(($_GET["sa"]=="desc") ? " DESC" : "")." ";
		break;
	case "sbt":
		$sql.= " i.buken_sbt".(($_GET["sa"]=="desc") ? " DESC" : "")." ";
		break;
	case "men":
		$sql.= " i.menseki".(($_GET["sa"]=="desc") ? " DESC" : "")." ";
		break;
	case "tod":
		$sql.= " s.todoufuken_no".(($_GET["sa"]=="desc") ? " DESC" : "")." ";
		break;
	case "shi":
		$sql.= " s.shikucyouson_no".(($_GET["sa"]=="desc") ? " DESC" : "")." ";
		break;
	case "muk":
		$sql.= " c.c_mukou_flg".(($_GET["sa"]=="desc") ? " DESC" : "")." ";
		break;
	default:
		$sql.= " i.item_no DESC ";
	}

	$sql.= f_get_limit($gc->pn, $gc->pl, C_ORDER_LIST_COL_CNT);

	$rs = $gc->db->query($sql);

	$row_count = $gc->db->get_row_count();
	//ページャーの設定
	if($row_count > 0){
		$page_arr = f_page_arr("item_l.php", $row_count, $gc->pl, C_ORDER_LIST_COL_CNT, C_ORDER_PAGE_TAG_CNT);
	}

	//ソート関連
	$sort_mode["ank"] = "";
	$sort_mode["mbi"] = "";
	$sort_mode["sbt"] = "";
	$sort_mode["men"] = "";
	$sort_mode["tod"] = "";
	$sort_mode["shi"] = "";
	$sort_mode["muk"] = "";

	foreach ($sort_mode as $key => &$value) {
		if($key == $_GET["si"]){
			if($_GET["sa"] == "desc"){
				$value = " ▼";
			}else{
				$value = " ▲";
			}
		}
	}

?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8" />
<title>申込/対応状況</title>
<!-- *** stylesheet *** -->
<link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
<!-- *** javascript *** -->
<script type="text/javascript" src="js/listpage.js" charset="utf-8"></script> 
<script language="JavaScript">
<!--
var submit_flg = false;
function run_submit(fname, mode) {
	document.forms[fname].mode.value = mode;
	if(submit_flg==false){
		//ボタン2度押し対応
		submit_flg = true;
		document.forms[fname].submit();
	}
}
function unload_page(){
	submit_flg = false;
}
window.onunload = unload_page;
// -->
</script>
</head>
<body>

<!-- Header -->
<div id="header">
	<div class="shell">
		<!-- Logo + Top Nav -->
		<?php tcom_header_logo_nav($gc) ?>
		<!-- End Logo + Top Nav -->
		<!-- Main Nav -->
		<?php tcom_header_main_nav2($gc, 1) ?>
		<!-- End Main Nav -->
	</div>
</div>
<!-- End Header -->

<!-- Container -->
<div id="container">
	<div class="shell">

		<!-- Small Nav -->
		<div class="small-nav">
			<a href="item_l.php">案件管理</a>
			<span>&gt;</span>
			申込み/対応状況
		</div>
		<!-- End Small Nav -->

		<!-- Main -->
		<div id="main">
			<div class="cl">&nbsp;</div>

			<!-- Content -->
			<div id="content">

				<!-- Box -->
				<div class="box">

					<!-- Form -->
					<div class="form">

						<form name="form_search" action="item_l.php" method="get" onsubmit="return false">
							<input name="mode" type="hidden" value="">

							<div class="box-size2 left">
								<p class="inline-field">
									<label style="display:inline;">案件番号:</label>
									<input name="anken_no" type="text" class="field size3" value="<?php echo f_hsc($gc->anken_no) ?>" />
									<button type="button" class="button color silver ml05" onclick="run_submit('form_search', 'search');">検索</button>
								</p>
							</div>

							<div class="cl">&nbsp;</div>

						</form>

					</div>
					<!-- End Form -->

					<!-- Box Head -->
					<div class="box-head">
						<h2 class="left">申込み/対応状況</h2>
						<div class="right">
							<a href="item_csv.php" class="custom-button"><span>CSV出力</span></a>
						</div>
					</div>
					<!-- End Box Head -->

					<!-- Table -->
					<div class="table">

<?php if($row_count > 0){ ?>
						<!-- Pagging -->
						<div class="pagging">
							<div class="box-l">
								<?php echo $page_arr["cmes_str"].$page_arr["par1_str"].$page_arr["par2_str"]; ?>
							</div>
							<div class="box-c">
								<div class="margin-center">
									<?php echo $page_arr["back_str"].$page_arr["list_str"].$page_arr["deno_str"].$page_arr["next_str"]; ?>
								</div>
							</div>
							<div class="box-r">
								<label>表示件数:</label>
								<?php echo $page_arr["plst_str"] ?>
							</div>
						</div>
						<!-- End Pagging -->
<?php } ?>

						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<tr style="border-top:solid 1px #e0e0e0;">
								<th width="80" class="ac"><a href="item_l.php<?php echo f_sq("ank") ?>">案件番号</a><?php echo $sort_mode["ank"] ?></th>
								<th width="80" class="ac"><a href="item_l.php<?php echo f_sq("mbi") ?>">申込日</a><?php echo $sort_mode["mbi"] ?></th>
								<th width="80" class="ac"><a href="item_l.php<?php echo f_sq("sbt") ?>">種別</a><?php echo $sort_mode["sbt"] ?></th>
								<th width="80" class="ac"><a href="item_l.php<?php echo f_sq("men") ?>">延床面積</a><?php echo $sort_mode["men"] ?><br />(平米)</th>
								<th width="100" class="ac"><a href="item_l.php<?php echo f_sq("tod") ?>">都道府県</a><?php echo $sort_mode["tod"] ?></th>
								<th><a href="item_l.php<?php echo f_sq("shi") ?>">市区町村</a><?php echo $sort_mode["shi"] ?></th>
								<th width="50" class="ac"><a href="item_l.php<?php echo f_sq("muk") ?>">状態</a><?php echo $sort_mode["muk"] ?></th>
								<th width="70" class="ac">詳細</th>
							</tr>

<?php

	$i = 0;

	while ($rs->eof==false) {

		$item_no = $rs->fields["item_no"];
		$anken_no = $rs->fields["anken_no"];
		$buken_sbt = $rs->fields["buken_sbt"];
		$menseki = $rs->fields["menseki"];
		$rank_no = $rs->fields["rank_no"];
		$buken_shikucyouson_no = $rs->fields["buken_shikucyouson_no"];
		$mukou_flg = $rs->fields["mukou_flg"];
		$c_mukou_flg = $rs->fields["c_mukou_flg"];
		$moushikomibi = $rs->fields["moushikomibi"];

		$menseki = (float)$menseki;

		$moushikomi_d = substr($moushikomibi, 0, 4)."/".substr($moushikomibi, 5, 2)."/".substr($moushikomibi, 8, 2);
		$moushikomi_t = substr($moushikomibi, 11);

		$arr = fdiv_set_buken_sbt_array();
		$buken_sbt_nm = $arr[$buken_sbt];

		$arr = fdiv_set_rank_array();
		$rank_nm = $arr[$rank_no];

		$buken_shikucyouson_nm = fdb_get_name($gc, "m_shikucyouson", "shikucyouson_nm", "shikucyouson_no", $buken_shikucyouson_no);
		$todoufuken_no = fdb_get_name($gc, "m_shikucyouson", "todoufuken_no", "shikucyouson_no", $buken_shikucyouson_no);
		$todoufuken_nm = fdb_get_name($gc, "m_todoufuken", "todoufuken_nm", "todoufuken_no", $todoufuken_no);

		$odd = "";
		if(($i % 2)==1){
			$odd = " class=\"odd\"";
		}

		echo "<tr".$odd.">";
		echo "<td class=\"ac\">".f_hsc($anken_no)."</td>";
		echo "<td class=\"ac\">".$moushikomi_d."<br />".$moushikomi_t."</td>";
		echo "<td class=\"ac\">".f_hsc($buken_sbt_nm)."</td>";
		echo "<td class=\"ac\">".f_hsc($menseki)."</td>";
		echo "<td class=\"ac\">".f_hsc($todoufuken_nm)."</td>";
		echo "<td>".f_hsc($buken_shikucyouson_nm)."</td>";
		echo "<td class=\"ac\" style=\"color: ".($c_mukou_flg==1?"red":"blue").";\">".f_hsc($c_mukou_flg==1?"無効":"有効")."</td>";
		echo "<td class=\"ac\"><button type=\"button\" class=\"list-button\" onclick=\"location.href='item_e.php?mode=edit&item_no=".$item_no."';\">詳細</button></td>";
		echo "</tr>";

		$rs->move_next();

		$i++;

	}

	$rs->free_result();

	if($row_count==0){
		echo "<tr>";
		echo "<td colspan=\"8\" align=\"center\">データはありません。</td>";
		echo "</tr>";
	}

?>

						</table>

<?php if($row_count > 0){ ?>
						<!-- Pagging -->
						<div class="pagging">
							<div class="box-l">
								&nbsp;
							</div>
							<div class="box-c">
								<div class="margin-center">
									<?php echo $page_arr["back_str"].$page_arr["list_str"].$page_arr["deno_str"].$page_arr["next_str"]; ?>
								</div>
							</div>
							<div class="box-r">
								<label>表示件数:</label>
								<?php echo $page_arr["plst_str"] ?>
							</div>
						</div>
						<!-- End Pagging -->
<?php } ?>

					</div>
					<!-- Table -->

				</div>
				<!-- End Box -->
				<div class="cl">&nbsp;</div>

			</div>
			<!-- End Content -->
			<div class="cl">&nbsp;</div>

		</div>
		<!-- Main -->
	</div>
</div>
<!-- End Container -->

<!-- Footer -->
	<?php tcom_footer($gc) ?>
<!-- End Footer -->

</body>
</html>
<?php
}
Esempio n. 5
0
function fsel_get_rank($gc, $select, $name_flg = false)
{
    $array = fdiv_set_rank_array();
    return fdiv_get_select($gc, $select, $name_flg, $array);
}
Esempio n. 6
0
function download_csv($gc) {

	$crlf = "\r\n";

	$arr_todoufuken = fsel_get_arr_todoufuken($gc);
	$arr_purpose_arr = fdiv_set_purpose_array();
	$arr_buken_sbt = fdiv_set_buken_sbt_array();
	$arr_madori = fdiv_set_madori_array();
	$arr_meigi = fdiv_set_meigi_array();
	$arr_genjyou = fdiv_set_genjyou_array();

	$arr_rank = fdiv_set_rank_array();

	$file_str = "";

	unset($line);

	$line[] = csv_item_edit("案件番号");
	$line[] = csv_item_edit("申込日時");
	$line[] = csv_item_edit("ご利用目的");
	$line[] = csv_item_edit("希望のサービス");
	$line[] = csv_item_edit("物件種別");
	$line[] = csv_item_edit("物件所在地");
	$line[] = csv_item_edit("町名・番地");
	$line[] = csv_item_edit("建物名・部屋番号");
	$line[] = csv_item_edit("築年数");
	$line[] = csv_item_edit("面積");
	$line[] = csv_item_edit("間取り");
	$line[] = csv_item_edit("名義");
	$line[] = csv_item_edit("現況");
	$line[] = csv_item_edit("お名前");
	$line[] = csv_item_edit("フリガナ");
	$line[] = csv_item_edit("電話番号");
	$line[] = csv_item_edit("メールアドレス");
	$line[] = csv_item_edit("お住まい");
	$line[] = csv_item_edit("町名・番地");
	$line[] = csv_item_edit("建物名・部屋番号");
	$line[] = csv_item_edit("ご要望・ご質問など");
	$line[] = csv_item_edit("ランク");
//	$line[] = csv_item_edit("手数料");

	$file_str.= implode(",", $line).$crlf;

	/////////////////////////////////////////////////////////////

	$sql = "SELECT SQL_CALC_FOUND_ROWS";
	$sql.= " itm.item_no,";
	$sql.= " itm.anken_no,";
	$sql.= " itm.relocation_flg,";
	$sql.= " itm.chintai_flg,";
	$sql.= " itm.sublease_flg,";
	$sql.= " itm.purpose_flg,";
	$sql.= " itm.buken_sbt,";
	$sql.= " itm.buken_shikucyouson_no,";
	$sql.= " itm.buken_banchi,";
	$sql.= " itm.buken_tatemono,";
	$sql.= " itm.chikunensu,";
	$sql.= " itm.menseki,";
	$sql.= " itm.input_val,";
	$sql.= " itm.input_kbn,";
	$sql.= " itm.land_val,";
	$sql.= " itm.madori_no,";
	$sql.= " itm.meigi_no,";
	$sql.= " itm.genjyou_no,";
	$sql.= " itm.room_cnt,";
	$sql.= " itm.fudousan_flg,";
	$sql.= " itm.fudousan_nm,";
	$sql.= " itm.bikou,";
	$sql.= " itm.lname,";
	$sql.= " itm.fname,";
	$sql.= " itm.lname_kn,";
	$sql.= " itm.fname_kn,";
	$sql.= " itm.tel,";
	$sql.= " itm.e_mail,";
	$sql.= " itm.sumai_flg,";
	$sql.= " itm.sumai_shikucyouson_no,";
	$sql.= " itm.sumai_banchi,";
	$sql.= " itm.sumai_tatemono,";
	$sql.= " itm.moushikomibi,";
	$sql.= " itm.rank_no,";
	$sql.= " itm.tesuryou,";
	$sql.= " itm.mukou_flg,";
	$sql.= " itc.c_mukou_flg,";
	$sql.= " itc.company_no,";
	$sql.= " ad1.todoufuken_no AS buken_todoufuken_no,";
	$sql.= " ad1.shikucyouson_nm AS buken_shikucyouson_nm,";
	$sql.= " ad2.todoufuken_no AS sumai_todoufuken_no,";
	$sql.= " ad2.shikucyouson_nm AS sumai_shikucyouson_nm,";
	$sql.= " mco.company_no,";
	$sql.= " mco.company_nm ";
	$sql.= "FROM";
	$sql.= " t_item itm ";
	$sql.= "INNER JOIN";
	$sql.= " t_item_company itc ";
	$sql.= "ON";
	$sql.= " itm.item_no = itc.item_no ";
	$sql.= "INNER JOIN";
	$sql.= " m_company mco ";
	$sql.= "ON";
	$sql.= " itc.company_no = mco.company_no ";
	$sql.= "LEFT JOIN";
	$sql.= " m_shikucyouson ad1 ";
	$sql.= "ON";
	$sql.= " itm.buken_shikucyouson_no = ad1.shikucyouson_no ";
	$sql.= "LEFT JOIN";
	$sql.= " m_shikucyouson ad2 ";
	$sql.= "ON";
	$sql.= " itm.sumai_shikucyouson_no = ad2.shikucyouson_no ";
	$sql.= "WHERE itc.c_mukou_flg = 0 and itc.company_no=".$gc->login_company_no." ";
	$sql.= "ORDER BY";
	$sql.= " itm.moushikomibi DESC, mco.company_no";

	$rs = $gc->db->query($sql);

	$row_count = $gc->db->get_row_count();

	$i = 0;

	$wk_item_no = "";

	$arr_company_nm = array();

	while ($rs->eof==false) {

		$item_no = $rs->fields["item_no"];

		if($item_no != $wk_item_no){

			$wk_item_no = $item_no;

			if( $i > 0 ){

				unset($line);

				$line[] = csv_item_edit($anken_no);
				$line[] = csv_item_edit($moushikomibi);
				$line[] = csv_item_edit($purpose_str);
				$line[] = csv_item_edit($kibou_str);
				$line[] = csv_item_edit($buken_sbt_nm);
				$line[] = csv_item_edit($buken_todoufuken_nm.$buken_shikucyouson_nm);
				$line[] = csv_item_edit($buken_banchi);
				$line[] = csv_item_edit($buken_tatemono);
				$line[] = csv_item_edit($chikunensu);
				$line[] = csv_item_edit($menseki);
				$line[] = csv_item_edit($madori_nm);
				$line[] = csv_item_edit($meigi_nm);
				$line[] = csv_item_edit($genjyou_nm);
				$line[] = csv_item_edit($lname.$fname);
				$line[] = csv_item_edit($lname_kn.$fname_kn);
				$line[] = csv_item_edit($tel);
				$line[] = csv_item_edit($e_mail);
				$line[] = csv_item_edit($sumai_todoufuken_nm.$sumai_shikucyouson_nm);
				$line[] = csv_item_edit($sumai_banchi);
				$line[] = csv_item_edit($sumai_tatemono);
				$line[] = csv_item_edit($bikou);
				$line[] = csv_item_edit($rank_nm);
//				$line[] = csv_item_edit($tesuryou);

				$file_str.= implode(",", $line).$crlf;

				$arr_company_nm = array();

			}

			// --------------------------------------------------------------------

			$anken_no = $rs->fields["anken_no"];
			$relocation_flg = $rs->fields["relocation_flg"];
			$chintai_flg = $rs->fields["chintai_flg"];
			$sublease_flg = $rs->fields["sublease_flg"];
			$purpose_flg = $rs->fields["purpose_flg"];
			$buken_sbt = $rs->fields["buken_sbt"];
			$buken_shikucyouson_no = $rs->fields["buken_shikucyouson_no"];
			$buken_banchi = $rs->fields["buken_banchi"];
			$buken_tatemono = $rs->fields["buken_tatemono"];
			$chikunensu = $rs->fields["chikunensu"];
			$menseki = $rs->fields["menseki"];
			$input_val = $rs->fields["input_val"];
			$input_kbn = $rs->fields["input_kbn"];
			$land_val = $rs->fields["land_val"];
			$madori_no = $rs->fields["madori_no"];
			$meigi_no = $rs->fields["meigi_no"];
			$genjyou_no = $rs->fields["genjyou_no"];
			$room_cnt = $rs->fields["room_cnt"];
			$fudousan_flg = $rs->fields["fudousan_flg"];
			$fudousan_nm = $rs->fields["fudousan_nm"];
			$bikou = $rs->fields["bikou"];
			$lname = $rs->fields["lname"];
			$fname = $rs->fields["fname"];
			$lname_kn = $rs->fields["lname_kn"];
			$fname_kn = $rs->fields["fname_kn"];
			$tel = $rs->fields["tel"];
			$e_mail = $rs->fields["e_mail"];
			$sumai_flg = $rs->fields["sumai_flg"];
			$sumai_shikucyouson_no = $rs->fields["sumai_shikucyouson_no"];
			$sumai_banchi = $rs->fields["sumai_banchi"];
			$sumai_tatemono = $rs->fields["sumai_tatemono"];
			$moushikomibi = $rs->fields["moushikomibi"];
			$rank_no = $rs->fields["rank_no"];
			$tesuryou = $rs->fields["tesuryou"];
			$mukou_flg = $rs->fields["mukou_flg"];

			$purpose_str = $arr_purpose_arr[$purpose_flg];

			$arr_work = array();
			if($chintai_flg == 1){
				$arr_work[] = "賃貸募集・賃貸管理";
			}
			if($sublease_flg == 1) {
				$arr_work[] = "サブリース";
			}
			if($relocation_flg == 1) {
				$arr_work[] = "リロケーション";
			}
			$kibou_str = implode(" ", $arr_work);

			$buken_sbt_nm = $arr_buken_sbt[$buken_sbt];

			$madori_nm = $arr_madori[$madori_no];

			$meigi_nm = $arr_meigi[$meigi_no];

			$genjyou_nm = $arr_genjyou[$genjyou_no];
			if($room_cnt > 0){
				$genjyou_nm = $genjyou_nm." 空き部屋数 ".$room_cnt;
			}

			$buken_todoufuken_no = $rs->fields["buken_todoufuken_no"];
			$buken_todoufuken_nm = $arr_todoufuken[$buken_todoufuken_no];
			$buken_shikucyouson_nm = $rs->fields["buken_shikucyouson_nm"];

			$sumai_todoufuken_no = $rs->fields["sumai_todoufuken_no"];
			$sumai_todoufuken_nm = $arr_todoufuken[$sumai_todoufuken_no];
			$sumai_shikucyouson_nm = $rs->fields["sumai_shikucyouson_nm"];

			$rank_nm = $arr_rank[$rank_no];

			$mukou_str = "有効";
			if($mukou_flg==1){
				$mukou_str = "無効";
			}

		}

		$arr_company_nm[] = $rs->fields["company_nm"];

		$rs->move_next();

		$i++;

	}

	$rs->free_result();

	// ----------------------------------------------------------------

	unset($line);

	$line[] = csv_item_edit($anken_no);
	$line[] = csv_item_edit($moushikomibi);
	$line[] = csv_item_edit($purpose_str);
	$line[] = csv_item_edit($kibou_str);
	$line[] = csv_item_edit($buken_sbt_nm);
	$line[] = csv_item_edit($buken_todoufuken_nm.$buken_shikucyouson_nm);
	$line[] = csv_item_edit($buken_banchi);
	$line[] = csv_item_edit($buken_tatemono);
	$line[] = csv_item_edit($chikunensu);
	$line[] = csv_item_edit($menseki);
	$line[] = csv_item_edit($madori_nm);
	$line[] = csv_item_edit($meigi_nm);
	$line[] = csv_item_edit($genjyou_nm);
	$line[] = csv_item_edit($lname.$fname);
	$line[] = csv_item_edit($lname_kn.$fname_kn);
	$line[] = csv_item_edit($tel);
	$line[] = csv_item_edit($e_mail);
	$line[] = csv_item_edit($sumai_todoufuken_nm.$sumai_shikucyouson_nm);
	$line[] = csv_item_edit($sumai_banchi);
	$line[] = csv_item_edit($sumai_tatemono);
	$line[] = csv_item_edit($bikou);
	$line[] = csv_item_edit($rank_nm);
//	$line[] = csv_item_edit($tesuryou);

	$file_str.= implode(",", $line).$crlf;

	// ----------------------------------------------------------------

	$file_str = mb_convert_encoding($file_str, "sjis-win", C_ENCODING);

	$file_length = strlen($file_str);

	$file_name = "案件.csv";
	$agent = $_SERVER['HTTP_USER_AGENT'];
	if(strstr($agent, "MSIE")){
		$file_name = urlencode($file_name);
	}

	header("Content-Disposition: attachment; filename=".$file_name);
	header("Content-Length:".$file_length);
	header("Content-Type: application/octet-stream");

	echo $file_str;

	return true;

}
Esempio n. 7
0
function download_csv_file2($gc) {

	$crlf = "\r\n";

	$arr_todoufuken = fsel_get_arr_todoufuken($gc);

	$rank = fdiv_set_rank_array();

	$file_str = "";

	unset($line);

	$line[] = csv_item_edit("案件番号");
	$line[] = csv_item_edit("申込日");
	$line[] = csv_item_edit("種別");
	$line[] = csv_item_edit("延床面積(平米)");
	$line[] = csv_item_edit("ランク");
	$line[] = csv_item_edit("都道府県");
	$line[] = csv_item_edit("市区町村");
	$line[] = csv_item_edit("有効");
	$line[] = csv_item_edit("無効");
	$line[] = csv_item_edit("手数料");

	$file_str.= implode(",", $line).$crlf;

	/////////////////////////////////////////////////////////////

	$gc->mbif = $_GET["mbif"];
	$y = substr($gc->mbif, 0, 4);
	$m = substr($gc->mbif, 4, 2);
	$d = substr($gc->mbif, 6, 4);
	if(!@checkdate($m, $d, $y)){
		$gc->mbif = date("Ym01", time());
	}

	$gc->mbit = $_GET["mbit"];
	$y = substr($gc->mbit, 0, 4);
	$m = substr($gc->mbit, 4, 2);
	$d = substr($gc->mbit, 6, 4);
	if(!@checkdate($m, $d, $y)){
		$gc->mbit = date("Ymt", time());
	}

	$gc->company_no = $_GET["company_no"];
	if(!is_numeric($gc->company_no)){
		$gc->company_no = 0;
	}

	$gc->company_nm = fdb_get_name($gc, "m_company", "company_nm", "company_no", $gc->company_no);

	$arr_todoufuken = fsel_get_arr_todoufuken($gc);
	$arr_buken_sbt = fdiv_set_buken_sbt_array();
	$arr_rank = fdiv_set_rank_array();

	$sql = sql_text_create_d_csv($gc);
	$sql.= " p.item_no";

	$rs = $gc->db->query($sql);

	$row_count = $gc->db->get_row_count();

	$i = 0;

	while ($rs->eof==false) {

		unset($line);

		$item_no = $rs->fields["item_no"];
		$anken_no = $rs->fields["anken_no"];
		$buken_sbt = $rs->fields["buken_sbt"];
		$menseki = $rs->fields["menseki"];
		$purpose_flg = $rs->fields["purpose_flg"];
		$rank_no = get_rank_d($rs);
//		$rank_no = $rs->fields["rank_no"];
		$todoufuken_no = $rs->fields["todoufuken_no"];
		$buken_shikucyouson_no = $rs->fields["buken_shikucyouson_no"];
		$shikucyouson_nm = $rs->fields["shikucyouson_nm"];
		$mukou_flg = $rs->fields["mukou_flg"];
		$m_cnt = $rs->fields["m_cnt"];
		$y_cnt = $rs->fields["y_cnt"];
		$tesuryou = get_tesuryo_d($rs);
//		$tesuryou = $rs->fields["tesuryou"];
		$moushikomibi = $rs->fields["moushikomibi"];

		$moushikomi_d = substr($moushikomibi, 0, 4)."/".substr($moushikomibi, 5, 2)."/".substr($moushikomibi, 8, 2);

		$todoufuken_nm = $arr_todoufuken[$todoufuken_no];

		$buken_sbt_nm = $arr_buken_sbt[$buken_sbt];

		if($rank_no != "L"){
			$rank_nm = $arr_rank[$rank_no];
		}else{
			$rank_nm = "L";
		}
/*
		if($purpose_flg == 1){
			$rank_nm = "L";
		}
*/
		$line[] = csv_item_edit($anken_no);
		$line[] = csv_item_edit($moushikomi_d);
		$line[] = csv_item_edit($buken_sbt_nm);
		$line[] = csv_item_edit($menseki);
		$line[] = csv_item_edit($rank_nm);
		$line[] = csv_item_edit($todoufuken_nm);
		$line[] = csv_item_edit($shikucyouson_nm);
		$line[] = csv_item_edit($y_cnt);
		$line[] = csv_item_edit($m_cnt);
//		$line[] = csv_item_edit($mukou_flg==1?"無効":"有効");
		$line[] = csv_item_edit( ( $mukou_flg==1?"0":$tesuryou ) );
//		$line[] = csv_item_edit( ( $mukou_flg==1?"0":number_format($tesuryou) ) );

		$file_str.= implode(",", $line).$crlf;

		$rs->move_next();

		$i++;

	}

	$rs->free_result();

	$file_str = mb_convert_encoding($file_str, "sjis-win", C_ENCODING);

	$file_length = strlen($file_str);

	$file_name = $gc->company_nm."(".substr($gc->mbif, 0, 4)."年".substr($gc->mbif, 4, 2)."月".substr($gc->mbif, 6, 2)."日から".substr($gc->mbit, 0, 4)."年".substr($gc->mbit, 4, 2)."月".substr($gc->mbit, 6, 2).").csv";
	$agent = $_SERVER['HTTP_USER_AGENT'];
	if(strstr($agent, "MSIE")){
		$file_name = urlencode($file_name);
	}

	header("Content-Disposition: attachment; filename=".$file_name);
	header("Content-Length:".$file_length);
	header("Content-Type: application/octet-stream");

	echo $file_str;

	return true;

}
function download_csv_file($gc) {

	$crlf = "\r\n";

	$rank = fdiv_set_rank_array();

	$file_str = "";

	unset($line);

	if($_GET["company_no"]){$company_no_f = $_GET["company_no"];}
	else{$company_no_f = 0;}

	$line[] = csv_item_edit("都道府県コード");
	$line[] = csv_item_edit("都道府県名");
	$line[] = csv_item_edit("市区町村コード");
	$line[] = csv_item_edit("市区町村名");
	$line[] = csv_item_edit("ランク");

	$sql = "SELECT SQL_CALC_FOUND_ROWS";
	$sql.= " company_no,";
	$sql.= " company_nm ";
	$sql.= "FROM";
	$sql.= " m_company ";
	if($company_no_f > 0){
		$sql.= "WHERE";
		$sql.= " company_no='".$company_no_f."' ";
	}
	if($company_no_f == 0){//★★★ 抽出条件注意 ★★★ ★★★ 抽出条件注意 ★★★ ★★★ 抽出条件注意 ★★★
		$sql.= "WHERE keisai_flg='1' OR company_no=9 ";
		$sql.= "ORDER BY";
		$sql.= " company_no";
	}

	$rs = $gc->db->query($sql);
	$ccnt = 0;
	while ($rs->eof==false) {

		$company_no_arr[$ccnt] = $rs->fields["company_no"];
		$company_nm = $rs->fields["company_nm"];

		$line[] = csv_item_edit($company_nm."(件数)");
		$line[] = csv_item_edit($company_nm."(手数料)");

		$ccnt++;

		$rs->move_next();
	}

	$rs->free_result();

		$line[] = csv_item_edit("合計(件数)");
		$line[] = csv_item_edit("合計(手数料)");

	$file_str.= implode(",", $line).$crlf;


	$sql = "SELECT SQL_CALC_FOUND_ROWS";
	$sql.= " t.todoufuken_no,";
	$sql.= " t.todoufuken_nm,";
	$sql.= " s.shikucyouson_no,";
	$sql.= " s.shikucyouson_nm,";
	$sql.= " s.rank_no";
	for ($i=0; $i<$ccnt; $i++) {
		$sql.= ", cad".$i.".com_count as cmc_".$i." ";
		$sql.= ", cad".$i.".shikucyouson_kingaku as csk_".$i." ";
	}
	$sql.= "FROM";
	$sql.= " m_shikucyouson s ";
	$sql.= "INNER JOIN";
	$sql.= " m_todoufuken t ";
	$sql.= "ON";
	$sql.= " s.todoufuken_no = t.todoufuken_no ";
	for ($i=0; $i<$ccnt; $i++) {
		$sql.= "left JOIN";
		$sql.= "   (";
		$sql.= "   SELECT";
		$sql.= "    ic.company_no,";
		$sql.= "    im.buken_shikucyouson_no AS shikucyouson_no,";
		$sql.= "    COUNT(ic.company_no) AS com_count,";
		$sql.= "    SUM(it.tesuryou) AS shikucyouson_kingaku";
		$sql.= "   FROM";
		$sql.= "    t_item im";
		$sql.= "   INNER JOIN";
		$sql.= "    t_item_company ic";
		$sql.= "   ON";
		$sql.= "    im.item_no = ic.item_no";
		$sql.= "   INNER JOIN";
		$sql.= "    t_tesuryou it";
		$sql.= "   ON";
		$sql.= "    ic.item_no = it.item_no AND";
		$sql.= "    ic.company_no = it.company_no";
		$sql.= "   WHERE";
		$sql.= "    im.mukou_flg = 0 AND";
		$sql.= "    ic.c_mukou_flg = 0 AND";//★★★ 抽出条件注意 ★★★ ★★★ 抽出条件注意 ★★★ ★★★ 抽出条件注意 ★★★
		$sql.= "    im.moushikomibi BETWEEN '2015-10-01 00:00:00' AND '2015-11-08 23:59:59' AND";
		$sql.= "    ic.company_no = ".$company_no_arr[$i];
		$sql.= "   GROUP BY";
		$sql.= "    ic.company_no,";
		$sql.= "    im.buken_shikucyouson_no";
		$sql.= "   ) cad".$i;

		$sql.= " ON ";
		$sql.= " cad".$i.".shikucyouson_no = s.shikucyouson_no ";
	}

	$sql.= "WHERE s.rank_no > 0 ";

	$sql.= "ORDER BY";
	$sql.= " t.todoufuken_no, s.shikucyouson_no";

	$rs = $gc->db->query($sql);

	$row_count = $gc->db->get_row_count();

	$i = 0;

	while ($rs->eof==false) {

		unset($line);

		$todoufuken_no = $rs->fields["todoufuken_no"];
		$todoufuken_nm = $rs->fields["todoufuken_nm"];
		$shikucyouson_no = $rs->fields["shikucyouson_no"];
		$shikucyouson_nm = $rs->fields["shikucyouson_nm"];
		$company_no = $rs->fields["company_no"];
		$company_nm = $rs->fields["company_nm"];
		$rank_no = $rs->fields["rank_no"];
//		$shikucyouson_kingaku = $rs->fields["shikucyouson_kingaku"];

		$cmc_kei = 0;
		$csk_kei = 0;

		$line[] = csv_item_edit($todoufuken_no);
		$line[] = csv_item_edit($todoufuken_nm);
		$line[] = csv_item_edit($shikucyouson_no);
		$line[] = csv_item_edit($shikucyouson_nm);
		$line[] = csv_item_edit($rank[$rank_no]);
		for ($i=0; $i<$ccnt; $i++) {
			if($rs->fields["csk_".$i] == ""){
				$line[] = csv_item_edit("0");
				$line[] = csv_item_edit("0");
			}else{
				$line[] = csv_item_edit($rs->fields["cmc_".$i]);
				$line[] = csv_item_edit($rs->fields["csk_".$i]);
				$cmc_kei += $rs->fields["cmc_".$i];
				$csk_kei += $rs->fields["csk_".$i];
			}
		}

		$line[] = csv_item_edit($cmc_kei);
		$line[] = csv_item_edit($csk_kei);

		$file_str.= implode(",", $line).$crlf;

		$rs->move_next();

		$i++;

	}

	$rs->free_result();

	$file_str = mb_convert_encoding($file_str, "sjis-win", C_ENCODING);

	$file_length = strlen($file_str);

	$file_name = "company_area_tesuryou";
	if($company_no_f > 0){$file_name .= "_".$company_no_f;}

	header("Content-Disposition: attachment; filename=".$file_name.".csv");
	header("Content-Length:".$file_length);
	header("Content-Type: application/octet-stream");

	echo $file_str;

	return true;

}
Esempio n. 9
0
function download_csv_file($gc) {

	$crlf = "\r\n";

	$rank = fdiv_set_rank_array();

	$file_str = "";

	unset($line);

	$line[] = csv_item_edit("都道府県コード");
	$line[] = csv_item_edit("都道府県名");
	$line[] = csv_item_edit("市区町村コード");
	$line[] = csv_item_edit("市区町村名");
	$line[] = csv_item_edit("市区町村名カナ");
	$line[] = csv_item_edit("ランク");

	$file_str.= implode(",", $line).$crlf;

	$sql = "SELECT SQL_CALC_FOUND_ROWS";
	$sql.= " t.todoufuken_no,";
	$sql.= " t.todoufuken_nm,";
	$sql.= " s.shikucyouson_no,";
	$sql.= " s.shikucyouson_nm,";
	$sql.= " s.shikucyouson_kn,";
	$sql.= " s.rank_no ";
	$sql.= "FROM";
	$sql.= " m_todoufuken t ";
	$sql.= "INNER JOIN";
	$sql.= " m_shikucyouson s ";
	$sql.= "ON";
	$sql.= " s.todoufuken_no = t.todoufuken_no ";
	$sql.= "ORDER BY";
	$sql.= " t.todoufuken_no, s.shikucyouson_no";

	$rs = $gc->db->query($sql);

	$row_count = $gc->db->get_row_count();

	$i = 0;

	while ($rs->eof==false) {

		unset($line);

		$todoufuken_no = $rs->fields["todoufuken_no"];
		$todoufuken_nm = $rs->fields["todoufuken_nm"];
		$shikucyouson_no = $rs->fields["shikucyouson_no"];
		$shikucyouson_nm = $rs->fields["shikucyouson_nm"];
		$shikucyouson_kn = $rs->fields["shikucyouson_kn"];
		$rank_no = $rs->fields["rank_no"];

		$line[] = csv_item_edit($todoufuken_no);
		$line[] = csv_item_edit($todoufuken_nm);
		$line[] = csv_item_edit($shikucyouson_no);
		$line[] = csv_item_edit($shikucyouson_nm);
		$line[] = csv_item_edit($shikucyouson_kn);
		$line[] = csv_item_edit($rank[$rank_no]);

		$file_str.= implode(",", $line).$crlf;

		$rs->move_next();

		$i++;

	}

	$rs->free_result();

	$file_str = mb_convert_encoding($file_str, "sjis-win", C_ENCODING);

	$file_length = strlen($file_str);

	header("Content-Disposition: attachment; filename=area.csv");
	header("Content-Length:".$file_length);
	header("Content-Type: application/octet-stream");

	echo $file_str;

	return true;

}