<h1 class="page-header">
	<?php echo $judul;
	$a_date = date("Y-m-d");
	$last =  date("Y-m-t", strtotime($a_date));
	$query = $this->db->query("select sum(total) as total from mutasi where status='1'")->result_array(); 
	$query = $this->db->query("select sum(total) as total from mutasi where status='1' and date(tanggal)>='".date("Y-m")."-01'  and date(tanggal)<='$last' ")->result_array(); 
	$total =  $query[0]['total'];	
	?>
</h1> 
<div style='background:#2A0A01; padding:10px; color:#FFFFFF; font-size:20px; font-weight:bold;'>Total Mutasi : Rp. <?=number_format($total);?></div>
<div class="panel panel-default">
<div class="panel-heading">
	<div class="row">
		<div class='col-sm-6'><?php echo $judul;?> List</div>
		<div class='col-sm-6' align='right'>
			<a href="<?=$url?>mutasi-new" class="btn btn-success btn-md"><i class=" fa fa-plus"></i> Tambah</a>
		</div>
	</div>
</div>
<div class="panel-body">
	<div class="table-responsive">
		<table class="table table-striped table-bordered table-hover dataTables" >
			<thead>
				<tr>
					<th width='35'>No</th> 
					<th width='150'>No Mutasi</th> 
					<th width='150'>Tanggal</th> 
					<th>Tujuan</th> 
					<th>Keterangan</th> 
					<th width='100'>Total</th>  
					<th width='70'></th>
				</tr>
			</thead>
			<tbody>
				<?php
					$nos=1;
					if(isset($data) && count($data) > 0): foreach($data as $row):  
				?>
				<tr>
					<td align='center'><?=$nos;?></td> 
					<td align='left'><?=$row['no'];?></td> 
					<td align='left'><?=$row['tanggal'];?></td> 
					<td align='left'><?=$row['tujuan'];?></td> 
					<td align='left'><?=$row['keterangan'];?></td> 
					<td align='left'>Rp. <?=number_format($row['total']);?></td> 
 
					<td align='center'>
						<button type='button' title="View"  data-toggle="modal-<?=$no;?>" data-target="#myModal-<?=$nos;?>" class='btn btn-xs btn-success modal-view'><i class="fa fa-eye "></i></button>
						<a class='btn btn-xs btn-danger' onclick="return confirm('Are you sure you want to delete this item?');" href="<?=base_url()?>cms/logic/deletem/mutasi/<?=$row['id_mutasi']?>?part=mutasi" class="text-danger"><i class="fa fa-trash-o"></i></a>					
						<div id="myModal-<?=$nos;?>" class="modal fade" role="dialog">
						  <div class="modal-dialog">

							<div class="modal-content">
							  <div class="modal-header" style='padding:10px;background:#172D44; color:#FFFFFF;'>
								<button type="button" class="close" data-dismiss="modal" style='color:#FFFFFF;'>&times;</button>
								<h4 class="modal-title">Detil mutasi</h4>
							  </div>
							  <div class="modal-body">

<?php
		$item = $this->model_global->get_data(array(
			'select' => 'b.*,a.*, c.nama as satuan', 
			'table' => 'mutasi_item a',
			'join' => array('barang b','b.id_barang = a.id_barang'),
			'join2' => array('satuan c','c.id_satuan = b.id_satuan'), 
			'where' => array('a.status'=>1,'a.id_mutasi'=>$row['id_mutasi']), 
			'order_by' => 'b.nama asc'
		));		
		$isi = "<table width='100%'>";
		if(isset($item) && count($item) > 0):
		$no=1;
		foreach($item as $rows):
		
			$isi.="
				<tr>
					<td width='10' align='left' valign='top'>$no</td> 
					<td width='' style='padding-bottom:10px;'>
						$rows[nama]<br>
						&nbsp; $rows[qty] $rows[satuan] x ".number_format($rows['harga'])."
						
					</td>
					<td width='50' align='right' valign='top'>".number_format($rows['total'])."</td>
				</tr>
			";
			$no++;
		endforeach; endif;
		$isi.= "</table>";
		echo " 
			<style>
				@font-face {
					font-family: merchant;
					src: url(".base_url()."assets/webadmin/fonts/merchant.ttf);
				}
				@font-face {
					font-family: receipt;
					src: url(".base_url()."assets/webadmin/fonts/receipt.ttf);
				}
				.modal-body{
					padding:0px;
					margin:10px 0px;
					font-family:receipt;
					font-size:12px;
					color:#000000;
					letter-spacing:-1px;
				}
				.modal-body td,.modal-body p,.modal-body div{
					font-size:12px;
					font-family:receipt;
					/*font-family:'courier new';*/
				}
				p{
					margin:0px;padding:0px;
					line-height: 13px;
				}
				@media print{
					.cetak{display:none;}
				}
			</style>
			
			<div align='center'> 
				$row[no]<br>$row[tanggal]<br><br>
				Tujuan : $row[tujuan]
			</div>
			<div style='border-top:1px dashed #000000; margin:10px; padding:5px 0px;'>
				$isi
			</div> 
			<div style='border-top:1px dashed #000000;border-bottom:1px dashed #000000; margin:5px; padding:5px;'>
				<table width='100%'>
					<tr>
						<td></td>
						<td align='right' width='100'>Total</td><td width='10' align='center'>:</td>
						<td align='right' width='100'>Rp. ".number_format($row['total'])."</td>
					</tr> 
				</table>
			</div> 
			<div style='margin:5px; padding:5px; text-align:left;'>
				<em>*) : $row[keterangan]</em>
			</div> 
			
		";
?>							  
							  </div>
							  <div class="modal-footer" style='padding:10px;'> 
								<button type="button" class="btn btn-success cetak-ulangmutasi" data-dismiss="modal" data-id='<?=$row['id_mutasi'];?>'><i class='fa fa-print'></i> Cetak</button>
								<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
							  </div>
							</div>

						  </div>						
					</td>
				</tr>
				<?php $nos++; endforeach; endif; ?>
			</tbody>
		</table>
	</div>
</div>
</div>