-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmemo.php
208 lines (192 loc) · 6.81 KB
/
memo.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
<?php
$page = "memo";
include("meta.php");
include("header.php");
//exit("memo temporary unavailable");
if (!$_SESSION["login"]){
echo "<script>window.location = 'index.php'</script>";
die();
}
if (!isset($_GET["id"])){
$id_memo = 1;
$type = 4;
}else{
$id_memo = $_GET["id"];
if ($id_memo > 2){
$id_memo = 2;
}
if($id_memo == 1) { $type = 4; $statRep = 'rep';}
if($id_memo == 2) { $type = 5; $statRep = 'fwd';}
}
if(!isset($_GET['page'])) $page = 1;
else $page = $_GET['page'];
if (isset($_GET["delete"])){
if ($_GET["delete"] > 0){
$reqAPIMemoDel = array(
'auth' => $authapi,
"userid" => $login,
"id" => $_GET["delete"],
"type" => 3,
);
$respMemoDel = sendAPI($url_Api."/memo",$reqAPIMemoDel,'JSON','02e97eddc9524a1e');
if( $respMemoDel->status == 200 ){
echo "<script>window.location = 'memo.php?id=" . $id_memo . "'</script>";
}
echo "<script>alert('Delete Failed, " . $respMemoDel->msg . "');</script>";
}
}
// get inbox/outbox
$reqAPIMemoinout = array(
"auth" => $authapi,
"agent" => $agentwlable,
"userid" => $login,
"type" => $type,
);
$respMemoinout = sendAPI($url_Api."/memo?page=".$page,$reqAPIMemoinout,'JSON','02e97eddc9524a1e');
$total_page = $respMemoinout->resp->last_page;
?>
<link rel="stylesheet" href="assets/css/popmodal.css?id=<?PHP echo time(); ?>" type="text/css" />
<style>
#table-memo tbody td{ color: #ffffff !important; }
#unread{ color: #f00; }
</style>
<div id="content">
<div class="container">
<div class="clear space_30"></div>
<div class="wrap">
<div class="full">
<div class="head-wrap">
<?php if ($id_memo == 1){
echo '<h1>Memo - Inbox</h1>';
}else{
echo '<h1>Memo - Outbox</h1>';
}
?>
</div>
<div class="body-wrap">
<div class="left">
<a class="btn btn-login" href="?id=1">Kotak Masuk</a>
<a class="btn btn-login" href="?id=2">Kotak Keluar</a>
</div>
<div class="right">
<a class="btn btn-write compose popup2" id="compose">Tulis Memo</a>
</div>
<div class="clear space_20"></div>
<?php
getPaging($total_page, $page, 'memo.php?id='.$id_memo, array('showMore' => true));
?>
<table id="table-memo">
<thead>
<tr>
<th>#</th>
<?php
if ($id_memo == 1) echo '<th>Dari</th>';
if ($id_memo == 2) echo '<th>Kepada</th>';
?>
<th>Subjek</th>
<th>Tanggal</th>
<th>Status</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
$i = $respMemoinout->resp->from;
if( $respMemoinout->resp->total > 0 ){
foreach($respMemoinout->resp->data AS $memo){
if ($memo->mread == 0){
$read = '<span id="unread">Belum dibaca</span>';
}else{
$read = '<span id="read">baca</span>';
}
?>
<tr>
<td align="center"><?php echo $i++; ?></td>
<td><?php echo 'Operator'; ?></td>
<td><?php echo $memo->msubject.' <br>';?></td>
<td><?php echo date('d/m/Y H:i:s', strtotime($memo->mdate)); ?></td>
<td><?php echo $read; ?></td>
<td align="center">
<a class="table" rel="withdraw"></a>
<a class="id" rel="4"></a>
[<a href="#" id="read-<?php echo $memo->id; ?>" class="popup2"><font color=white>Baca</font></a>]
[<a href="#" id="rep-<?php echo $memo->id; ?>" class="popup2"><font color=white>Balas</font></a>]
[<a href="javascript:delete_record('<?php echo $memo->id; ?>','<?php echo $id_memo;?>');" ><font color=white>Hapus</font></a>]
</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
</div>
</div>
</div>
<div class="clear space_30"></div>
</div>
<!-- The Modal -->
<div id="Modal" class="modal">
<!-- Modal content -->
<div class="modal-content memo"></div>
</div>
</div>
<script language="JavaScript" type="text/javascript">
$(document).ready(function(){
$(".toggleCheck").bind("click", function(){
var current=$(this);
var table=current.parent().children("a.table").attr("rel");
var id=current.parent().children("a.id").attr("rel");
if(confirm("Are you sure want to perform this action? Click 'OK' to continue.")){
$.get(''+"/"+table+"/"+id+"/"+current.attr("rel"), function(r){
$("#statusCheck"+id).html(r);
})
}
});
$("#table th, #table tfoot tr td").css({
"background":"#444444",
"color":"#ffffff"
});
$("#table").css({
"border":"1px solid #444444"
});
})
function delete_record(idmemo, idbox){
if (!idmemo){
return false;
}else if (!idbox){
return false;
}else{
var validasi = confirm("Are you sure, to delete this memo?");
if (validasi){
window.location = "memo.php?id="+idbox+"&delete="+idmemo;
}
}
}
var modal = document.getElementById('Modal');
function openModal() {
modal.style.display = "block";
}
$('.popup2').click(function () {
var id = $(this).attr('id');
var span = document.getElementsByClassName("close")[0];
if(id == 'compose')
$('#Modal .modal-content').load('memo-form.php?typ=com', function () { openModal(); });
if(id.substring(0, 3) == 'rep') {
var memid = id.split('-')[1];
$('#Modal .modal-content').load('memo-form.php?typ=<?php echo $statRep; ?>&id='+memid, function () { openModal() });
}
if(id.substring(0, 4) == 'read') {
var memid = id.split('-')[1];
$('#Modal .modal-content').load('memo-read.php?typ=<?php echo $id_memo;?>&id='+memid, function () { openModal() });
}
});
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>
<?php
include("footer.php");
?>