トップへ戻る 採用情報 お問い合わせ よくある質問
マックのこだわり ごあいさつ 製品紹介 工場紹介 大豆の力 とっておきレシピ


> Name: php_common.inc Version: 1.0.0 Function: 共通関数 Author: Y.Takahashi Date of creation: 2006/01 History of modification: Copyright (C)2006 [] All Rights Reserverd. ******************************************************************************/ /*---------------------------------------------------   処理結果(エラー)表示後、画面切り替え ----------------------------------------------------*/ function phpcom_ErrmsgJmp($back_url,$outmessage,$php_errormsg="",$hidden_params=array()) { print << マック食品


!! WEBシステム エラーメッセージ !!


$outmessage
$php_errormsg




EOF; if ( $back_url != "" ){ print ("
\n"); foreach ( $hidden_params as $param => $value ) { print ("\n"); } print ("\n"); print ("
\n"); } print <<
EOF; } /*---------------------------------------------------   処理結果表示後、画面切り替え ----------------------------------------------------*/ function phpcom_MessageJmp($back_url,$outmessage,$php_errormsg="",$hidden_params=array()) { print << マック食品


!! WEBシステム メッセージ !!


$outmessage
$php_errormsg




EOF; if ( $back_url != "" ){ print ("
\n"); foreach ( $hidden_params as $param => $value ) { print ("\n"); } print ("\n"); print ("
\n"); } print <<
EOF; } /*---------------------------------------------------   日付取得関数1   (現在の日付の指定日分前後の日付を取得) ----------------------------------------------------*/ function phpcom_GetDate1 ( $date, $sabun ) { $buf = split ( "-",$date ); $newdate = date ( "Y-m-d", mktime(0,0,0,$buf[1],$buf[2]+$sabun,$buf[0]) ); return ( $newdate ); } /*---------------------------------------------------   日付取得関数2   (現在の日付が含まれる週の日〜土の年月日を取得) ----------------------------------------------------*/ function phpcom_GetDate2 ( $date ) { $buf = split ( "-",$date ); $youbi = date ( "w", mktime(0,0,0,$buf[1],$buf[2],$buf[0]) ); $cnt = 0; while ( $cnt <= $youbi ) { $sabun = $youbi - $cnt; $outdat[$cnt] = date ( "Y-m-d", mktime(0,0,0,$buf[1],$buf[2]-$sabun,$buf[0]) ); $cnt++; } while ( $cnt < 7 ) { $sabun = $cnt - $youbi; $outdat[$cnt] = date ( "Y-m-d", mktime(0,0,0,$buf[1],$buf[2]+$sabun,$buf[0]) ); $cnt++; } return ( $outdat ); } /*---------------------------------------------------   日付取得関数3   (現在の日付の曜日と平日/休日種別、その月の日数を取得) ----------------------------------------------------*/ function phpcom_GetDate3 ( $date ) { $youbi = array ( "日","月","火","水","木","金","土" ); $kyuDays["01-01"] = "元旦"; $kyuDays["02-11"] = "建国記念日"; $kyuDays["04-29"] = "みどりの日"; $kyuDays["05-03"] = "憲法記念日"; $kyuDays["05-04"] = "国民の休日"; $kyuDays["05-05"] = "こどもの日"; $kyuDays["11-03"] = "文化の日"; $kyuDays["11-23"] = "勤労感謝の日"; $kyuDays["12-23"] = "天皇誕生日"; $datebuf = split ( "-",$date ); $buf = "03-".floor(20.8431 + 0.242194 * ($datebuf[0] - 1980) - floor(($datebuf[0] - 1980)/4)); // 春分の日を求める $kyuDays["$buf"] = "春分の日"; $buf = "09-".floor(23.2488 + 0.242194 * ($datebuf[0] - 1980) - floor(($datebuf[0] - 1980)/4)); // 秋分の日を求める $kyuDays["$buf"] = "秋分の日"; // 2000年以降の成人の日/体育の日(第2月曜日)の計算 if ($datebuf[0] >= 2000 && ( $datebuf[1] == "01" || $datebuf[1] == "10")) { $startDay = date ( "w", mktime(0,0,0,$datebuf[1],1,$datebuf[0]) ); if ($startDay <= 1) $happyMon = 7 + (2 - $startDay); else $happyMon = 14 - ($startDay - 2); if ($happyMon < 10) $happyMon = "0"."$happyMon"; $buf = "01-" . $happyMon; $kyuDays["$buf"] = "成人の日"; $buf = "10-" . $happyMon; $kyuDays["$buf"] = "体育の日"; } else { $kyuDays["01-15"] = "成人の日"; $kyuDays["10-10"] = "体育の日"; } // 2003年以降の海の日/敬老の日(第3月曜日)の計算 if ($datebuf[0] >= 2003 && ( $datebuf[1] == "07" || $datebuf[1] == "09")) { $startDay = date ( "w", mktime(0,0,0,$datebuf[1],1,$datebuf[0]) ); if ($startDay <= 1) $happyMon = 14 + (2 - $startDay); else $happyMon = 21 - ($startDay - 2); $buf = "07-" . $happyMon; $kyuDays["$buf"] = "海の日"; $buf = "09-" . $happyMon; $kyuDays["$buf"] = "敬老の日"; } else { $kyuDays["07-20"] = "海の日"; $kyuDays["09-15"] = "敬老の日"; } $buf2 = split ( "-",$date ); $youbicd = date ( "w", mktime(0,0,0,$buf2[1],$buf2[2],$buf2[0]) ); $nisuu = date ( "t", mktime(0,0,0,$buf2[1],$buf2[2],$buf2[0]) ); $nowday = date ( "m-d", mktime(0,0,0,$buf2[1],$buf2[2],$buf2[0]) ); $yesterday = date ( "m-d", mktime(0,0,0,$buf2[1],$buf2[2]-1,$buf2[0]) ); $yesterday_yobi = date ( "w", mktime(0,0,0,$buf2[1],$buf2[2]-1,$buf2[0]) ); if ( $youbicd == 0 || $kyuDays["$nowday"] != "" || ($kyuDays["$yesterday"] != "" && $yesterday_yobi == 0) ) $holflg = 1; else $holflg = 0; return array ( $youbicd, $youbi[$youbicd],$holflg,$nisuu ); } /*---------------------------------------------------   日付取得関数4   (指定した期間内の指定曜日の年月日を得る) ----------------------------------------------------*/ function phpcom_GetDate4 ( $sdate, $edate, $youbicd ) { $flg = 0; $cnt = 0; $cnt2 = 0; while ( $flg==0 ) { $datebuf = phpcom_GetDate1 ( $sdate, $cnt2 ); list($youbicdbuf,$yobiname,$holflg,$nisuu) = phpcom_GetDate3($datebuf); if ( $youbicd == $youbicdbuf ) { $date[$cnt] = $datebuf; $cnt++; } $cnt2++; if ( $datebuf == $edate ) $flg = 1; } return array ( $cnt, $date ); } /*---------------------------------------------------   日付取得関数5   (指定した期間内の指定日の年月日を得る) ----------------------------------------------------*/ function phpcom_GetDate5 ( $sdate, $edate, $date ) { $flg = 0; $cnt = 0; $cnt2 = 0; $sdatebuf = split ( "-", $sdate ); $edatebuf = split ( "-", $edate ); $edate = date ( "Y-m", mktime(0,0,0,$edatebuf[1]+$cnt,1,$edatebuf[0]) ); while ( $flg==0 ) { $datebuf = date ( "Y-m", mktime(0,0,0,$sdatebuf[1]+$cnt2,1,$sdatebuf[0]) ); $datebuf2 = split ( "-", $datebuf ); if ( checkdate($datebuf2[1],$date,$datebuf2[0]) ) { $newdate[$cnt] = $datebuf."-".$date; $cnt++; } $cnt2++; if ( $datebuf == $edate ) $flg = 1; } return array ( $cnt, $newdate ); } /*---------------------------------------------------   日付取得関数6   (指定年月日の年度を得る) ----------------------------------------------------*/ function phpcom_GetDate6 ( $date,$stmonth ) { $datebuf = split ( "-", $date ); $edmonth = $stmonth + 11; $year = $datebuf[0]; if ( $edmonth > 12 ) { if ( 1 <= (int)$datebuf[1] && (int)$datebuf[1] <= $edmonth-12 ) $year = $datebuf[0] - 1; } return ($year); } /*---------------------------------------------------   日付取得関数7   (指定年月日が本日以前かどうかをチェックする) ----------------------------------------------------*/ function phpcom_GetDate7 ( $chkdate ) { $now_date = date(Y)."-".date(m)."-".date(d); $chkdate_buf = explode("-",$chkdate); $chk1 = date("U",mktime(0,0,0,date(m),date(d),date(Y))); $chk2 = date("U",mktime(0,0,0,$chkdate_buf[1],$chkdate_buf[2],$chkdate_buf[0])); if ( $chk1 > $chk2 ) { return(1); } else { return(0); } } /*---------------------------------------------------   日付取得関数8   (指定した期間内の指定日の年月日を得る) ----------------------------------------------------*/ function phpcom_GetDate8 ( $sdate, $edate ) { $flg = 0; $cnt = 0; $cnt2 = 0; $sdatebuf = split ( "-", $sdate ); $edatebuf = split ( "-", $edate ); if ( $sdatebuf[0].$sdatebuf[1].$sdatebuf[2] > $edatebuf[0].$edatebuf[1].$edatebuf[2] ) { return array (-1,NULL); } while ( $flg == 0 ) { $datebuf = date ( "Y-m-d", mktime(0,0,0,$sdatebuf[1],$sdatebuf[2]+$cnt,$sdatebuf[0]) ); $datebuf2 = split ( "-", $datebuf ); if ( $datebuf != $edate ) { $datelist[$cnt2] = $datebuf; $cnt++; $cnt2++; } else { $datelist[$cnt2] = $datebuf; $cnt2++; $flg = 1; } } return array ( $cnt2, $datelist ); } /*---------------------------------------------------   日付取得関数9   (日本語形式の年月日の文字列を生成する ----------------------------------------------------*/ function phpcom_GetDate9 ( $date ) { $buf = explode("-",$date); list($youbicd, $youbi_name,$holflg,$nisuu) = phpcom_GetDate3($date); return ( "{$buf[0]}年". (int)$buf[1] ."月" . (int)$buf[2] . "日({$youbi_name})" ); } /*---------------------------------------------------   日付取得関数10   (日本語形式の日時の文字列を生成する ----------------------------------------------------*/ function phpcom_GetDate10 ( $date ) { $buf = explode(" ",$date); $buf1 = explode("-",$buf[0]); $buf2 = explode(":",$buf[1]); list($youbicd, $youbi_name,$holflg,$nisuu) = phpcom_GetDate3($buf[0]); return ( "{$buf1[0]}年". (int)$buf1[1] ."月" . (int)$buf1[2] . "日({$youbi_name}) " . (int)$buf2[0] . "時" . (int)$buf2[1] . "分" ); } /*---------------------------------------------------   日付取得関数11   (日本語形式の日にちの文字列を生成する ----------------------------------------------------*/ function phpcom_GetDate11 ( $date ) { $buf1 = explode("-",$date); list($youbicd, $youbi_name,$holflg,$nisuu) = phpcom_GetDate3($date); return ( "{$buf1[0]}年". $buf1[1] ."月" . $buf1[2] . "日({$youbi_name})" ); } /*---------------------------------------------------   日付選択のHTMLを表示する ----------------------------------------------------*/ function phpcom_DspDateSelList ( $sufix, $mode, $curdate, $s_year,$e_year ) { $datebuf = split ( "-", $curdate ); $yeartxt = $sufix."_year"; $monthtxt = $sufix."_month"; $daytxt = $sufix."_day"; if ( $mode == 1 || $mode == 3 ) $onchtext = "onchange=\"refNum($yeartxt,$monthtxt,$daytxt)\""; else $onchtext = ""; print ( "\n" ); if ( $mode == 1 || $mode == 3 ) { print ( "\n" ); } return; } /*---------------------------------------------------   時刻選択のHTMLを表示する ----------------------------------------------------*/ function phpcom_DspTimeSelList ( $time,$id,$mode,$kizami,$s_hour=0,$e_hour=23 ) { print ( "時\n" ); print ( "分\n" ); } /*--------------------------------------------------- 一覧表ページ換え制御 ----------------------------------------------------*/ function phpcom_page_change ( $cur_num,$total,$getnum,$stpos,$edpos,$page_num ) { global $ap_root; if ( $cur_num == 0 ) { print <<
 
EOF; return; } print << EOF; if ( $total <= $getnum ) { print ( "
\n" ); } else { $endpos = $stpos + $cur_num -1; print ( "\n" ); if ( $getnum < $stpos ) { $stpos_new = $stpos - $getnum; print <<前へ   EOF; } $page_no = (int)($stpos / $getnum) + 1; $start_page = $page_no - 9; if ( $start_page < 1 ) $start_page = 1; $end_page = $start_page + 9; if ( $end_page > $page_num ) $end_page = $page_num; print ( "Page: " ); for ( $i=$start_page;$i<=$end_page;$i++ ) { $stpos_new = ($i-1) * $getnum + 1; if ( $stpos_new == $stpos ) print ( "[$i] \n" ); else print ( "$i \n" ); } if ( $endpos < $total ) { $stpos_new = $stpos + $cur_num; print <<次へ EOF; } } print << EOF; } /*--------------------------------------------------- 管理者名表示 ----------------------------------------------------*/ function DispHelloMsg () { $now_time = date(H); if ( 0 <= $now_time && $now_time < 12 ) $hello = "おはようございます"; elseif ( 12 <= $now_time && $now_time <= 18 ) $hello = "こんにちわ"; else $hello = "こんばんわ"; $message = "{$hello}  {$_SESSION['_name']} さん  "; return ( $message ); } /*---------------------------------------------------   日付選択のHTMLを表示する(年月版) ----------------------------------------------------*/ function phpcom_DspDateSelList2 ( $objname, $curdate, $display_kbn="0" ) { global $sys_team_kbn; print <<