view_sm_detail_sekretaris.php
16.6 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
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
<?php
$params = array(':id_sm' => trim($_GET['smid']));
$sm = $this->model->selectprepare("surat_masuk a INNER JOIN user b on a.id_user=b.id_user", $field=null, $params, "a.id_sm=:id_sm", "ORDER BY tgl_terima DESC");
//cek tujuan
//$params = array(':id_sm' => trim($_GET['memoid']));
//$userLike = "'%\"$_SESSION[id_user]\"%'";
$userLike = '"%'.$_SESSION["id_user"].'%"';
$cekmemo = $this->model->selectprepare("surat_masuk", $field=null, $params, "id_sm=:id_sm", "AND (tujuan_surat LIKE ".$userLike." OR tujuan_surat LIKE '%".$_SESSION["nip"]."%') ");
$sk_tb_sm = $this->model->selectprepare("tbl_tembusan_sm", $field=null, $params, "id_sm=:id_sm");
$data_tb_sm= $sk_tb_sm->fetch(PDO::FETCH_OBJ);
$tembusan = json_decode($data_tb_sm->tembusan, true);
if($sm->rowCount() >= 1){
$data_sm = $sm->fetch(PDO::FETCH_OBJ);
$paramsx = array(':id_sm' => $data_sm->id_sm);
$StatSurat = $this->model->selectprepare("status_surat a join user b on a.id_user=b.id_user", $field=null, $paramsx, "a.id_sm=:id_sm", "ORDER BY a.id_status DESC");
$tujuansrt = json_decode($data_sm->tujuan_surat, true);
$idsm= $data_sm->id_sm;
if(isset($_GET['act']) && $_GET['act'] == "del"){
## Hanya Admin yang bisa menghapus ##
if($_SESSION['id_user'] != '1' and $_SESSION['hakakses'] != 'Admin'){
die("<script>alert('Hanya Admin yang diperbolehkan menghapus data. Terimakasih');window.history.go(-1);</script>");
}
$params = array(':id_sm' => $idsm, ':status' => '0');
$lihat_sm = $this->model->selectprepare("memo", $field=null, $params, "id_sm=:id_sm AND status=:status");
if($lihat_sm->rowCount() >= 1){
die("<script>alert('Data surat masuk ini tidak dapat dihapus karena terkait dengan data disposisi. Jika tetap ingin menghapus, silahkan hapus data disposisi surat ini terlebih dahulu. Terimakasih');window.history.go(-1);</script>");
}else{
@unlink('berkas/'.$data_sm->file);
$params = array(':id_sm' => $idsm);
$delete = $this->model->hapusprepare("surat_masuk", $params, "id_sm=:id_sm");
if($delete){
$cek = $this->model->selectprepare("surat_masuk", $field=null, $params=null, $where=null);
if($cek->rowCount() <= 0){
$delete = $this->model->truncate("surat_masuk");
}
echo "<script type=\"text/javascript\">alert('Data Berhasil di Hapus...!!');window.location.href=\"./index.php?op=sm\";</script>";
}else{
die("<script>alert('Gagal menghapus data surat masuk, Silahkan Coba Kembali..!!');window.history.go(-1);</script>");
}
}
}
$params = array(':id_user' => $_SESSION['id_user'], ':id_sm' => $data_sm->id_sm, ':kode' => 'SM');
$lihat_sm = $this->model->selectprepare("surat_read", $field=null, $params, "id_sm=:id_sm AND id_user=:id_user AND kode=:kode");
if($lihat_sm->rowCount() <= 0){
$field = array('id_user' => $_SESSION['id_user'], 'id_sm' => $data_sm->id_sm, 'kode' => 'SM');
$insert2 = $this->model->insertprepare("surat_read", $field, $params);
}
$params = array(':id_user' => $_SESSION['id_user'], ':id_sm' => $data_sm->id_sm, ':kode' => 'SM');
$lihat_sk = $this->model->selectprepare("surat_read", $field=null, $params, "id_sm=:id_sm AND id_user=:id_user AND kode=:kode");
if($lihat_sk->rowCount() <= 0){
$field = array('id_user' => $_SESSION['id_user'], 'id_sm' => $data_sm->id_sm, 'kode' => 'SM');
$insert2 = $this->model->insertprepare("surat_read", $field, $params);
}
$params = array(':id_sm' => $data_sm->id_sm, ':status' => '0');
$cekDisposisi = $this->model->selectprepare("memo a join user b on a.id_user=b.id_user", $field=null, $params, "a.id_sm=:id_sm AND a.status=:status", "ORDER BY a.tgl ASC");?>
<div class="widget-box">
<div class="message-header clearfix">
<div class="pull-left" style="padding:0 9px;">
<span class="blue bigger-125">
<?php echo $data_sm->perihal;?>
</span>
<div class="space-4"></div>
<img class="middle" alt="John's Avatar" src="assets/images/avatars/<?php echo $data_sm->picture;?>" width="32" />
<a href="#" class="sender"><?php echo $data_sm->nama;?></a>
<i class="ace-icon fa fa-clock-o bigger-110 orange middle"></i>
<span class="time grey"><?php echo tgl_indo($data_sm->tgl_terima);?></span>
</div>
</div>
<div class="hr hr-double"></div>
<div class="message-body">
<p>
Tgl Agenda/No agenda: <br/><b><?php echo tgl_indo($data_sm->tgl_agenda);?> | <?php echo $this->model->noref_sm($data_sm->id_sm);?></b>
</p>
<p>
Dari: <br/><b><?php echo $data_sm->asal_sm;?></b>
</p>
<p>
Tgl/No surat: <br/><b><?php echo tgl_indo($data_sm->tgl_sm);?> | <?php echo $data_sm->no_sm;?></b>
</p>
<p>
Perihal: <br/><b><?php echo $data_sm->perihal;?></b>
</p>
<p>
Tujuan surat: <br/><b>
<?php
if(is_array($tujuansrt)){
foreach($tujuansrt as $field => $value){
$field = array('nama', '(SELECT nama FROM unit_kerja WHERE unit_kerja.id = user.unitkerjaid) as unit_kerja');
$GetUserDis = $this->model->selectprepare("user", $field, $params=null, $where=null, "WHERE nik='".$value."' ")->fetch(PDO::FETCH_OBJ);
echo '- '.$GetUserDis->nama.' ('.$GetUserDis->unit_kerja.') <br/>';
}
}?></b>
</p>
<p>
Tembusan surat: <br/><b>
<?php
if(is_array($tembusan)){
foreach($tembusan as $field => $value){
$field = array('nama', '(SELECT nama FROM unit_kerja WHERE unit_kerja.id = user.unitkerjaid) as unit_kerja');
$GetUserDis = $this->model->selectprepare("user", $field, $params=null, $where=null, "WHERE nik='".$value."' ")->fetch(PDO::FETCH_OBJ);
echo '- '.$GetUserDis->nama.' ('.$GetUserDis->unit_kerja.') <br/>';
}
}?></b>
</p>
<?php
$params = array(':id_sm' => $data_sm->id_sm, ':status' => '0');
$cek_memo = $this->model->selectprepare("memo a inner join bagian b on a.disposisi=b.id_bag", $field=null, $params, "a.id_sm=:id_sm AND a.status=:status");
if($cek_memo->rowCount() >= 1){
$data_cek = $cek_memo->fetch(PDO::FETCH_OBJ);?>
<p>
<b>Status Surat: </b><br/>Diteruskan ke : <b><a href="./index.php?op=memo&memoid=<?php echo $data_cek->id_status;?>" target="_blank"><?php echo $data_cek->nama_bagian;?></b></a>
</p><?php
}?>
<hr/>
<!--
<p>
Bukti Terima Surat:<br/>
<span class="label label-xs label-primary label-white middle">
<a href="./index.php?op=smprint&smid=<?php echo $data_sm->id_sm;?>" target="_blank"><b>Lihat</b></a>
</span>
<span class="label label-xs label-danger label-white middle">
<a href="./index.php?op=smprint&smid=<?php echo $data_sm->id_sm;?>&act=pdf" target="_blank"><b>Cetak</b> <i class="ace-icon fa fa-file-pdf-o align-top bigger-125 icon-on-right"></i></a>
</span>
</p>
<p>
Detail Surat:<br/>
<span class="label label-xs label-primary label-white middle">
<a href="./index.php?op=memoprint&memoid=<?php echo $data_sm->id_sm;?>" target="_blank"><b>Lihat</b></a>
</span>
<span class="label label-xs label-danger label-white middle">
<a href="./index.php?op=memoprint&memoid=<?php echo $data_sm->id_sm;?>&act=pdf" target="_blank"><b>Cetak</b> <i class="ace-icon fa fa-file-pdf-o align-top bigger-125 icon-on-right"></i></a>
</span>
</p>
-->
<?php if($data_sm->status_draft == '1'){ ?>
<p>
<?php
if(is_array($tujuansrt)){
foreach($tujuansrt as $field => $value){
if($value == $_SESSION["nip"]){ ?>
<a href="./index.php?op=memo&memoid=<?php echo $data_sm->id_sm;?>&act=progres"><button class="btn btn-primary btn-minier ">ENTRI PROGRESS SURAT <i class="ace-icon fa fa-arrow-right align-center bigger-100 icon-on-right"></i></button></a>
<?php }
}
}?>
</p>
<?php }
//$params = array(':id_sm' => $data_sm->id_sm, ':status' => '0');
//$StatSurat = $this->model->selectprepare("status_surat a join user b on a.id_user=b.id_user", $field=null, $params, "a.id_sm=:id_sm a.status=:status", "ORDER BY a.id_status ASC");
//$params = array(':id_sm' => $data_sm->id_sm);
//$StatSurat = $this->model->selectprepare("status_surat a join user b on a.id_user=b.id_user", $field=null, $params, "a.id_sm=:id_sm", "ORDER BY a.id_status DESC");
if($StatSurat->rowCount() >= 1){?>
<hr/>
<div class="widget-body">
<div class="widget-main padding-0">
<div id="profile-feed-1" class="profile-feed">
</div>
</div>
</div><?php
$no=1;
while($dataStatSurat= $StatSurat->fetch(PDO::FETCH_OBJ)){?>
<div class="profile-activity clearfix"><?php
if($no == 1){?>
<b>PROGRES SURAT</b><?php
}
if($dataStatSurat->statsurat == 1){
$statusSirat = "Sedang diproses";
}elseif($dataStatSurat->statsurat == 2){
$statusSirat = "Selesai";
}elseif($dataStatSurat->statsurat == 0){
$statusSirat = "Dibatalkan";
}?>
<div>
<a class="user" href="#"><?php echo $dataStatSurat->nama; ?></a>
update status surat : <span class="text-primary"><?php echo $statusSirat; ?></span><?php
if($dataStatSurat->ket !==''){?>
<?php echo '('.$dataStatSurat->ket .')';
if($dataStatSurat->file_progress != ''){ ?>
<a href="./berkas/<?php echo $dataStatSurat->file_progress;?>" title="Dokumen Pendukung" target="_blank"><i class="ace-icon fa fa-file-pdf-o align-top bigger-125 icon-on-right"></i></a> <?php
}
}?>
<div class="time">
<?php echo tgl_indo1($dataStatSurat->created);?>, <?php echo substr($dataStatSurat->created,-9,-3);?> WIB
</div>
</div><?php
/*if($dataStatSurat->id_user == $_SESSION['id_user']){?>
<div class="tools action-buttons">
<a href="./index.php?op=memo&memoid=<?php echo $data_memo->id_sm;?>&act=progres&id=<?php echo $dataStatSurat->id_status;?>" class="blue">
<i class="ace-icon fa fa-pencil bigger-125"></i>
</a>
<a href="./index.php?op=memo&memoid=<?php echo $data_memo->id_sm;?>&act=progres&id=<?php echo $dataStatSurat->id_status;?>&do=delete" class="red">
<i class="ace-icon fa fa-times bigger-125"></i>
</a>
</div><?php
}*/ ?>
</div>
<?php
$no++;
}
} else {
echo "<p>Belum ada progress surat</p>";
}
//////////////////////////////////////////////////////////////// agung
$bantuan = "";
$bantuan1 = "";
if($data_sm->id_sm <> ''){
$bantuan = "where a.id_sm='".$data_sm->id_sm."' order by id_status desc";
}
$cekDisposisi = $this->model->selectprepare("memo a join user b on a.id_user=b.id_user", $field=null, $params=null, $where=null, $bantuan);
//echo $memoid;
if($cekDisposisi->rowCount() >= 1){
$ArrStatRiwayat = array(0 => "Open", 2 => "Selesai", 9 => "Disposisi");
?>
<p><hr/><b><a href="./index.php?op=memo&memoid=<?php echo $data_sm->id_sm;?>&act=disposisi">RIWAYAT DISPOSISI SURAT:</a></b><br/>
<div style="overflow: auto;">
<table id="simple-table" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th width="200">Disposisi dari</th>
<th width="200">Tujuan Disposisi</th>
<th>Catatan</th>
<th>File</th>
<th>Status</th>
<th width="200">Waktu</th>
</tr>
</thead>
<tbody><?php
while($dataDisposisi= $cekDisposisi->fetch(PDO::FETCH_OBJ)){
$ListDisposisi2 = json_decode($dataDisposisi->disposisi, true);
$tgl_dispolevel = substr($dataDisposisi->tgl,0,10);?>
<tr>
<td><?php echo $dataDisposisi->nama;?></td>
<td><?php
foreach($ListDisposisi2 as $listdispo){
$TampilUser = $this->model->selectprepare("tag", $field=null, $params=null, $where=null, "WHERE nip='$listdispo'")->fetch(PDO::FETCH_OBJ);
$TampilNama = $this->model->selectprepare("tag", $field=null, $params=null, $where=null, "WHERE nip='$listdispo'")->fetch(PDO::FETCH_OBJ);
echo "- ".$TampilNama->nama_user;?>
<!--<a href="./index.php?op=disposisiprint&smid=<?php echo $data_sm->id_sm;?>&iduser=<?php echo $TampilUser->nip; ?>&dispo=<?php echo $dataDisposisi->id_user;?>" target="_blank"><i class="ace-icon fa fa-globe align-top bigger-125 icon-on-right"></i></a>
<a href="./index.php?op=disposisiprint&smid=<?php echo $data_sm->id_sm;?>&iduser=<?php echo $TampilUser->nip; ?>&dispo=<?php echo $dataDisposisi->id_user;?>&act=pdf" target="_blank"><i class="ace-icon fa fa-file-pdf-o align-top bigger-125 icon-on-right"></i></a>--><br/><?php
}?>
</td>
<td><?php echo $dataDisposisi->note;?></td>
<td><?php
if($dataDisposisi->file != ""){?>
<a href="./berkas/<?php echo $dataDisposisi->file;?>" target="_blank">Lihat File Surat</a><?php
}else{ ?>
- <?php
}?></td>
<td><?php if($dataDisposisi->status=='0'){echo '<p>
<a href="./index.php?op=memo&memoidinternal='.$dataDisposisi->id_sm.'&act=progres"><button class="btn btn-primary btn-minier ">ENTRI PROGRESS SURAT <i class="ace-icon fa fa-arrow-right align-center bigger-100 icon-on-right"></i></button></a>
</p>';
}else{
echo $ArrStatRiwayat[$dataDisposisi->status];
}?></td>
<td><?php echo tgl_indo($tgl_dispolevel);?>, <?php echo substr($dataDisposisi->tgl,-9,-3);?> WIB</td>
</tr><?php
}?>
</tbody>
</table>
</div>
</p><?php
} else {
}
//////////////////////////////////////////////////////////////// agung
//echo $data_sm->disposisi;
if($cekDisposisi->rowCount() >= 1){ /*?>
<p><hr/><b><a href="./index.php?op=memo&memoid=<?php echo $data_sm->id_sm;?>&act=disposisi">RIWAYAT DISPOSISI SURAT:</a></b><br/>
<table id="simple-table" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th width="200">Disposisi dari</th>
<th width="200">Tujuan Disposisi</th>
<th>Catatan</th>
<th width="200">Waktu</th>
</tr>
</thead>
<tbody><?php
while($dataDisposisi= $cekDisposisi->fetch(PDO::FETCH_OBJ)){
$ListDisposisi2 = json_decode($dataDisposisi->disposisi, true);
$tgl_dispolevel = substr($dataDisposisi->tgl,0,10);?>
<tr>
<td><?php echo $dataDisposisi->nama;?></td>
<td><?php
foreach($ListDisposisi2 as $listdispo){
$TampilUser = $this->model->selectprepare("tag", $field=null, $params=null, $where=null, "WHERE nip='$listdispo'")->fetch(PDO::FETCH_OBJ);
$TampilNama = $this->model->selectprepare("tag", $field=null, $params=null, $where=null, "WHERE nip='$listdispo'")->fetch(PDO::FETCH_OBJ);
echo "- ".$TampilNama->nama_user;?>
<a href="./index.php?op=disposisiprint&smid=<?php echo $data_sm->id_sm;?>&iduser=<?php echo $TampilUser->nip; ?>&dispo=<?php echo $dataDisposisi->id_user;?>" target="_blank"><i class="ace-icon fa fa-globe align-top bigger-125 icon-on-right"></i></a>
<a href="./index.php?op=disposisiprint&smid=<?php echo $data_sm->id_sm;?>&iduser=<?php echo $TampilUser->nip; ?>&dispo=<?php echo $dataDisposisi->id_user;?>&act=pdf" target="_blank"><i class="ace-icon fa fa-file-pdf-o align-top bigger-125 icon-on-right"></i></a><br/><?php
}?>
</td>
<td><?php echo $dataDisposisi->note;?></td>
<td><?php echo tgl_indo($tgl_dispolevel);?>, <?php echo substr($dataDisposisi->tgl,-9,-3);?> WIB</td>
</tr><?php
}?>
</tbody>
</table>
</p><?php */
} else {
if($cekmemo->rowCount() >= 1 and $data_sm->status_draft=='1' and $StatSurat->rowCount() < 1){
echo '<ul class="pager"><li class="next"><a href="./index.php?op=memo&memoid='.$data_sm->id_sm.'&act=disposisi" class="btn btn-danger"> Disposisi <i class="ace-icon fa fa-share align-top bigger-125 icon-on-right"></i></a></li></ul>';
}
}
?>
<ul class="pager"><?php
if($data_sm->file != ''){?>
<li class="previous">
<a href="./berkas/<?php echo $data_sm->file;?>" target="_blank" class="btn btn-primary">Lihat Surat<i class="ace-icon fa fa-file-pdf-o align-top bigger-125 icon-on-right"></i></a>
</li><?php
}
if($HakAkses->sm == "W" and $data_sm->id_user == $_SESSION['id_user'] and $data_sm->status_draft == '0'){?>
<li class="next">
<a href="./index.php?op=add_sm&smid=<?php echo $data_sm->id_sm;?>" class="btn btn-danger"> Edit Surat <i class="ace-icon fa fa-pencil align-top bigger-125 icon-on-right"></i></a>
</li> <?php
} ?>
</ul>
</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>
Data Surat masuk tidak ditemukan. Terimakasih.
</p>
<p>
<a href="./index.php?op=sm"><button class="btn btn-minier btn-danger">Kembali</button></a>
</p>
</div><?php
}?>