/****************************************************** ' System :Eco-footprint 会員ページ ' Content:ガンバリスト '******************************************************/ $top = '.'; $inc = "$top/../inc"; include("$inc/common.php"); include("$inc/database.php"); $inc = "$top/inc"; include("$inc/mypage.php"); include("$inc/sim_db.php"); // 会員番号取得 $seq_no = $_SESSION['ss_seq_no']; // 今月の年月取得 $ym_now = date('Ym'); // 年月の指定が無ければ今月とする if (!$ym) $ym = $ym_now; // 年月に分解 $year = substr($ym, 0, 4); $month = substr($ym, -2); // 前月取得 $sql = "SELECT count(*) FROM t_ganbalist WHERE gn_seq_no=$seq_no AND gn_ym<'$ym'"; if (db_fetch1($sql)) $ym_back = date('Ym', mktime(0, 0, 0, $month - 1, 1, $year)); // 次月取得 if ($ym < $ym_now) $ym_next = date('Ym', mktime(0, 0, 0, $month + 1, 1, $year)); // 指定月のガンバリストを取得 $sql = "SELECT gn_co2,gn_ym,gn_ganbalist_id,gn_eng_bunrui,gn_cost,COALESCE(gn_advice,gm_advice) AS advice,EXISTS (SELECT * FROM t_master_mark WHERE mm_mb_seq_no=gn_seq_no AND mm_ganbalist_id=gn_ganbalist_id) AS master_mark" . " FROM t_ganbalist JOIN m_ganbalist ON gm_ganbalist_id=gn_ganbalist_id AND gm_eng_bunrui=gn_eng_bunrui" . " WHERE gn_seq_no=$seq_no AND gn_ym='$ym'" . " ORDER BY gn_eng_bunrui,gn_ganbalist_id"; $result = db_exec($sql); $nrow = pg_numrows($result); if ($nrow == 0) { // 指定月のデータが無い場合 if ($ym < date('Ym')) { // 過去の場合 redirect("decision_nothing.php?ym=$ym"); } else { // 現在または未来の場合 redirect("decision_create.php?ym=$ym"); } } ?>