view_memo.php
8.22 KB
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
<?php
if(isset($_GET['memoid'])){
require_once "view_memo_detail.php";
} elseif(isset($_GET['memoidinternal'])){
require_once "view_memo_internal_detail.php";
}else{
/* PAGINATION */
$batas = 5;
$pg = isset( $_GET['halaman'] ) ? $_GET['halaman'] : "";
if(empty($pg)){
$posisi = 0;
$pg = 1;
}else{
$posisi = ($pg-1) * $batas;
}
/* END PAGINATION */
//$userLike = "'%\"$_SESSION[id_user]\"%'";
$userLike = "%".$_SESSION['id_user']."%";
$userID = $_SESSION['id_user'];
$field = array("
'Eksternal' as identitas,
'Surat Masuk Eksternal' as titel,
'sm' as type,
'smid' as kat,
'memoid' as memo,
a.id_user,
a.id_sm,
a.tgl_sm,
a.asal_sm,
a.perihal,
(SELECT count(*) FROM surat_read WHERE surat_read.id_sm = a.id_sm AND surat_read.id_user='".$userID."' AND surat_read.kode='SM') as surat_read,
(SELECT count(*) FROM memo WHERE memo.id_sm = a.id_sm) as memocount,
(SELECT statsurat FROM status_surat WHERE status_surat.id_sm = a.id_sm ORDER BY status_surat.id_status DESC LIMIT 1) AS status_surat
");
// var_dump($field);exit;
$field_help = "
'Internal' as identitas,
'Surat Keluar Internal' as titel,
'sk_internal' as type,
'skid' as kat,
'memoidinternal' as memo,
a.id_user,
a.id_sk,
a.tgl_agenda as tgl_sm,
a.pembuat as asal_sm,
a.perihal,
(SELECT count(*) FROM surat_read WHERE surat_read.id_sk = a.id_sk AND surat_read.id_user='".$userID."' AND surat_read.kode='SKI') as surat_read,
(SELECT count(*) FROM surat_keluar_internal as b WHERE b.id_sk = a.id_sk) as memocount,
(SELECT statsurat FROM status_surat WHERE status_surat.id_sk = a.id_sk ORDER BY status_surat.id_status DESC LIMIT 1) AS status_surat
";
// var_dump($field_help);exit;
//$userLike = "'%\"3\"%'";
if(isset($_GET['keyword'])){
$keyword = "%".$_GET['keyword']."%";
if(empty($_GET['keyword'])){
$bantuan = "";
$bantuan1 = "";
if($userID != 1){
$bantuan = "AND a.tujuan_surat LIKE '".$userLike."' ";
$bantuan1 = "AND a.tujuan LIKE '".$userLike."' ";
}
$SM = $this->model->selectprepare("surat_masuk a", $field, $params=null, $where=null, $bantuan, " UNION SELECT ".$field_help." FROM surat_keluar_internal a ".$bantuan1." order by tgl_sm DESC LIMIT $posisi, $batas");
$SM2 = $this->model->selectprepare("surat_masuk a", $field, $params=null, $where=null, $bantuan, " UNION SELECT ".$field_help." FROM surat_keluar_internal a ".$bantuan1." ");
}else{
$bantuan = "";
$bantuan1 = "";
if($userID != 1){
$bantuan = "AND a.tujuan_surat LIKE '".$userLike."' ";
$bantuan1 = "AND a.tujuan LIKE '".$userLike."' ";
}
$SM = $this->model->selectprepare("surat_masuk a", $field, $params=null, $where=null, "WHERE (a.asal_sm LIKE '".$keyword."' OR a.perihal LIKE '".$keyword."') ".$bantuan." ", " UNION SELECT ".$field_help." FROM surat_keluar_internal a WHERE (a.asal_sm LIKE '".$keyword."' OR a.perihal LIKE '".$keyword."') ".$bantuan1." order by tgl_sm DESC LIMIT $posisi, $batas");
$SM2 = $this->model->selectprepare("surat_masuk a", $field, $params=null, $where=null, "WHERE (a.asal_sm LIKE '".$keyword."' OR a.perihal LIKE '".$keyword."') ".$bantuan." ", " UNION SELECT ".$field_help." FROM surat_keluar_internal a WHERE (a.asal_sm LIKE '".$keyword."' OR a.perihal LIKE '".$keyword."') ".$bantuan1." ");
}
}else{
$bantuan = " WHERE a.tujuan_surat != 'null'";
$bantuan1 = " WHERE a.tujuan != 'null'";
if($userID != 1){
$bantuan = "WHERE a.tgl_sm >= '2020-01-01' AND a.tujuan_surat LIKE '%".$_SESSION['nip']."%' AND a.id_sm NOT IN (SELECT b.id_sm FROM surat_read b WHERE b.id_user='".$_SESSION['id_user']."' AND b.kode='SM')";
$bantuan1 = "WHERE a.tgl_agenda >= '2020-01-01' AND a.tujuan LIKE '%".$_SESSION['nip']."%' AND a.id_sk NOT IN (SELECT b.id_sk FROM surat_read b WHERE b.id_user='".$_SESSION['id_user']."' AND b.kode='SKI')";
}
// $SM = $this->model->selectprepare("surat_masuk a", $field, $params=null, $where=null, "WHERE a.tujuan_surat LIKE '%".$_SESSION['nip']."%' AND a.id_sm NOT IN (SELECT b.id_sm FROM surat_read b WHERE b.id_user='".$_SESSION['id_user']."' AND b.kode='SM')", " UNION SELECT ".$field_help." ".$params=null." ".$where=null." FROM surat_keluar_internal a WHERE a.id_user='".$_SESSION['id_user']."' AND a.id_sk NOT IN (SELECT b.id_sk FROM surat_read b WHERE b.id_user='".$_SESSION['id_user']."' AND b.kode='SKI')");
$SM = $this->model->selectprepare("surat_masuk a", $field, $params=null, $where=null, $bantuan, " UNION SELECT ".$field_help." FROM surat_keluar_internal a ".$bantuan1." order by tgl_sm DESC LIMIT $posisi, $batas");
$SM2 = $this->model->selectprepare("surat_masuk a", $field, $params=null, $where=null, $bantuan, " UNION SELECT ".$field_help." FROM surat_keluar_internal a ".$bantuan1." order by tgl_sm DESC");
// var_dump($SM);exit;
}
if($SM->rowCount() >= 1){?>
<div class="widget-box">
<div id="inbox" class="tab-pane in active">
<div class="message-container">
<div class="message-list-container">
<div class="message-list" id="message-list"><?php
$no=1+$posisi;
while($ViewSM = $SM->fetch(PDO::FETCH_OBJ)){
$tglterima = substr($ViewSM->tgl_sm,0,10);
if($ViewSM->status_surat == '1'){
$ProgresStat = " <i class=\"ace-icon fa fa-history bigger-110 green\" title=\"Surat sedang ditindaklanjuti\"></i>";
} elseif ($ViewSM->status_surat == '2') {
$ProgresStat = " <i class=\"ace-icon fa fa-thumbs-o-up bigger-110 green\" title=\"Surat sudah selesai ditindaklanjuti\"></i>";
} elseif ($ViewSM->status_surat == '0') {
$ProgresStat = " <i class=\"ace-icon fa fa-times bigger-110 green\" title=\"Surat tidak dapat diproses\"></i>";
} else{
$ProgresStat = " <i class=\"ace-icon fa fa-info bigger-110 green\" title=\"Surat belum diproses\"></i>";
}
$surat_readShow = $ViewSM->surat_read == 0 ? "message-unread" : "";
?>
<div class="message-item <?php echo $surat_readShow;?>">
<label class="inline">
<span class="lbl" style="color:#609FC4;font-weight:700"><small><?php echo $no;?></small></span>
</label>
<!-- <span class="sender" title="<?php echo $ViewSM->pengirim;?>"><?php echo $ViewSM->asal_sm;?></span> -->
<span title="<?php echo $ViewSM->pengirim;?>">Pengirim : <?php echo $ViewSM->asal_sm;?> (<?php echo $this->model->noref($ViewSM->id_sm);?>) <?php echo "[".$ViewSM->identitas."]" ?></span>
<span class="time" style="width:100px;"><small><?php echo tgl_indo($tglterima);?></small></span>
<p class="summary">
<p class="text">
<a href="./index.php?op=<?php echo $ViewSM->type;?>&<?php echo $ViewSM->kat."=".$ViewSM->id_sm;?>" title="<?php echo $ViewSM->titel;?>">Perihal : <?php echo $ViewSM->perihal;?></a>
<?php echo $ProgresStat;?>
</p>
<!-- <?php echo $labelStat;?> -->
</p>
</div><?php
$no++;
}?>
</div>
</div>
</div>
</div>
</div><?php
}else{?>
<div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">
<i class="ace-icon fa fa-times"></i>
</button>
<p>
<strong><i class="ace-icon fa fa-check"></i>Perhatian!!!</strong>
Belum ada data surat masuk untuk anda. Terimakasih.
</p>
</div><?php
}
/* PAGINATION */
//hitung jumlah data
if(isset($_GET['keyword'])){
$jml_data = $SM2->rowCount();
$link_order="&keyword=$_GET[keyword]";
}else{
$jml_data = $SM2->rowCount();
$link_order="";
}
//Jumlah halaman
$JmlHalaman = ceil($jml_data/$batas);
//Navigasi ke sebelumnya
if($pg > 1){
$link = $pg-1;
$prev = "index.php?op=memo&halaman=$link$link_order";
$prev_disable = " ";
}else{
$prev = "#";
$prev_disable = "disabled";
}
//Navigasi ke selanjutnya
if($pg < $JmlHalaman){
$link = $pg + 1;
$next = "index.php?op=memo&halaman=$link$link_order";
$next_disable = " ";
}else{
$next = "#";
$next_disable = "disabled";
}
if($batas < $jml_data){?>
<ul class="pager">
<li class="previous <?php echo $prev_disable;?>"><a href="<?php echo $prev;?>">← Sebelumnya </a></li>
<li class="next <?php echo $next_disable;?>"><a href="<?php echo $next;?>">Selanjutnya →</a></li>
</ul>
<span class="text-muted">Halaman <?php echo $pg;?> dari <?php echo $JmlHalaman;?> (Total : <?php echo $jml_data;?> records)</span> <?php
}
/* END PAGINATION */
}?>