<!DOCTYPE html>
<html lang="en">
<head>
	<?php $this->load->view("includes/header");?>
</head>

<body>
	<?php $this->load->view("includes/menu");?>
	
	<section class="content">
		<?php $this->load->view("includes/nav");?>
		
		<div class="wraper container-fluid xs_container-fluid">
			
			<div class="row">
				<div class="col-md-offset-2 col-md-8">
					<?php $this->load->view("includes/success_msg");?>
					
					<div class="panel panel-default xs_panel" style="padding-left: 10px; padding-right: 10px;">
						<div class="panel-heading">
							<center>
								<h3 class="panel-title">
									<i class="fa fa-user-circle fa-fw"></i>
									Creditor
								</h3> 
							</center>
							<div class="pull-left" style="margin-top: -20px;">
								<!--  -->
								<a href="<?php echo base_url($this->router->fetch_class()."/"."?".$this->session->flashdata($this->router->fetch_class().'_page_filter'));?>" class="visible-xs" style="margin-left: 10px; color: #797979;">
									<i class="fa fa-chevron-left"></i>
								</a>
								<a href="<?php echo base_url($this->router->fetch_class()."/"."?".$this->session->flashdata($this->router->fetch_class().'_page_filter'));?>" class="hidden-xs btn btn-primary btn-xs">
									<i class="fa fa-arrow-left"></i>
									Back
								</a>
								<!--  -->
							</div>
							<div class="pull-right" style="margin-top: -20px;">
								<!--  -->
								<div id="edit_div_action" class="dropdown" style="display: none;">
									<a href="javascript:;" data-toggle="dropdown" class="visible-xs edit_btn_action" style="margin-right: 10px; color: #797979;">
										<i class="fa fa-wrench fa-lg"></i>
									</a>
									<a href="javascript:;" data-toggle="dropdown" class="hidden-xs btn btn-primary btn-xs dropdown-toggle edit_btn_action">
										Action
									</a>
									<ul class="dropdown-menu extended pro-menu" style="left: auto; right: 0;">
										<li>
											<a href="#delete_modal" data-toggle="modal" class="btn_delete" style="display: none;" title="Delete">
												<i class="fa fa-trash-o"></i>
												Delete
											</a>
										</li>
									</ul>
								</div>
								<!--  -->
							</div>
						</div>
						<div class="panel-body">
							<div id="edit_ajax_container"><!-- AJAX --></div>
						</div>
					</div>
				</div>
			</div>
		</div>
	
		<!-- delete_modal -->
		<div id="delete_modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
			<div class="modal-dialog modal-sm">
				<div class="modal-content">
					<form onSubmit="disable_btn('.btn_submit');" action="<?php echo base_url($this->router->fetch_class()."/delete")?>" method="POST" class="form-horizontal">
						<!--  -->
						<input type="hidden" name="CODE">
						<!--  -->
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
							<h4 class="modal-title">Confirmation</h4>
						</div>
						<div class="modal-body">
							<p>
								Are you sure to delete this data?
								<br>
								<span style="color: red;"><strong>Note:</strong> This action is unable to be undone in the future.</span>
							</p>
						</div>
						<div class="modal-footer" style="padding: 10px;">
							<a href="javascript:;" data-dismiss="modal" class="btn btn-default">Close</a>
							<button type="submit" class="btn btn-danger btn_submit">Confirm</button>
						</div>
					</form>
				</div>
			</div>
		</div>
		<!--  -->
		
		<?php $this->load->view("includes/footer");?>
	</section>
	
	<script type="text/javascript">
		$(document).ready(function(){
//			$(".select2").select2();

			edit_load_data("<?php echo $id;?>");
		});

		//Global Variables---
		var timer_check_unique;
		var checking_unique;
		//-------------------

		function edit_load_data(id){
			disable_btn("#edit_btn_submit");
			
			//Loader---
			$("#edit_ajax_container").html("<?php echo $this->text_ajax_loader;?>");
			//---------
			
			var title = id == 0? "New":"Edit";
			$("#edit_h4_title").html(title);
		
			$.ajax({
				type: "POST",
				url: "<?php echo base_url($this->router->fetch_class());?>/load_edit",
				data: "CODE=" + id,
				success: function(result, status, xhr){
					$("#edit_ajax_container").html(result);
					enable_btn("#edit_btn_submit");
				},
				error: function(xhr,status,error){
					$("#edit_ajax_container").html("<?php echo $this->text_ajax_fail;?>");
				},
				complete: function(xhr,status){
				},
			});
		}
	</script>
</body>
</html>
