<!DOCTYPE html>
<html lang="en">
	<head>
		<?php $this->load->view('main/head');?>
		<!-- bootstrap & fontawesome -->
		<link rel="stylesheet" href="dek/assets/css/bootstrap.css" />
		<link rel="stylesheet" href="dek/assets/css/font-awesome.css" />

		<!-- page specific plugin styles -->		

		<!-- text fonts -->
		<link rel="stylesheet" href="dek/assets/css/ace-fonts.css" />

		<!-- ace styles -->
		<link rel="stylesheet" href="dek/assets/css/ace.css" class="ace-main-stylesheet" id="main-ace-style" />
		
		<!-- ace settings handler -->
		<script src="dek/assets/js/ace-extra.js"></script>
	</head>

	<body class="no-skin">
		<!-- #section:basics/navbar.layout -->
		<?php $this->load->view('main/menu_ndhuwur');?>

		<!-- /section:basics/navbar.layout -->
		<div class="main-container" id="main-container">
			<script type="text/javascript">
				try{ace.settings.check('main-container' , 'fixed')}catch(e){}
			</script>

			<!-- #section:basics/sidebar.horizontal -->
			<?php $this->load->view('main/top_menu');?>

			<!-- /section:basics/sidebar.horizontal -->
			<div class="main-content">
				<div class="main-content-inner">
					<div class="page-content">
						<!-- #section:settings.box -->
						
						<!-- /section:settings.box -->
						<div class="page-header">
							<h1>
								Rekap Tagihan Pasien
								<small>
									<i class="ace-icon fa fa-angle-double-right"></i>
									Sub <i class="ace-icon fa fa-angle-double-right"></i> sub sub
								</small>
							</h1>
						</div><!-- /.page-header -->

						<div class="row">
							<div class="col-xs-12">
								<!-- PAGE CONTENT BEGINS -->
								<form class="form-horizontal" action="pasien-dalam-perawatan.html" method="post" role="form">
									<!-- #section:elements.form -->
									<div class="form-group">
										<label class="col-sm-3 control-label no-padding-right" for="form-field-1">Penjamin </label>

										<div class="col-sm-2">
											<select name="penjamnin" class=" form-control" data-placeholder="Choose a Country...">
												<option value="">Semua</option>
												<option value="0">Umum</option>
												<option value="1">BPJS</option>	
												<option value="2">Asuransi Lainnya</option>	
											</select>
										</div>
										<button class="btn btn-info btn-sm" type="submit" name="bProses">
												<i class="ace-icon fa fa-gear bigger-110"></i>
												Proses
										</button>
									</div>

									<!--div class="form-group">
										<label class="col-sm-3 control-label no-padding-right" for="form-field-1-1"> Tanggal Periode </label>

										<div class="col-sm-3">
											<div class="input-group">
												<input name="tglawal" class="form-control date-picker" id="id-date-picker-1" type="text" data-date-format="yyyy-mm-dd" />
												<span class="input-group-addon">
													<i class="fa fa-calendar bigger-110"></i>
												</span>
											</div>
										</div>
										<div class="col-sm-1 text-center"><span>s/d</span></div>
										<div class="col-sm-3">
											<div class="input-group">
												<input name="tglakhir"class="form-control date-picker" id="id-date-picker-1" type="text" data-date-format="yyyy-mm-dd" />
												<span class="input-group-addon">
													<i class="fa fa-calendar bigger-110"></i>
												</span>
											</div>
										</div>
											
									</div-->	
														
									
									<!--div class="clearfix ">
										<div class="col-md-offset-3 col-md-9">
										<button class="btn btn-info btn-sm" type="submit" name="bProses">
												<i class="ace-icon fa fa-gear bigger-110"></i>
												Proses
										</button>
										</div>
									</div-->
									<!--div class="clearfix ">
										<div class="col-md-offset-3 col-md-9">
											<button class="btn btn-info btn-sm" type="submit">
												<i class="ace-icon fa fa-gear bigger-110"></i>
												Proses
											</button>

											&nbsp; &nbsp; &nbsp;
											<button class="btn btn-sm btn-warning" type="reset">
												<i class="ace-icon fa fa-undo bigger-110"></i>
												Reset
											</button>
										</div>
									</div-->
								</form>
								<hr />
						<?php if(isset($_POST['bProses'])){ ?>
								<div class="row">
									<div class="col-xs-12">
										<h3 class="header smaller lighter blue text-center">Rekap Tagihan  Pasien Rawat Inap <?php echo $nmpenjamin;?><br>
										Dalam Perawatan
										</h3>
											
										<!--div class="clearfix">
											
											<div class="pull-right" style="margin-right:20px; padding-bottom:20px;"> 
												<form action="exptoexcel-rekap-kunjungan.html" method="post" >
												<input type="hidden" value="<?php //echo $_POST['statusx'];?>" name="statusx">
												<input type="hidden" value="<?php //echo $_POST['followup'];?>" name="followup">
												<input type="hidden" value="<?php //echo $_POST['tglawal'];?>" name="tglawal">
												<input type="hidden" value="<?php //echo $_POST['tglakhir'];?>" name="tglakhir">
												<button class="btn btn-xs btn-success"> Exsport to Excel</button>
												</form>
											</div>
										</div-->
										<?php if($this->session->flashdata('error')!=''):?>
										<div class="alert alert-danger">
											<button type="button" class="close" data-dismiss="alert">
												<i class="ace-icon fa fa-times"></i>
											</button>
											<strong>
												<i class="ace-icon fa fa-times"></i>
												Pesan Kesalahan, 
											</strong>
											<?php echo $this->session->flashdata('error');?>
											<br />
										</div>
										<?php endif;?>
										<?php if($this->session->flashdata('pesan')!=''):?>
										<div class="alert alert-success">
											<button type="button" class="close" data-dismiss="alert">
												<i class="ace-icon fa fa-times"></i>
											</button>
											<strong>
												<i class="ace-icon fa fa-times"></i>
												Pesan,
											</strong>
											<?php echo $this->session->flashdata('pesan');?>
											<br />
										</div>
										<?php endif;?>
										<div class="table-header">
											Data Pasien
										</div>

										<!-- div.table-responsive -->

										<!-- div.dataTables_borderWrap -->
										<div>
											<table id="" class="table table-striped table-bordered table-hover">
												<thead>
													<tr>
														<th>No</th>
														<th class="hidden-480">Tgl Masuk</th>
														<th class="hidden-480">No RM</th>
														<th>Nama</th>
														<th class="hidden-480">Jaminan</th>
														<th>Tagihan</th>
														<th class="hidden-480">DP</th>
														<th class="hidden-480">Sisa</th>														
														<!--th>Tgl Update</th>														
														<th>Petugas</th>														
														<!--th></th-->														
													</tr>
												</thead>

												<tbody>
												<?php $no=1;
												 $tottag=0;$totdp=0;$totsisa=0;
												foreach($databayar as $dtk){ 
													
													$tottag=$tottag+$dtk->totbayar; 
													$totdp=$totdp+$dtk->DP; 
													$totsisa=$tottag - $totdp;
												?>
													<tr>
														<td><?php echo $no;?></td>
														<td class="hidden-480"><?php echo tgl_id_short($dtk->TanggalMasuk);?></td>
														<td class="hidden-480"><?php echo $dtk->NoRM;?></td>
														<td class=""><?php echo $dtk->Nama;?></td>
														<td class="hidden-480"><?php echo $dtk->ket;?></td>
														<td class=""><?php echo number_format($dtk->totbayar,0);?></td>
														<td class="hidden-480"><?php echo number_format($dtk->DP,0);?></td>
														<td class="hidden-480"><?php echo number_format($dtk->totbayar - $dtk->DP,0);?></td>
														<!--td class="hidden-480"><?php //echo tgl_id_short($dtk->TanggalMasuk);?></td>
														<td class="hidden-480"><?php //echo $dtk->user;?></td>

														<!--td>
															<div class="hidden-sm hidden-xs action-buttons">																
																<a class="green ranap" href="#modal-table" data-toggle="modal" data-idkamar="<?php //echo $dtk->ID;?>">
																	<i class="ace-icon fa fa-pencil bigger-130 tooltip-dark" data-rel="tooltip" data-placement="top" title="Ubah"></i>
																</a>

																<a class="red" href="#">
																	<i class="ace-icon fa fa-trash-o bigger-130 tooltip-danger" data-rel="tooltip" data-placement="top" title="Hapus"></i>
																</a>
															</div>
														</td-->
													</tr>
												<?php $no++; } ?>
													<tr style="color:#b30000;font-size:1.1em">
														<td colspan="5" class="text-center hidden-sm hidden-xs"><strong>Total</strong></td>
														<td colspan="2" class="text-center hidden-md hidden-lg"><strong>Total</strong></td>
														<td><strong><?php echo number_format($tottag,0);?></strong></td>
														<td class="hidden-480"><strong><?php echo number_format($totdp,0);?></strong></td>
														<td class="hidden-480"><strong><?php echo number_format($totsisa,0);?></strong></td>
													</tr>
												</tbody>
											</table>
										</div>
									</div>
								</div>
						<?php } ?>
								<!-- PAGE CONTENT ENDS -->
								<div id="modal-table" class="modal fade" tabindex="-1">
									<div class="modal-dialog">
										<div class="modal-content">
											<div class="modal-header no-padding">
												<div class="table-header">
													<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
														<span class="white">&times;</span>
													</button>
													Ubah Data Kamar Rawat Inap
												</div>
											</div>

											<form class="form-horizontal" action="save-perubahan-kamar.html" id="validation-form" method="post">
											<div class="modal-body">
												
												<div class="space-1"></div>

												<div class="form-group">
													<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="password">Nama Kamar:</label>

													<div class="col-xs-12 col-sm-6">
														<div class="clearfix">
															<input type="hidden" name="idkamar" id="idk" value="" class="col-xs-12" />
															<input type="text" name="kamar" id="kamar" value="" class="col-xs-12" readonly />
														</div>
													</div>
												</div>
												<div class="form-group">
													<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="password">Kapasitas:</label>

													<div class="col-xs-12 col-sm-3">
														<div class="clearfix">
															<input type="text" name="kapasitas" id="kapasitas" value="" class="col-xs-12" />
														</div>
													</div>
												</div>
												
												<div class="space-1"></div>

												<div class="form-group">
													<label class="control-label col-xs-12 col-sm-3 no-padding-right" for="password">Terisi:</label>

													<div class="col-xs-12 col-sm-3">
														<div class="clearfix">
															<input type="text" name="terisi" id="terisi" value="" class="col-xs-12" />
														</div>
													</div>
												</div>
												
											</div>

											<div class="modal-footer no-margin-top">
												<button class="btn btn-sm btn-success pull-left">
													<i class="ace-icon fa fa-save"></i>
													Simpan Perubahan
												</button>
												<button class="btn btn-sm btn-danger pull-left" data-dismiss="modal">
													<i class="ace-icon fa fa-times"></i>
													Close
												</button>
											</div>
											</form>
										</div><!-- /.modal-content -->
									</div><!-- /.modal-dialog -->
								</div><!-- Modal endS -->
							</div><!-- /.col -->
						</div><!-- /.row -->
					</div><!-- /.page-content -->
				</div>
			</div><!-- /.main-content -->

			<?php $this->load->view('main/footer');?>

			<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
				<i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
			</a>
		</div><!-- /.main-container -->

		<!--[if !IE]> -->
		<script type="text/javascript">
			window.jQuery || document.write("<script src='dek/assets/js/jquery.js'>"+"<"+"/script>");
		</script>

		<!-- <![endif]-->

		<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='dek/assets/js/jquery1x.js'>"+"<"+"/script>");
</script>
<![endif]-->
		<script type="text/javascript">
			if('ontouchstart' in document.documentElement) document.write("<script src='dek/assets/js/jquery.mobile.custom.js'>"+"<"+"/script>");
		</script>
		<script src="dek/assets/js/bootstrap.js"></script>

		<!-- page specific plugin scripts -->
		<script src="dek/assets/js/dataTables/jquery.dataTables.js"></script>
		<script src="dek/assets/js/dataTables/jquery.dataTables.bootstrap.js"></script>
		<script src="dek/assets/js/dataTables/extensions/TableTools/js/dataTables.tableTools.js"></script>
		<script src="dek/assets/js/dataTables/extensions/ColVis/js/dataTables.colVis.js"></script>

		<!-- ace scripts -->
		<script src="dek/assets/js/ace/elements.scroller.js"></script>
		<script src="dek/assets/js/ace/elements.colorpicker.js"></script>
		<script src="dek/assets/js/ace/elements.fileinput.js"></script>
		<script src="dek/assets/js/ace/elements.typeahead.js"></script>
		<script src="dek/assets/js/ace/elements.wysiwyg.js"></script>
		<script src="dek/assets/js/ace/elements.spinner.js"></script>
		<script src="dek/assets/js/ace/elements.treeview.js"></script>
		<script src="dek/assets/js/ace/elements.wizard.js"></script>
		<script src="dek/assets/js/ace/elements.aside.js"></script>
		<script src="dek/assets/js/ace/ace.js"></script>
		<script src="dek/assets/js/ace/ace.ajax-content.js"></script>
		<script src="dek/assets/js/ace/ace.touch-drag.js"></script>
		<script src="dek/assets/js/ace/ace.sidebar.js"></script>
		<script src="dek/assets/js/ace/ace.sidebar-scroll-1.js"></script>
		<script src="dek/assets/js/ace/ace.submenu-hover.js"></script>
		<script src="dek/assets/js/ace/ace.widget-box.js"></script>
		<script src="dek/assets/js/ace/ace.settings.js"></script>
		<script src="dek/assets/js/ace/ace.settings-rtl.js"></script>
		<script src="dek/assets/js/ace/ace.settings-skin.js"></script>
		<script src="dek/assets/js/ace/ace.widget-on-reload.js"></script>
		<script src="dek/assets/js/ace/ace.searchbox-autocomplete.js"></script>

		<!-- inline scripts related to this page -->
		<script type="text/javascript">
			jQuery(function($) {
				//initiate dataTables plugin
				var oTable1 = 
				$('#dynamic-table')
				//.wrap("<div class='dataTables_borderWrap' />")   //if you are applying horizontal scrolling (sScrollX)
				.dataTable( {
					bAutoWidth: false,
					"aoColumns": [
					  { "bSortable": false },
					  null, null,null,null,null,null
					],
					"aaSorting": [],
			
					//,
					//"sScrollY": "200px",
					//"bPaginate": false,
			
					//"sScrollX": "100%",
					//"sScrollXInner": "120%",
					//"bScrollCollapse": true,
					//Note: if you are applying horizontal scrolling (sScrollX) on a ".table-bordered"
					//you may want to wrap the table inside a "div.dataTables_borderWrap" element
			
					//"iDisplayLength": 50
			    } );
				//oTable1.fnAdjustColumnSizing();
			
			
				//TableTools settings
				TableTools.classes.container = "btn-group btn-overlap";
				TableTools.classes.print = {
					"body": "DTTT_Print",
					"info": "tableTools-alert gritter-item-wrapper gritter-info gritter-center white",
					"message": "tableTools-print-navbar"
				}
			
				//initiate TableTools extension
				var tableTools_obj = new $.fn.dataTable.TableTools( oTable1, {
					"sSwfPath": "dek/assets/js/dataTables/extensions/TableTools/swf/copy_csv_xls_pdf.swf", //in Ace demo dek/assets will be replaced by correct assets path
					
					"sRowSelector": "td:not(:last-child)",
					"sRowSelect": "multi",
					"fnRowSelected": function(row) {
						//check checkbox when row is selected
						try { $(row).find('input[type=checkbox]').get(0).checked = true }
						catch(e) {}
					},
					"fnRowDeselected": function(row) {
						//uncheck checkbox
						try { $(row).find('input[type=checkbox]').get(0).checked = false }
						catch(e) {}
					},
			
					"sSelectedClass": "success",
			        "aButtons": [
						{
							"sExtends": "copy",
							"sToolTip": "Copy to clipboard",
							"sButtonClass": "btn btn-white btn-primary btn-bold",
							"sButtonText": "<i class='fa fa-copy bigger-110 pink'></i>",
							"fnComplete": function() {
								this.fnInfo( '<h3 class="no-margin-top smaller">Table copied</h3>\
									<p>Copied '+(oTable1.fnSettings().fnRecordsTotal())+' row(s) to the clipboard.</p>',
									1500
								);
							}
						},
						
						{
							"sExtends": "csv",
							"sToolTip": "Export to CSV",
							"sButtonClass": "btn btn-white btn-primary  btn-bold",
							"sButtonText": "<i class='fa fa-file-excel-o bigger-110 green'></i>"
						},
						
						{
							"sExtends": "pdf",
							"sToolTip": "Export to PDF",
							"sButtonClass": "btn btn-white btn-primary  btn-bold",
							"sButtonText": "<i class='fa fa-file-pdf-o bigger-110 red'></i>"
						},
						
						{
							"sExtends": "print",
							"sToolTip": "Print view",
							"sButtonClass": "btn btn-white btn-primary  btn-bold",
							"sButtonText": "<i class='fa fa-print bigger-110 grey'></i>",
							
							"sMessage": "<div class='navbar navbar-default'><div class='navbar-header pull-left'><a class='navbar-brand' href='#'><small>Optional Navbar &amp; Text</small></a></div></div>",
							
							"sInfo": "<h3 class='no-margin-top'>Print view</h3>\
									  <p>Please use your browser's print function to\
									  print this table.\
									  <br />Press <b>escape</b> when finished.</p>",
						}
			        ]
			    } );
				//we put a container before our table and append TableTools element to it
			    $(tableTools_obj.fnContainer()).appendTo($('.tableTools-container'));
				
				//also add tooltips to table tools buttons
				//addding tooltips directly to "A" buttons results in buttons disappearing (weired! don't know why!)
				//so we add tooltips to the "DIV" child after it becomes inserted
				//flash objects inside table tools buttons are inserted with some delay (100ms) (for some reason)
				setTimeout(function() {
					$(tableTools_obj.fnContainer()).find('a.DTTT_button').each(function() {
						var div = $(this).find('> div');
						if(div.length > 0) div.tooltip({container: 'body'});
						else $(this).tooltip({container: 'body'});
					});
				}, 200);
				
				
				
				//ColVis extension
				var colvis = new $.fn.dataTable.ColVis( oTable1, {
					"buttonText": "<i class='fa fa-search'></i>",
					"aiExclude": [0, 6],
					"bShowAll": true,
					//"bRestore": true,
					"sAlign": "right",
					"fnLabel": function(i, title, th) {
						return $(th).text();//remove icons, etc
					}
					
				}); 
				
				//style it
				$(colvis.button()).addClass('btn-group').find('button').addClass('btn btn-white btn-info btn-bold')
				
				//and append it to our table tools btn-group, also add tooltip
				$(colvis.button())
				.prependTo('.tableTools-container .btn-group')
				.attr('title', 'Show/hide columns').tooltip({container: 'body'});
				
				//and make the list, buttons and checkboxed Ace-like
				$(colvis.dom.collection)
				.addClass('dropdown-menu dropdown-light dropdown-caret dropdown-caret-right')
				.find('li').wrapInner('<a href="javascript:void(0)" />') //'A' tag is required for better styling
				.find('input[type=checkbox]').addClass('ace').next().addClass('lbl padding-8');
			
			
				
				/////////////////////////////////
				//table checkboxes
				$('th input[type=checkbox], td input[type=checkbox]').prop('checked', false);
				
				//select/deselect all rows according to table header checkbox
				$('#dynamic-table > thead > tr > th input[type=checkbox]').eq(0).on('click', function(){
					var th_checked = this.checked;//checkbox inside "TH" table header
					
					$(this).closest('table').find('tbody > tr').each(function(){
						var row = this;
						if(th_checked) tableTools_obj.fnSelect(row);
						else tableTools_obj.fnDeselect(row);
					});
				});
				
				//select/deselect a row when the checkbox is checked/unchecked
				$('#dynamic-table').on('click', 'td input[type=checkbox]' , function(){
					var row = $(this).closest('tr').get(0);
					if(!this.checked) tableTools_obj.fnSelect(row);
					else tableTools_obj.fnDeselect($(this).closest('tr').get(0));
				});
				
			
				
				
					$(document).on('click', '#dynamic-table .dropdown-toggle', function(e) {
					e.stopImmediatePropagation();
					e.stopPropagation();
					e.preventDefault();
				});
				
				
				//And for the first simple table, which doesn't have TableTools or dataTables
				//select/deselect all rows according to table header checkbox
				var active_class = 'active';
				$('#simple-table > thead > tr > th input[type=checkbox]').eq(0).on('click', function(){
					var th_checked = this.checked;//checkbox inside "TH" table header
					
					$(this).closest('table').find('tbody > tr').each(function(){
						var row = this;
						if(th_checked) $(row).addClass(active_class).find('input[type=checkbox]').eq(0).prop('checked', true);
						else $(row).removeClass(active_class).find('input[type=checkbox]').eq(0).prop('checked', false);
					});
				});
				
				//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(this.checked) $row.addClass(active_class);
					else $row.removeClass(active_class);
				});
			
				
			
				/********************************/
				//add tooltip for small view action buttons in dropdown menu
				$('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
				
				//tooltip placement on right or left
				function tooltip_placement(context, source) {
					var $source = $(source);
					var $parent = $source.closest('table')
					var off1 = $parent.offset();
					var w1 = $parent.width();
			
					var off2 = $source.offset();
					//var w2 = $source.width();
			
					if( parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2) ) return 'right';
					return 'left';
				}
			
			})
		</script>

		<!-- the following scripts are used in demo only for onpage help and you don't need them -->
		<link rel="stylesheet" href="dek/assets/css/ace.onpage-help.css" />
		<link rel="stylesheet" href="dek/docs/assets/js/themes/sunburst.css" />

		<script type="text/javascript"> ace.vars['base'] = '..'; </script>
		<script src="dek/assets/js/ace/elements.onpage-help.js"></script>
		<script src="dek/assets/js/ace/ace.onpage-help.js"></script>
		<script src="dek/docs/assets/js/rainbow.js"></script>
		<script src="dek/docs/assets/js/language/generic.js"></script>
		<script src="dek/docs/assets/js/language/html.js"></script>
		<script src="dek/docs/assets/js/language/css.js"></script>
		<script src="dek/docs/assets/js/language/javascript.js"></script>
		
		<script>
			$( ".ranap" ).click( function() {
				var idkamar = $( this ).data( "idkamar" );
				$.post("get-datakamar.html", { idkamar: idkamar, ajax: 'true' }, function( data ) {
					var konten = '';
					if(data.length > 0)
					{						
						$.each( data, function ( key, val ) {
							$("#idk").attr('value',val.ID);
							$("#kamar").attr('value',val.NamaKamar);
							$("#kapasitas").attr('value',val.Kapasitas);
							$("#terisi").attr('value',val.terisi);
							//$("#satuan").text(val.nm_satuan);				
							//$("#tgli_hidden").attr('value', val.tgl_absensi);
							
						} );
						
					}
					else
					{
						konten += 'Belum dikonfirmasi!';
					}
					
				}, "json") 
			});
		</script>
	</body>
</html>
