# HG changeset patch # User yoneda # Date 1248359743 -32400 # Node ID f3bf1be1a51b016cfbd052f4c05c063579b9472d # Parent 95629ba1f043e477a745a17a6c4708c8b8ce90f9 Change: using ajax in custom reservation method diff -r 95629ba1f043 -r f3bf1be1a51b customReservation.php --- a/customReservation.php Fri Jul 17 22:40:41 2009 +0900 +++ b/customReservation.php Thu Jul 23 23:35:43 2009 +0900 @@ -7,16 +7,36 @@ $program_id = 0; if( isset( $_POST['program_id'] ) ) $program_id = $_POST['program_id']; + +if(!( + isset($_POST['shour']) && + isset($_POST['smin']) && + isset($_POST['smonth']) && + isset($_POST['sday']) && + isset($_POST['syear']) && + isset($_POST['ehour']) && + isset($_POST['emin']) && + isset($_POST['emonth']) && + isset($_POST['eday']) && + isset($_POST['eyear']) && + isset($_POST['channel_id']) && + isset($_POST['title']) && + isset($_POST['description']) && + isset($_POST['category_id']) && + isset($_POST['record_mode'])) +) { + exit("Error:予約に必要な値がセットされていません"); +} + + $start_time = @mktime( $_POST['shour'], $_POST['smin'], 0, $_POST['smonth'], $_POST['sday'], $_POST['syear'] ); if( ($start_time < 0) || ($start_time === false) ) { - if( $program_id ) jdialog( "開始時間が不正です" , "reservation.php?program_id=".$program_id ); - else jdialog("開始時間が不正です" ); + exit("Error:開始時間が不正です" ); } $end_time = @mktime( $_POST['ehour'], $_POST['emin'], 0, $_POST['emonth'], $_POST['eday'], $_POST['eyear'] ); if( ($end_time < 0) || ($end_time === false) ) { - if( $program_id ) jdialog( "終了時間が不正です" , "reservation.php?program_id=".$program_id ); - else jdialog("終了時間が不正です" ); + exit("Error:終了時間が不正です" ); } $channel_id = $_POST['channel_id']; @@ -41,10 +61,7 @@ ); } catch( Exception $e ) { - if( $progarm_id ) jdialog( $e->getMessage(), "reservation.php?program_id=".$program_id ); - else jdialog( $e->getMessage() ); + exit( "Error:".$e->getMessage() ); } - -jdialog("予約しました:job番号".$rval); - +exit( "".$program_id ); ?> \ No newline at end of file diff -r 95629ba1f043 -r f3bf1be1a51b reservationform.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/reservationform.php Thu Jul 23 23:35:43 2009 +0900 @@ -0,0 +1,57 @@ +starttime, "%4d-%2d-%2d %2d:%2d:%2d", $syear, $smonth, $sday, $shour, $smin, $ssec ); + sscanf( $prec->endtime, "%4d-%2d-%2d %2d:%2d:%2d", $eyear, $emonth, $eday, $ehour, $emin, $esec ); + + $crecs = DBRecord::createRecords( TBL_PREFIX.CATEGORY_TBL ); + $cats = array(); + foreach( $crecs as $crec ) { + $cat = array(); + $cat['id'] = $crec->id; + $cat['name'] = $crec->name_jp; + $cat['selected'] = $prec->category_id == $cat['id'] ? "selected" : ""; + + array_push( $cats , $cat ); + } + + $smarty = new Smarty(); + + $smarty->assign( "syear", $syear ); + $smarty->assign( "smonth", $smonth ); + $smarty->assign( "sday", $sday ); + $smarty->assign( "shour", $shour ); + $smarty->assign( "smin" ,$smin ); + $smarty->assign( "eyear", $eyear ); + $smarty->assign( "emonth", $emonth ); + $smarty->assign( "eday", $eday ); + $smarty->assign( "ehour", $ehour ); + $smarty->assign( "emin" ,$emin ); + + $smarty->assign( "type", $prec->type ); + $smarty->assign( "channel", $prec->channel ); + $smarty->assign( "channel_id", $prec->channel_id ); + $smarty->assign( "record_mode" , $RECORD_MODE ); + + $smarty->assign( "title", $prec->title ); + $smarty->assign( "description", $prec->description ); + + $smarty->assign( "cats" , $cats ); + + $smarty->assign( "program_id", $prec->id ); + + $smarty->display("reservationform.html"); +} +catch( exception $e ) { + exit( "Error:". $e->getMessage() ); +} +?> \ No newline at end of file diff -r 95629ba1f043 -r f3bf1be1a51b templates/index.html --- a/templates/index.html Fri Jul 17 22:40:41 2009 +0900 +++ b/templates/index.html Thu Jul 23 23:35:43 2009 +0900 @@ -53,7 +53,7 @@ if ($(this).hasClass('prg_rec')) { str += '
予約キャンセル
'; } else { - str += '
簡易予約 予約カスタマイズ
'; + str += '
簡易予約 予約カスタマイズ
'; } $('#floatBox4Dialog').html(str); $('#floatBox4Dialog').dialog('open', 'center'); @@ -100,6 +100,70 @@ $('#floatBox4Dialog').dialog('close'); } }); + }, + customform:function(id) { + $('#floatBox4Dialog').dialog('close'); + $.get('reservationform.php', { program_id: id }, function(data) { + if(data.match(/^error/i)){ + alert(data); + } + else { + var str = data; + str += '
予約する
'; + $('#floatBox4Dialog').html(str); + $('#floatBox4Dialog').dialog('open', 'center'); + } + }); + }, + customrec:function() { + var id_syear = $('#id_syear').val(); + var id_smonth = $('#id_smonth').val(); + var id_sday = $('#id_sday').val(); + var id_shour = $('#id_shour').val(); + var id_smin = $('#id_smin').val(); + var id_eyear = $('#id_eyear').val(); + var id_emonth = $('#id_emonth').val(); + var id_eday = $('#id_eday').val(); + var id_ehour = $('#id_ehour').val(); + var id_emin = $('#id_emin').val(); + var id_channel_id = $('#id_channel_id').val(); + var id_record_mode = $('#id_record_mode').val(); + var id_title = $('#id_title').val(); + var id_description = $('#id_description').val(); + var id_category_id = $('#id_category_id ').val(); + var id_program_id = $('#id_program_id').val(); + var with_program_id = $('#id_program_id').attr('checked'); + + if( ! with_program_id ) id_program_id = 0; + + $.post('customReservation.php', { syear: id_syear, + smonth: id_smonth, + sday: id_sday, + shour: id_shour, + smin: id_smin, + eyear: id_eyear, + emonth: id_emonth, + eday: id_eday, + ehour: id_ehour, + emin: id_emin, + channel_id: id_channel_id, + record_mode: id_record_mode, + title: id_title, + description: id_description, + category_id: id_category_id, + program_id: id_program_id }, function(data) { + if(data.match(/^error/i)){ + $('#floatBox4Dialog').dialog('close'); + alert(data); + } + else { + var id = parseInt(data); + if( id ) { + $('#prgID_' + id).addClass('prg_rec'); + } + $('#floatBox4Dialog').dialog('close'); + } + }); } } var CTG = { @@ -223,7 +287,7 @@ tvtimes_scroll(); prg_hover(); var DG = $('#floatBox4Dialog'); - DG.dialog({title:'録画予約',width:500}); + DG.dialog({title:'録画予約',width:600}); DG.dialog('close'); nowBar.INI(); CTG.INI(); diff -r 95629ba1f043 -r f3bf1be1a51b templates/programTable.html --- a/templates/programTable.html Fri Jul 17 22:40:41 2009 +0900 +++ b/templates/programTable.html Thu Jul 23 23:35:43 2009 +0900 @@ -9,6 +9,9 @@ {literal} + + +