-
Notifications
You must be signed in to change notification settings - Fork 0
/
addNews.php
118 lines (84 loc) · 3.49 KB
/
addNews.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
<?php
include 'layout.php';
include 'model.php';
if (!isset($_SESSION['userType']) && $_SESSION['userType'] != 3) {
header("location:main.php");
}
if (isset($_POST['news']) && !empty($_POST['news'])) {
$manager = getManagerIdByemail($_SESSION['email']);
if ($row = $manager->fetch()) {
insertNews($row['mid'], $_POST['news']);
echo "<script>alert('News Spread Successfully!')</script>";
header("location:news.php");
}
}
?>
<link rel="stylesheet" href="css/aboutUs.css" type="text/css">
<script src="ckeditor/ckeditor.js"></script>
<div class="left-sidebar" id="left-sidebar">
<a href="#" id="close-sidebar" class="fas fa-arrow-left"></a>
<a href="picnics.php" class="fas fa-thumbtack"> Latest Picnics</a>
<a href="news.php" class="fas fa-newspaper"> News</a>
<?php if (isset($_SESSION['userType']) && $_SESSION['userType'] == 2) { ?>
<a href="#" class="fas fa-shopping-cart" id="openCart"> Cart <span id="openCart-span"
class="fas fa-sort-down"
style="float: right"></span></a>
<div class="purchase" id="purchase">
<?php $customer = getCustomerIdByEmail($_SESSION['email']);
$cid = 0;
if ($i = $customer->fetch())
$cid = $i['cid'];
$order = getPurchase($cid);
?>
<ul><?php
while ($i = $order->fetch()) {
echo "<li>" . $i['pid'] . " | " . $i['title'] . "</li>";
echo "<small>" . $i['invoice'] . " <strong class='fas fa-shekel-sign'></strong></small>";
echo "<hr>";
}
?> </ul><?php
?>
</div>
<?php } ?>
</div>
<script type="text/javascript">
var role = <?=$_SESSION['userType']?>;
if (role ==2) {
document.getElementById('openCart').addEventListener('click', function (event) {
event.preventDefault();
openAndCloseCart();
});
}
</script>
<div id="container">
<div class="container-news" id="container">
<sub style="color:red;display: none;padding: 10px" id="error">Please Fill in the Text-area!</sub>
<input type="button"
onclick="validate()"
class="bt"
style="position: absolute;left: 35%;top: 1%;cursor: pointer" value="Spread News">
<div class="row" id="contact">
<form method="post" id="news" action="addNews.php">
<textarea name="news" id="news-text"></textarea>
</form>
</div>
</div>
</div>
<script>
document.getElementById('close-sidebar').addEventListener('click', function (event) {
event.preventDefault();
closeSlidMenu();
})
CKEDITOR.replace('news');
function validate() {
let value = CKEDITOR.instances.news.getData();
if (!value) {
document.getElementById('error').style.display = 'block';
} else {
document.getElementById('news-text').value = value;
document.getElementById('news').submit();
}
}
</script>
<?php
require 'footer.php';