/var/www/hkosl.com/imusiccircle/webadmin/calendar_form.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?php
    $page_settings 
= array(
        
'formid'     => 'Calendar'// for permission
        
'section'    => 'Master'// parent/page title
        
'subsection' => 'Calendar'// page title
        
'domain'     => 'calendar'// table/model name
        
'access'     => 'GNr'// for permission
    
);
    require_once 
"check_login.php";

    if(empty(
$_REQUEST["id"]) ){
        
header("Location: calendar_index.php");
        exit;
    }

    if(isset(
$_GET["action"]) && $_GET["action"] == "DELETE"){
        
$sql "update calendar set deleted = ? where id = ? and cmsloginid = ?";
        
$parameters = array(1, (int)$_GET["id"], $_SESSION["cmsloginid"]);
        
bind_pdo($sql$parameters);

        
header("Location: calendar_index.php");
        exit;
    }

    if(
$_POST){
        if(
$_POST["action"] == "MODIFY"){
            
$sql "update calendar set title = ?, start = ?, end = ? where id = ? and cmsloginid = ?";
            
$parameters = array($_POST["title"], $_POST["start"], $_POST["end"], (int)$_POST["id"], $_SESSION["cmsloginid"]);
            
bind_pdo($sql$parameters);

            
header("Location: calendar_form.php?id=".(int)$_POST["id"]);
            exit;
        }
    }

    
$sql        "select * from calendar where deleted = ? and cmsloginid = ? and id = ?";
    
$parameters = array(0$_SESSION["cmsloginid"], (int)$_GET["id"]);
    
$row   bind_pdo($sql$parameters"selectone");

?>
<!DOCTYPE html>
<html>
<head>
    <?php require_once "_html_head.php"?>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <?php require_once "_header.php"?>
    <?php require_once "_menu.php"?>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                <?= _lang($page_settings['subsection']) ?>
                <small>
                    <?= _lang("Update"?>
                </small>
            </h1>
            <ol class="breadcrumb">
                <li>
                    <?= _lang("Home"?>
                </li>
                <li><a href="<?= $page_settings['domain'?>_index.php"><i class="fa"></i>
                        <?= _lang($page_settings['subsection']) ?>
                    </a></li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content">

            <!-- Your Page Content Here -->

            <!-- main form -->
            <form action="<?= $page_settings['domain'?>_form.php" id="myform" class="myform" method="POST" enctype="multipart/form-data">
                <? if ($row['id']) { ?>
                    <input type="hidden" name="id" value="<?= _h($row['id']) ?>"/>
                    <input type="hidden" name="action" value="MODIFY"/>
                <? ?>
                <div class="row">
                    <div class="col-xs-12">
                        <div class="box">
                            <div class="box-header">
                                <div class="col-md-8">
                                    <div class="btn-group">

                                        <a href="<?= $page_settings['domain'?>_index.php?category_id=<?= (int)$_GET["category_id"?>&msg=4" class="btn btn-default"><i class="fa fa-chevron-left" aria-hidden="true"></i>
                                            <?= _lang('Back'?>
                                        </a>
                                        <button type="submit" class="btn btn-primary" id="LiSaveBtn"> <i class="fa fa-floppy-o" aria-hidden="true"></i> <?= _lang('Save'?></button>
                                        <button type="button" class="btn btn-danger" id="LiSaveBtn" onclick="if( confirm('確定刪除?')){location.href='calendar_form.php?id=<?=$row["id"]?>&action=DELETE';}"> <i class="fa fa-trash" aria-hidden="true"></i> <?= _lang('Delete'?></button>
                                    </div>
                                </div>

                            </div>

                            <!-- /.box-header -->
                            <div class="box-body">
                                <table width="100%" border="0" cellpadding="0" cellspacing="2">

                                    <tr>
                                        <td width="120" align="right" valign="top" class='required_field'>標題</td>
                                        <td width="5" valign="top" class=''>:&nbsp;</td>
                                        <td class=''>
                                            <div class="col-sm-8 form-group">
                                                <input type="text" class="form-control" name="title" size="50" maxlength="255" value="<?= $row['title'?>">
                                            </div>
                                        </td>
                                    </tr>

                                    <tr>
                                        <td width="120" align="right" valign="top" class='required_field'>開始日期及時間</td>
                                        <td width="5" valign="top" class=''>:&nbsp;</td>
                                        <td class=''>
                                            <div class="col-sm-8 form-group">
                                                <input type="text" class="form-control" name="start" size="50" value="<?= $row['start'?>">
                                            </div>
                                        </td>
                                    </tr>


                                    <tr>
                                        <td width="120" align="right" valign="top" class='required_field'>完結日期及時間</td>
                                        <td width="5" valign="top" class=''>:&nbsp;</td>
                                        <td class=''>
                                            <div class="col-sm-8 form-group">
                                                <input type="text" class="form-control" name="end" size="50" value="<?= $row['end'?>">
                                            </div>
                                        </td>
                                    </tr>

                                    <tr>
                                        <td width="120" align="right" valign="top" class=''></td>
                                        <td class='' valign="top"></td>
                                        <td class='red'><br>
                                            <?= lang("* Required Field"?>
                                            <br> <br> <br></td>
                                    </tr>
                                </table>
                                <!-- End Content -->

                            </div>
                            <!-- /.box-body -->
                        </div>
                        <!-- /.box -->
                    </div>
                    <!-- /.col -->
                </div>
                <!-- /.row -->
            </form>

            <!-- End of Your Page Content Here -->

        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->

    <?php require_once "_footer.php"?>
    <?php require_once "_aside.php"?>
</div>
<!-- ./wrapper -->

<!-- REQUIRED JS SCRIPTS -->
<?php require_once "_html_script.php"?>
</body>

</html>