-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocument.php
257 lines (158 loc) · 6.13 KB
/
document.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<?php
require_once('function.php');
dbconnect();
session_start();
if (!is_user()) {
redirect('index.php');
}
?>
<?php
$user = $_SESSION['username'];
$usid = $pdo->query("SELECT id FROM users WHERE username='".$user."'");
$usid = $usid->fetch(PDO::FETCH_ASSOC);
$uid = $usid['id'];
include ('header.php');
?>
<div class="pageheader">
<h2><i class="fa fa-cog"></i> Manage Office Document</h2>
</div>
<div class="contentpanel">
<div class="panel panel-default">
<div class="panel-body">
<?php
if($_POST)
{
$title = $_POST["title"];
$title = $_POST["title"];
$detail = $_POST["detail"];
// IMAGE UPLOAD //////////////////////////////////////////////////////////
$folder = "img/documents/";
$extention = strrchr($_FILES['bgimg']['name'], ".");
$new_name = time();
$bgimg = $new_name.'.jpg';
$uploaddir = $folder . $bgimg;
move_uploaded_file($_FILES['bgimg']['tmp_name'], $uploaddir);
//////////////////////////////////////////////////////////////////////////
$res = $pdo->exec("INSERT INTO documents SET title='".$title."', detail='".$detail."', img='".$bgimg."'");
if($res){
echo "<div class='alert alert-success alert-dismissable'>
<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>
Added Successfully!
</div>";
}else{
echo "<div class='alert alert-danger alert-dismissable'>
<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>
Some Problem Occurs, Please Try Again.
</div>";
}
}
?>
<form name="" id="" action="" method="post" enctype="multipart/form-data" >
<div class="form-group">
<label class="col-sm-3 control-label">Document Title</label>
<div class="col-sm-6"><input name="title" value="" class="form-control" /></div><br/>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Document Description</label>
<div class="col-sm-6"><input name="detail" value="" class="form-control" /></div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Document Image</label>
<div class="col-sm-6"><input name="bgimg" type="file" id="bgimg" /></div>
</div>
<div class="col-sm-6 col-sm-offset-3"><br/>
<button class="btn btn-primary btn-block" style="width:200px; height: 40px;">UPLOAD</button><br/><br/>
</div>
</form>
<div class="clearfix"></div>
<div class="panel panel-default">
<div class="panel-body">
<div class="clearfix mb30"></div>
<div class="table-responsive">
<table class="table table-striped" id="table2">
<thead>
<tr>
<th>#</th>
<th>Title</th>
<th>Document Description</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$ddaa = $pdo->query("SELECT id, title, detail, img FROM documents ORDER BY id");
while ($data = $ddaa->fetch(PDO::FETCH_ASSOC))
{
echo " <tr>
<td>$data[id]</td>
<td>$data[title]</td>
<td>$data[detail]</td>
<td>
<a href='img/documents/$data[img]' class='btn btn-info btn-xs'>View</a>
<a class='btn btn-danger btn-xs' href='deldoc.php?id=$data[id]'>Delete</a>
";
echo "</td></tr>";
}
?>
</tbody>
</table>
</div><!-- table-responsive -->
</div>
</div>
</div><!-- contentpanel -->
</div>
</div><!-- contentpanel -->
</div><!-- mainpanel -->
</section>
<?php
include ('footer.php');
?>
<script src="js/bootstrap-timepicker.min.js"></script>
<script src="js/wysihtml5-0.3.0.min.js"></script>
<script src="js/bootstrap-wysihtml5.js"></script>
<script src="js/ckeditor/ckeditor.js"></script>
<script src="js/ckeditor/adapters/jquery.js"></script>
<script>
jQuery(document).ready(function(){
"use strict";
// HTML5 WYSIWYG Editor
jQuery('#wysiwyg').wysihtml5({color: true,html:true});
// CKEditor
jQuery('#ckeditor').ckeditor();
jQuery('#inlineedit1, #inlineedit2').ckeditor();
// Uncomment the following code to test the "Timeout Loading Method".
// CKEDITOR.loadFullCoreTimeout = 5;
window.onload = function() {
// Listen to the double click event.
if ( window.addEventListener )
document.body.addEventListener( 'dblclick', onDoubleClick, false );
else if ( window.attachEvent )
document.body.attachEvent( 'ondblclick', onDoubleClick );
};
function onDoubleClick( ev ) {
// Get the element which fired the event. This is not necessarily the
// element to which the event has been attached.
var element = ev.target || ev.srcElement;
// Find out the div that holds this element.
var name;
do {
element = element.parentNode;
}
while ( element && ( name = element.nodeName.toLowerCase() ) &&
( name != 'div' || element.className.indexOf( 'editable' ) == -1 ) && name != 'body' );
if ( name == 'div' && element.className.indexOf( 'editable' ) != -1 )
replaceDiv( element );
}
var editor;
function replaceDiv( div ) {
if ( editor )
editor.destroy();
editor = CKEDITOR.replace( div );
}
jQuery('#timepicker').timepicker({defaultTIme: false});
jQuery('#timepicker2').timepicker({showMeridian: false});
jQuery('#timepicker3').timepicker({minuteStep: 15});
});
</script>
</body>
</html>