Blame view

view/view_doc.php 14.1 KB
Maulyanda authored
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
<div class="row">
	<div class="col-xs-12">
		<!-- PAGE CONTENT BEGINS -->
		<div class="row">
			<div class="col-xs-12"><?php
				if(isset($_GET['smid'])){
					require_once "view_doc_detail_sekretaris.php";
				}else{
					/* PAGINATION */
					$batas = 15;
					$pg = isset( $_GET['halaman'] ) ? $_GET['halaman'] : "";
					if(empty($pg)){
						$posisi = 0;
						$pg = 1;
					}else{
						$posisi = ($pg-1) * $batas;
					}
					/* END PAGINATION */
					if(isset($_GET['keyword'])){
						$keyword = "%".$_GET['keyword']."%";
						$params = array(':noref' => $keyword, ':no_sm' => $keyword, ':asal_sm' => $keyword, ':perihal' => $keyword);
						$arsip_sm = $this->model->selectprepare("surat_dokumen", $field=null, $params, "no_sm LIKE :no_sm OR asal_sm LIKE :asal_sm 
							OR (SELECT (CONCAT(b.kode_masalah, '.', b.primer, '.', b.sekunder, '/', c.kode1, '.', c.kode2, '.', lpad(a.no_agenda,5,'0'), '/', DATE_FORMAT(a.tgl_agenda, '%Y'))) as noref FROM surat_masuk a left join kode_masalah b ON b.id = a.kodemasalahid left join unit_kerja c ON c.id = a.unitkerjaid WHERE a.id_sm = surat_masuk.id_sm) LIKE :noref 
							OR perihal LIKE :perihal OR no_sm LIKE :no_sm", "order by tgl_agenda DESC LIMIT $posisi, $batas");
						$arsip_sm2 = $this->model->selectprepare("surat_dokumen", $field=null, $params, "no_sm LIKE :no_sm OR asal_sm LIKE :asal_sm 
							OR (SELECT (CONCAT(b.kode_masalah, '.', b.primer, '.', b.sekunder, '/', c.kode1, '.', c.kode2, '.', lpad(a.no_agenda,5,'0'), '/', DATE_FORMAT(a.tgl_agenda, '%Y'))) as noref FROM surat_masuk a left join kode_masalah b ON b.id = a.kodemasalahid left join unit_kerja c ON c.id = a.unitkerjaid WHERE a.id_sm = surat_masuk.id_sm) LIKE :noref 
							OR perihal LIKE :perihal OR no_sm LIKE :no_sm", $other=null);
					}else{
						$field = array("id_sm","DATE_FORMAT(tgl_agenda, '%Y') as thn");
						$lastData = $this->model->selectprepare("surat_dokumen", $field, $params=null, $where=null, "GROUP BY DATE_FORMAT(tgl_agenda, '%Y') order by DATE_FORMAT(tgl_agenda, '%Y') DESC LIMIT 1");
						$dataLast = $lastData->fetch(PDO::FETCH_OBJ);
						if(isset($_GET['yearsm'])){
							$params = array(':year' => $_GET['yearsm']);
						}else{
							$params = array(':year' => $dataLast->thn);
						}
						$arsip_sm = $this->model->selectprepare("surat_dokumen", $field=null, $params, "DATE_FORMAT(tgl_agenda, '%Y')=:year", "order by tgl_agenda DESC LIMIT $posisi, $batas");
						$arsip_sm2 = $this->model->selectprepare("surat_dokumen", $field=null, $params, "DATE_FORMAT(tgl_agenda, '%Y')=:year", "order by tgl_agenda DESC");
					}
					if($arsip_sm->rowCount() >= 1){
						while($data_sm = $arsip_sm->fetch(PDO::FETCH_OBJ)){
							$dump_sm[]=$data_sm;
						}?>
						<!--Modal Preview PDF-->
						<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
							<div class="modal-dialog modal-lg">
								<div class="modal-content">
									<div class="modal-header">
										<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
										<h4 class="modal-title" id="myModalLabel">Preview Surat Dokumen</h4>
									</div>
									<div class="modal-body" style="height: 450px;"></div>
									<div class="modal-footer">
										<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
									</div>
								</div>
							</div>
						</div>
						<?php if($HakAkses->doc == "W"){ ?>
							<a href="./index.php?op=add_doc" title="Tambah Surat Dokumen">
								<button class="btn btn-white btn-info btn-bold">
									<i class="ace-icon glyphicon glyphicon-plus"></i>Tambah Dokumen
								</button>
							</a>
						<?php } ?>
						<table id="simple-table" class="table  table-bordered table-hover">
							<thead>
								<tr>
									<th width="50">No</th>
									<th width="200">No Agenda</th>
									<th>Perihal</th>									
									<th width="120">Tgl Terima</th>									
									<th class="detail-col">Details</th>
									<th width="100">Aksi</th>
								</tr>
							</thead>
							<tbody><?php
								$no=1+$posisi;
								foreach($dump_sm as $key => $object){
									$params = array(':id_sm' => $object->id_sm, ':status' => '2');
									$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");
									$tgltrm = explode("-", $object->tgl_terima);
									$tgltrm = $tgltrm[2]."-".$tgltrm[1]."-".$tgltrm[0];
									$tujuan = json_decode($object->tujuan_surat, true);
									
									$params = array(':id_sm' => $object->id_sm, ':kode' => 'SM');
									$lihat_sm = $this->model->selectprepare("surat_read", $field=null, $params, "id_sm=:id_sm AND kode=:kode");
									if($lihat_sm->rowCount() <= 0){
										$labelstatus = "";
									}else{
										$labelstatus = "<i class=\"ace-icon fa fa-check bigger-110 green\" title=\"was read\"></i>";
									}
									
									$params1 = array(':id_sm' => $object->id_sm, ':status' => '2');
									$CekStatFinish = $this->model->selectprepare("status_surat a join user b on a.id_user=b.id_user", $field=null, $params1, "a.id_sm=:id_sm AND a.status=:status", "ORDER BY a.id_status DESC LIMIT 1");
									if($CekStatFinish->rowCount() >= 1){
										$dataCekStatFinish = $CekStatFinish->fetch(PDO::FETCH_OBJ);
										if($dataCekStatFinish->statsurat == 1){
											$ProgresStat = " <i class=\"ace-icon fa fa-history bigger-110 green\" title=\"Surat sedang ditindaklanjuti\"></i>";
										}elseif($dataCekStatFinish->statsurat == 2){
											$ProgresStat = " <i class=\"ace-icon fa fa-thumbs-o-up bigger-110 green\" title=\"Surat sudah selesai ditindaklanjuti\"></i>";
										}elseif($dataCekStatFinish->statsurat == 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>";
									}
									
									if($cekDisposisi->rowCount() >= 1){
										//$data_cek = $cek_memo->fetch(PDO::FETCH_OBJ);
										$labelDis = " <i class=\"ace-icon fa fa-share bigger-110 green\" title=\"Telah di Disposisi\"></i>";
									}else{
										$labelDis = "";
									}?>
									<tr>
										<td><?php echo $no;?></td>
										<td>
											<a href="./index.php?op=doc&smid=<?php echo $object->id_sm;?>"><?php echo $this->model->noref_doc($object->id_sm); ?></a>
											<?php echo $labelstatus;?>
											<?php echo $labelDis;?>
											<?php echo $ProgresStat;?>
										</td>
										<td><?php echo $object->perihal;?></td>										
										<td><?php echo $tgltrm;?></td>										
										<td class="center">
											<div class="action-buttons">
												<a href="#" class="green bigger-140 show-details-btn" title="Show Details">
													<i class="ace-icon fa fa-angle-double-down"></i>
													<span class="sr-only">Details</span>
												</a>
											</div>
										</td>
										<td align="center">
											<?php if($HakAkses->doc == "W"){ ?>
											<div class="hidden-sm hidden-xs btn-group">
												<a href="./index.php?op=add_doc&smid=<?php echo $object->id_sm;?>">								
													<button class="btn btn-minier btn-info">
														<i class="ace-icon fa fa-pencil bigger-100"></i>
													</button>
												</a>
												<?php if($_SESSION['id_user'] == '1'){?>
													<a href="./index.php?op=doc&smid=<?php echo $object->id_sm;?>&act=del" onclick="return confirm('Anda yakin akan menghapus data ini??')">
														<button class="btn btn-minier btn-danger">
															<i class="ace-icon fa fa-trash-o bigger-110"></i>
														</button>
													</a>
												<?php } ?>
											</div>
											<?php } ?>										
										</td>
									</tr>
									<tr class="detail-row">
										<td colspan="12">
											<div class="table-detail">
												<div class="row">
													<div class="col-xs-12 col-sm-12">
														<div class="space visible-xs"></div>
														<div class="profile-user-info profile-user-info-striped">
															<div class="profile-info-row">
																<div class="profile-info-name"> No Agenda </div>
																<div class="profile-info-value"><span><a href="./index.php?op=doc&smid=<?php echo $object->id_sm;?>"><?php echo $this->model->noref_doc($object->id_sm);?></a></span></div>
															</div>
															<div class="profile-info-row">
																<div class="profile-info-name"> Tgl Agenda </div>
																<div class="profile-info-value"><span><?php echo explode_tanggal($object->tgl_agenda);?></span></div>
															</div>
															<div class="profile-info-row">
																<div class="profile-info-name"> Perihal </div>
																<div class="profile-info-value"><span><?php echo $object->perihal;?></span></div>
															</div>
															<div class="profile-info-row">
																<div class="profile-info-name"> Tanggal Terima </div>
																<div class="profile-info-value"><span><?php echo $tgltrm;?></span></div>
															</div>
															<div class="profile-info-row">
																<div class="profile-info-name"> File Surat </div>
																<div class="profile-info-value">
																	<span><?php 
																		if($object->file != ""){?>
																			<a href="./berkas/<?php echo $object->file;?>" target="_blank">Lihat File Surat</a><?php
																		}else{ ?>
																			- <?php
																		}?>
																	</span>
																</div>
															</div>
															<div class="profile-info-row">
																<div class="profile-info-name"> Tujuan </div>
																<div class="profile-info-value"><span>
																	<?php 
																	if(is_array($tujuan)){
																		foreach($tujuan 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 id_user='".$value."' ")->fetch(PDO::FETCH_OBJ);
																			echo '- '.$GetUserDis->nama.' ('.$GetUserDis->unit_kerja.') <br/>';
																		}
																	}?>
																</span></div>
															</div>
														</div>
													</div>
												</div>
											</div>
										</td>
									</tr><?php
								$no++;
								}?>
							</tbody>
						</table><?php
					}else{
						if($HakAkses->doc == "W"){ ?>
							<a href="./index.php?op=add_doc" title="Tambah Surat Dokumen">
								<button class="btn btn-white btn-info btn-bold">
									<i class="ace-icon glyphicon glyphicon-plus"></i>Tambah Surat
								</button>
							</a>
						<?php } ?>
						<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 tidak ditemukan. Terimakasih.
							</p>
						</div><?php
					}
					/* PAGINATION */
					//hitung jumlah data
					if(isset($_GET['keyword'])){
						$jml_data = $arsip_sm2->rowCount();
						$link_order="&keyword=$_GET[keyword]";
					}else{
						if(isset($_GET['yearsm'])){
							$params = array(':year' => $_GET['yearsm']);
							$link_order="&yearsm=$_GET[yearsm]";
						}else{
							$params = array(':year' => $dataLast->thn);
							$link_order="";
						}
						//$jlhdata = $this->model->selectprepare("surat_dokumen", $field=null, $params, "DATE_FORMAT(tgl_agenda, '%Y')=:year", $other=null);
						$jml_data = $arsip_sm2->rowCount();
					}
					//Jumlah halaman
					$JmlHalaman = ceil($jml_data/$batas); 
					//Navigasi ke sebelumnya
					if($pg > 1){
						$link = $pg-1;
						$prev = "index.php?op=doc&halaman=$link$link_order";
						$prev_disable = " ";
					}else{
						$prev = "#";
						$prev_disable = "disabled";
					}
					//Navigasi ke selanjutnya
					if($pg < $JmlHalaman){
						$link = $pg + 1;
						$next = "index.php?op=doc&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;?>">&larr; Sebelumnya </a></li>
							<li class="next <?php echo $next_disable;?>"><a href="<?php echo $next;?>">Selanjutnya &rarr;</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 */
				}
			//}?>
						
			</div><!-- /.span -->
		</div><!-- /.row -->
		<!-- PAGE CONTENT ENDS -->
	</div><!-- /.col -->
</div><!-- /.row -->
		
<script src="assets/js/jquery-2.1.4.min.js"></script>

<!-- page specific plugin scripts -->
<script src="assets/js/jquery.dataTables.min.js"></script>
<script src="assets/js/jquery.dataTables.bootstrap.min.js"></script>
<script src="assets/js/dataTables.buttons.min.js"></script>
<script src="assets/js/buttons.flash.min.js"></script>
<script src="assets/js/buttons.html5.min.js"></script>
<script src="assets/js/buttons.print.min.js"></script>
<script src="assets/js/buttons.colVis.min.js"></script>
<script src="assets/js/dataTables.select.min.js"></script>

<!-- inline scripts related to this page -->
<script type="text/javascript">
	jQuery(function($) {				
		//select/deselect a row when the checkbox is checked/unchecked
		$('#simple-table').on('click', 'td input[type=checkbox]' , function(){
			var $row = $(this).closest('tr');
			if($row.is('.detail-row ')) return;
			if(this.checked) $row.addClass(active_class);
			else $row.removeClass(active_class);
		});	
		
		/***************/
		$('.show-details-btn').on('click', function(e) {
			e.preventDefault();
			$(this).closest('tr').next().toggleClass('open');
			$(this).find(ace.vars['.icon']).toggleClass('fa-angle-double-down').toggleClass('fa-angle-double-up');
		});
		/***************/			
	})
</script>