添加的事件不会"坚持"到完整日历

时间:2016-03-05 02:32:06

标签: javascript php html fullcalendar

所以我一直在尝试为教会系统制作日历,他们可以使用日历添加预订,而且我很难制作我添加的数据"坚持&#34 #34;到日历本身。

非常感谢任何帮助。

<?php
include ('config1.php');


if(isset($_SESSION['username'])) {
$message = "Login First!";
echo "<script type='text/javascript'>alert('$message');</script>";
}
?>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>San Isidro Labrador Parish </title>


    <link href="css/bootstrap.min.css" rel="stylesheet">

    <link href="fonts/css/font-awesome.min.css" rel="stylesheet">
    <link href="css/animate.min.css" rel="stylesheet">

    <!-- Custom styling plus plugins -->
    <link href="css/custom.css" rel="stylesheet">
    <link href="css/icheck/flat/green.css" rel="stylesheet">

    <link href="css/calendar/fullcalendar.css" rel="stylesheet">
    <link href="css/calendar/fullcalendar.print.css" rel="stylesheet" media="print">

    <script src="js/jquery.min.js"></script>

    <!--[if lt IE 9]>
        <script src="../assets/js/ie8-responsive-file-warning.js"></script>
        <![endif]-->

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
          <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <![endif]-->

</head>


<body class="nav-md">

    <div class="container body">


        <div class="main_container">




            <!-- page content -->
            <div class="right_col" role="main">
                <div class="">

                    <div class="page-title">
                        <div class="title_left">
                            <h3>
                                Calender
                                <small>
                                    Click to add/edit events
                                </small>
                            </h3>
                        </div>

                        <div class="title_right">
                            <div class="col-md-5 col-sm-5 col-xs-12 form-group pull-right top_search">
                                <div class="input-group">
                                    <input type="text" class="form-control" placeholder="Search for...">
                                    <span class="input-group-btn">
                                        <button class="btn btn-default" type="button">Go!</button>
                                    </span>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="clearfix"></div>

                    <div class="row">
                        <div class="col-md-12">
                            <div class="x_panel">
                                <div class="x_title">
                                    <h2>Calender Events <small>Sessions</small></h2>
                                    <ul class="nav navbar-right panel_toolbox">
                                        <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                        </li>
                                        <li class="dropdown">
                                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                                            <ul class="dropdown-menu" role="menu">
                                                <li><a href="#">Settings 1</a>
                                                </li>
                                                <li><a href="#">Settings 2</a>
                                                </li>
                                            </ul>
                                        </li>
                                        <li><a class="close-link"><i class="fa fa-close"></i></a>
                                        </li>
                                    </ul>
                                    <div class="clearfix"></div>
                                </div>
                                <div class="x_content">

                                    <div id='calendar'></div>

                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- footer content -->
                <footer>
                </footer>
                <!-- /footer content -->

            </div>


            <!-- Start Calender modal -->
            <div id="CalenderModalNew" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">

                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                            <h4 class="modal-title" id="myModalLabel">New Calender Entry</h4>
                        </div>
                        <div class="modal-body">
                            <div id="testmodal" style="padding: 5px 20px;">
                                <form id="antoform" class="form-horizontal calender" role="form">
                                   <div class="form-group">
                                        <label class="col-sm-3 control-label">Venue</label>
                                        <div class="col-sm-9">     
                                        </div>
                                        <select name="Venue_idVenue" id ="Venue_idVenue" required = "required">
                                          <option value="1" name ="Garden" style ="height:55px;">Garden</option>
                                          <option value="2"  name ="Chapel" style ="height:55px;">Chapel</option>
                                          <option value="3"  name ="Church" style ="height:55px;">Church</option>
                                          <option value="4"  name ="New Bulding" style ="height:55px;">New Building</option>
                                          <option value="5"  name ="Seminar Hall" style ="height:55px;">Seminar Hall</option>
                                        </select>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">Sacrament</label>
                                        <div class="col-sm-9">     
                                        </div>
                                        <select name="Sacrament_idSacrament" id ="Sacrament_idSacrament" class = "form_control">
                                          <option value="1"  name ="Baptsim" style ="height:55px;">Baptism</option>
                                          <option value="2"  name ="Confirmation" style ="height:55px;">Confirmation</option>
                                          <option value="3"  name ="Marriage" style ="height:55px;">Marriage</option>
                                        </select>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">Reservation Date</label>
                                        <div class="col-sm-9">
                                            <input id="reservation_date" class="datepicker form-control col-md-7 col-xs-12" name="reservation_date" placeholder="Reservation Date" required="required" type="date"/>
                                           <!-- <textarea class="form-control" style="height:55px;" id="reservation_date" name="reservation_date"></textarea> -->
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">Reservation Time</label>
                                        <div class="col-sm-9">
                                        <input id="reservation_time" class="datepicker form-control col-md-7 col-xs-12" name="reservation_time" placeholder="Reservation Time" required="required" type="time"/>
                                            <!--<textarea class="form-control" style="height:55px;" id="reservation_time" name="reservation_time"></textarea> -->
                                        </div>
                                    </div>

                                </form>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default antoclose" data-dismiss="modal">Close</button>
                            <input type="submit" name="submit" class="btn btn-primary antosubmit"value="Save changes" onClick="validinfo()"></input>
                        </div>

                    </div>
                </div>
            </div>
            <div id="CalenderModalEdit" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">

                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                            <h4 class="modal-title" id="myModalLabel2">Edit Calender Entry</h4>
                        </div>
                        <div class="modal-body">
                            <div id="testmodal" style="padding: 5px 20px;">
                                <form id="antoform" class="form-horizontal calender" role="form">
                                <input type = "hidden" name = "submitted" value = "true"/>
                                   <div class="form-group">
                                        <label class="col-sm-3 control-label">Venue</label>
                                        <div class="col-sm-9">     
                                        </div>
                                        <select name="idVenue2" id ="idVenue2" required = "required">
                                          <option value="1" name ="Garden" style ="height:55px;">Garden</option>
                                          <option value="2" name ="Chapel" style ="height:55px;">Chapel</option>
                                          <option value="3" name ="Church" style ="height:55px;">Church</option>
                                          <option value="4" name ="New Building" style ="height:55px;">New Building</option>
                                          <option value="5" name ="Seminar Hall" style ="height:55px;">Seminar Hall</option>
                                        </select>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">Sacrament</label>
                                        <div class="col-sm-9">     
                                        </div>
                                        <select name="Sacrament_idSacrament2" id ="Sacrament_idSacrament2" class = "form_control">
                                          <option value="1" name ="Baptism" style ="height:55px;">Baptism</option>
                                          <option value="2" name ="Confirmation" style ="height:55px;">Confirmation</option>
                                          <option value="3" name ="Marriage" style ="height:55px;">Marriage</option>
                                        </select>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">Reservation Date</label>
                                        <div class="col-sm-9">
                                            <input id="reservation_date2" class="datepicker form-control col-md-7 col-xs-12" name="reservation_date2" placeholder="Reservation Date" required="required" type="date"/>
                                           <!-- <textarea class="form-control" style="height:55px;" id="reservation_date" name="reservation_date"></textarea> -->
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">Reservation Time</label>
                                        <div class="col-sm-9">
                                        <input id="reservation_time2" class="datepicker form-control col-md-7 col-xs-12" name="reservation_time2" placeholder="Reservation Time" required="required" type="time"/>
                                            <!--<textarea class="form-control" style="height:55px;" id="reservation_time" name="reservation_time"></textarea> -->
                                        </div>
                                    </div>

                                </form>
                            </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default antoclose2" data-dismiss="modal">Close</button>
                            <button type="submit" class="btn btn-primary antosubmit2">Save changes</button>
                        </div>
                    </div>
                </div>
            </div>

            <div id="fc_create" data-toggle="modal" data-target="#CalenderModalNew"></div>
            <div id="fc_edit" data-toggle="modal" data-target="#CalenderModalEdit"></div>

            <!-- End Calender modal -->
            <!-- /page content -->
        </div>

    </div>

    <div id="custom_notifications" class="custom-notifications dsp_none">
        <ul class="list-unstyled notifications clearfix" data-tabbed_notifications="notif-group">
        </ul>
        <div class="clearfix"></div>
        <div id="notif-group" class="tabbed_notifications"></div>
    </div>

    <script src="js/bootstrap.min.js"></script>

    <script src="js/nprogress.js"></script>
    <!-- chart js -->
    <script src="js/chartjs/chart.min.js"></script>
    <!-- bootstrap progress js -->
    <script src="js/progressbar/bootstrap-progressbar.min.js"></script>
    <script src="js/nicescroll/jquery.nicescroll.min.js"></script>
    <!-- icheck -->
    <script src="js/icheck/icheck.min.js"></script>

    <script src="js/custom.js"></script>

    <script src="js/moment.min.js"></script>
    <script src="js/calendar/fullcalendar.min.js"></script>

    <script>
        $(window).load(function () {

            var date = new Date();
            var d = date.getDate('Y-m-d');
            var m = date.getMonth();
            var y = date.getFullYear();
            var started;
            var categoryClass;

            var calendar = $('#calendar').fullCalendar({
                editable: true,
                header: {
                    left: 'prev,next, today',
                    center: 'title',
                    right: 'month,agendaWeek,agendaDay'
                },
                defaultDate: '<?php echo date('Y-M-d'); ?>',
                editable: true,
                timeFormat: 'h:mmA',
                selectable: true,
                selectHelper: true,
                eventLimit: true,


                select: function (start, end, allDay) {
                    $('#fc_create').click();

                    started = start;
                    ended = end

                    $(".antosubmit").on("click", function () {
                        var venue = $("#title").val();
                        if (end) {
                            ended = end
                        }
                        categoryClass = $("#event_type").val();

                        if (venue) {
                            calendar.fullCalendar('renderEvent', {
                                    title: title,
                                    start: started,
                                    end: end,
                                    allDay: allDay
                                },
                                true // make the event "stick"
                            );
                        }
                        $('#title').val('');
                        calendar.fullCalendar('unselect');

                        $('.antoclose').click();

                        return false;
                    });
                },
                eventClick: function (calEvent, jsEvent, view) {
                    //alert(calEvent.title, jsEvent, view);

                    $('#fc_edit').click();
                    $('#title2').val(calEvent.venue);
                    categoryClass = $("#event_type").val();

                    $(".antosubmit2").on("click", function () {
                        calEvent.title = $("#title2").val();

                        calendar.fullCalendar('updateEvent', calEvent);
                        $('.antoclose2').click();
                    });
                    calendar.fullCalendar('unselect');
                },
                editable: true,

                events: [

                <?php
                include('config1.php');
                $select = mysqli_query($conn, "select venue.venue_type, reservation.reservation_date, reservation.reservation_time from venue, reservation where venue.idVenue = reservation.idReservation;");
                $number = mysqli_num_rows($select);
                $row = mysqli_fetch_assoc($select);
                $venue_type = $row['venue_type'];
                $reservation_date = $row['reservation_date'];
                $reservation_time = $row['reservation_time'];
                $i = 1;

                while($row = mysqli_fetch_array($select)) 
                {
                    if($i <= $number) {
                        ?>
                        {

                            title: '<?php echo $row['venue_type']; ?>',
                            start: '<?php echo $row['reservation_date'].'T'.$row['reservation_time']; ?>'


                        },
                        <?php
                    }
                    else 
                    {
                    ?>

                        {
                                title: '<?php echo $row['venue_type']; ?>',
                                start: '<?php echo $row['reservation_date'].'T'.$row['reservation_time']; ?>'
                        }
                    <?php
                        }
                $i = $i + 1;
                        }
                ?>

                <?php
                    if(!empty($_POST['submit']))
                        {
                        global $conn;
                        $reservation_date1 = $_POST["reservation_date"];
                        $reservation_time1 = $_POST["reservation_time"];
                        $Seminar_sched_idSeminar_sched1 = $_POST['Seminar_sched_idSeminar_sched'];

                        //$insertRes = mysqli_query($conn, "INSERT INTO reservation (Venue_idVenue, Sacrament_idSacrament, reservation_date, reservation_time) VALUES ('".$_POST[venue_id]."', '".$_POST[sacrament_id]."', '$reservation_date1','$reservation_time1')");
                        $insertRes = mysqli_query($conn, "INSERT INTO reservation (Venue_idVenue, Sacrament_idSacrament, reservation_date, reservation_time) VALUES ('".$_POST[venue_id]."', '".$_POST[sacrament_id]."', '$reservation_date1','$reservation_time1')");
                        echo'<script language="java script">';
                        echo'alert("Data Saved!")';
                        echo'</script>';

                        if($insertRes) 
                        {
                            printf("Error: %s\n", mysqli_error(conn));
                            exit();
                        }

                    }

                        mysqli_close($conn);

 ?>



                ]
                });
            });
        </script>
    </body>

 </html>

0 个答案:

没有答案