<!DOCTYPE html>
<html lang="en">
<head>
	<!-- Main navbar -->
		<?php $this->load->view('admin/common_header'); ?>
	<!-- /main navbar -->

	<!-- date picker JS files -->
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/core/libraries/jquery_ui/interactions.min.js"></script>
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/core/libraries/jquery_ui/widgets.min.js"></script>
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/core/libraries/jquery_ui/effects.min.js"></script>
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/plugins/extensions/mousewheel.min.js"></script>
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/core/libraries/jquery_ui/globalize/globalize.js"></script>

	<!-- Bootsrap form validation JS files -->
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/formValidation.js"></script>
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/bootstrap.js"></script>

	<script type="text/javascript" src="<?php echo base_url();?>assets/js/plugins/forms/styling/uniform.min.js"></script>
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/plugins/notifications/pnotify.min.js"></script>
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/plugins/forms/selects/bootstrap_multiselect.js"></script>
	<!-- Theme JS files -->
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/core/app.js"></script>
	<!-- /theme JS files -->

	<!-- Theme JS files -->
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/core/libraries/jquery_ui/interactions.min.js"></script>
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/plugins/forms/selects/select2.min.js"></script>

	<!-- select box theme JS files -->
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/plugins/forms/selects/bootstrap_select.min.js"></script>

    <!-- notify JS files -->
    <script type="text/javascript" src="<?php echo base_url();?>assets/js/plugins/notifications/jgrowl.min.js"></script>

	<!-- /select box JS files -->
	
	<style>
	    .has-error span.select2-container{
	    	border:1px solid #d84315;
	    }
	    .has-success span.select2-container{
	    	border:1px solid #43a047;
	    }
	</style>
</head>

<body class="navbar-top-md-md pace-done">

	<!-- Fixed navbars wrapper -->
	<div class="navbar-fixed-top">

		<!-- Main navbar -->
		<?php $this->load->view('admin/mainnav'); ?>
		<!-- /main navbar -->


		<!-- Second navbar -->
		<?php $this->load->view('admin/secondnav'); ?>
		<!-- /second navbar -->

	</div>
	<!-- /fixed navbars wrapper -->


	<!-- Page header -->
	<?php $this->load->view('admin/'.$module_name.'_header'); ?>
	<!-- /page header -->


	<!-- Page container -->
	<div class="page-container">

		<!-- Page content -->
		<div class="page-content">

			<!-- Main content -->
			<div class="content-wrapper">
			
				<!-- Basic responsive configuration -->
				<div class="panel panel-flat">
					<div class="panel-heading">
						<h5 class="panel-title"><?php echo $page_title; ?></h5>
						<div class="heading-elements">
							<ul class="icons-list">
								<!-- <li><a href="<?php echo base_url();?>admin/users/add" class="glyphicon-plus"></a></li> -->
		                		<li><a data-action="collapse"></a></li>
		                		<li><a data-action="reload"></a></li>
		                		<li><a data-action="close"></a></li>
		                	</ul>
	                	</div>
					</div>
					<?php $currency_info = defaultcurrency();?>
					<div class="panel-body">
						<form class="form-horizontal make-deposit" action="<?php echo $action;?>" method="post" enctype="multipart/form-data">

							<?php 
								if(validation_errors()) { 
									$form_err_data = str_replace('<p>', '', validation_errors());
									$form_err_data = str_replace('</p>', '', $form_err_data);
									$form_err_data = str_replace('.', '', $form_err_data);
							?>
									
									<script type="text/javascript">
									
									(function( $ ) {
										$.jGrowl.defaults.closer = false;
								        var error_data = '<?php echo $form_err_data; ?>'
										$.jGrowl(error_data, {
								            header: '<?php echo $this->lang->line("error");?>',
								            theme: 'bg-danger'
								        });
								    
									})(jQuery);


									</script>
							<?php
								}
							?>
							
                           <?php 
                           		$this->load->library('MyEncrypt');
								$myencrypt = new MyEncrypt;
							?>
							<!-- <div class="form-group  <?php if(form_error('select_package')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo $this->lang->line('lbl_select_package'); ?> <span class="text-danger">*</span></label>
								<div class="col-lg-4">
									<select name="select_package" id="select_packageid" class="select-search form-control">
										<option value=""><?php echo $this->lang->line('none_selected'); ?></option>
					               		<?php foreach ($packages as $package) { ?>
											<option value="<?php echo $package->packageid; ?>"><?php echo ucfirst($package->package_name); ?></option>
										<?php } ?>	
									</select>
									<?php echo form_error('select_package', '<div class="form-control-feedback"><i class="icon-cancel-circle2"></i></div><span class="help-block">', '</span>'); ?>
								</div>
							</div> -->

							<!-- <div class="form-group  <?php if(form_error('select_plan')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo $this->lang->line('lbl_select_plan'); ?> </label>
								<div class="col-lg-4">
									<select name="select_plan" id="plan_list" class="bootstrap-select form-control">
										<option value=""><?php echo $this->lang->line('none_selected'); ?></option>
									</select>
									<?php echo form_error('select_plan', '<div class="form-control-feedback"><i class="icon-cancel-circle2"></i></div><span class="help-block">', '</span>'); ?>
								</div>
							</div> -->
                          <?php if($flag==0) {?>
							<div class="form-group  <?php if(form_error('select_user')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo $this->lang->line('lbl_select_user'); ?> <span class="text-danger">*</span></label>
								<div class="col-lg-4">
									<select name="select_user" id="select_user_id" class="select-search form-control">
										 <option value=""><?php echo $this->lang->line('none_selected'); ?></option>
					               		<?php foreach ($uusers_list as $users) { ?>
											<option value="<?php echo $users->uusersid; ?>"><?php echo ucfirst($users->username); ?></option>
										<?php } ?>	
									</select>
									<?php echo form_error('select_user', '<div class="form-control-feedback"><i class="icon-cancel-circle2"></i></div><span class="help-block">', '</span>'); ?>
								</div>
							</div>
							<?php } else { ?>

                           <input type="hidden" name="user1" value="<?php echo $myencrypt->encode($member_name->uusersid);?>">
							<? } ?>


							<div class="form-group  has-feedback <?php if(form_error('select_coin')) echo "has-error";?>">   
				                <label class="control-label col-lg-3 text-semibold"><?php echo $this->lang->line('lbl_select_coin'); ?></label>
				                <div class="col-lg-4">
					               <select class="bootstrap-select form-control"  name="select_coin" id="select_coin">
					               <option value=""><?php echo $this->lang->line('none_selected'); ?></option>
					               <?php foreach ($all_active_coin as $list) { ?>
											<option value="<?php echo $list->coid; ?>"><?php echo ucfirst($list->coin_name); ?></option>
											<?php } ?>
				                        
									</select> 
					       			<?php echo form_error('select_user', '<div class="form-control-feedback"><i class="icon-cancel-circle2"></i></div><span class="help-block">', '</span>'); ?>
							    </div>
							</div>

							<!-- <div class="form-group  <?php if(form_error('payment')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo $this->lang->line('lbl_select_payment'); ?> <span class="text-danger">*</span></label>
								<div class="col-lg-4">
									<select name="payment" class="select-search form-control">
										<option value=""><?php echo $this->lang->line('none_selected'); ?></option>
					               		<?php foreach ($payment_list as $list) { ?>
											<option value="<?php echo $list->payment_id; ?>"><?php echo ucfirst($list->payment_name); ?></option>
										<?php } ?>
									</select>
									<?php echo form_error('payment', '<div class="form-control-feedback"><i class="icon-cancel-circle2"></i></div><span class="help-block">', '</span>'); ?>
								</div>
							</div> -->

							<div class="form-group <?php if(form_error('amount')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo $this->lang->line('lbl_deposit_amount'); ?> <span class="text-danger">*</span></label>
								<div class="col-lg-4">
									<div class="input-group">
									    								
											<input type="text" name="amount" id="amount" class="form-control" placeholder="<?php echo $this->lang->line('place_deposit_amount'); ?>" value="<?php echo set_value('amount'); ?>">
					                    
									</div>
									<?php echo form_error('amount', '<div class="form-control-feedback"></div><span class="help-block">', '</span>'); ?>
								</div>
							</div>

							<!-- <div class="form-group <?php if(form_error('compound')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo $this->lang->line('lbl_compound_amount'); ?> <span class="text-danger">*</span></label>
								<div class="col-lg-4">
									<div class="input-group">
										<input type="text" name="compound" id="compound" class="form-control" placeholder="<?php echo $this->lang->line('place_compound_amount'); ?>" value="<?php echo set_value('amount'); ?>">
									</div>
									<?php echo form_error('compound', '<div class="form-control-feedback"></div><span class="help-block">', '</span>'); ?>
								</div>
							</div> -->
<!-- 
							<div class="form-group  <?php if(form_error('compound')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo $this->lang->line('lbl_compound_amount'); ?> </label>
								<div class="col-lg-2">
									<select name="compound" id="compound" class="bootstrap-select form-control">
										<option value=""><?php echo $this->lang->line('none_selected'); ?></option>
									</select>
									<?php echo form_error('compound', '<div class="form-control-feedback"><i class="icon-cancel-circle2"></i></div><span class="help-block">', '</span>'); ?>
								</div>
							</div> -->

							<input type="hidden" name="select_plan" value="1"/>
							

							<div class="form-group">
								<label class="control-label col-lg-3 text-semibold"><?php echo $this->lang->line('lbl_deposit_date'); ?> <span class="text-danger">*</span></label>
								<div class="col-lg-2">
									<div class="input-group">
										<span class="input-group-addon"><i class="icon-calendar22"></i></span>
										<input type="text" class="form-control deposit_date" placeholder="<?php echo $this->lang->line('place_deposit_date'); ?>" name="deposit_date" value="<?php echo set_value('deposit_date'); ?>">
									</div>
									<?php echo form_error('deposit_date', '<div class="form-control-feedback"></div><span class="help-block">', '</span>'); ?>
								</div>
							</div>

							<div class="form-group">
								<label class="control-label col-lg-3 text-semibold"><?php echo $this->lang->line('lbl_deposit_description'); ?> <span class="text-danger">*</span></label>
								<div class="col-lg-4">
									<div class="">
										<input type="text" class="form-control description" placeholder="<?php echo $this->lang->line('place_deposit_decsription'); ?>" name="description" value="<?php echo set_value('description'); ?>">
									</div>
									<?php echo form_error('description', '<div class="form-control-feedback"></div><span class="help-block">', '</span>'); ?>
								</div>
							</div>

							<div class="text-right col-lg-7">
	                            <button id="btn" type="submit" class="btn btn-primary"><?php echo $this->lang->line('lbl_make_deposit'); ?> <i class="icon-arrow-right14 position-right"></i></button>
							</div>
						</form>
					</div>
					
					<!-- </div> -->
				</div>
				<!-- /basic responsive configuration -->

			</div>
			<!-- /main content -->

		</div>
		<!-- /page content -->


		<!-- Footer -->
		<div class="footer text-muted">
			<?php echo site_footer();?>
		</div>
		<!-- /footer -->

	</div>
	<!-- /page container -->

	<script type="text/javascript">
		jQuery.noConflict();
		(function( $ ) {
		$(function() {

			$(document).ready(function() {

				$('.select-search').select2({"size":4});

				$.jGrowl.defaults.closer = false;

				<?php if($this->session->flashdata('error_message')) { ?>
					$.jGrowl("<?php echo $this->session->flashdata('error_message');?>", {
			            header: '<?php echo $this->lang->line("error");?>',
			            theme: 'bg-danger'
			        });
	            <?php } ?>
	                    
	            <?php if($this->session->flashdata('success_message')) { ?>
	                $.jGrowl("<?php echo $this->session->flashdata('success_message');?>", {
			            header: '<?php echo $this->lang->line("success");?>',
			            theme: 'bg-success'
			        });
	            <?php } ?>

	            $('#select_packageid').on('change', function() {
					
					var values =  this.value;
					$.ajax({
			            type: 'post',
			            url:'<?php echo base_url();?>admin/finance/checkpackage/'+values,
			            dataType: 'json',
			            success : function(resp)
			            {
			            	$('#plan_list').html(resp['plans']);
			            	$('#compound').html(resp['compound']);

			            	// console.log({elapsed_time});
			            	// console.log('{memory_usage}');

			            	$('.bootstrap-select').selectpicker('refresh');
			            	var plan = $('[name="select_plan"]').val();
			            	$('[name="selected_plan"]').val(plan);

			            }
			        });
				})

				$(".deposit_date").datepicker({
	            	dateFormat: 'yy-mm-dd',
	            	maxDate: 0
	            }).on('change', function(e) {
	            	$('.make-deposit').formValidation('revalidateField','deposit_date');
	            })

	            
	            $('[name="select_package"]').on('change', function(e){
	            	// $('.make-deposit').formValidation('revalidateField','select_plan');
	            	var plan = $('[name="select_plan"]').val();
			        $('[name="selected_plan"]').val(plan);
	            	if($('[name="amount"]').val()){
	            		$('.make-deposit').formValidation('revalidateField','amount');
	            	}
	            })
	        	

	            $('[name="select_plan"]').on('change', function(e){
	            	var plan = $('[name="select_plan"]').val();
			        $('[name="selected_plan"]').val(plan);
	            	if($('[name="amount"]').val()){
	            		$('.make-deposit').formValidation('revalidateField','amount');
	            	}
	            })

	            // $('[name="paymnet_periord"]').on('change', function(e){
	            // 	$('.make-deposit').formValidation('revalidateField','paymnet_periord');
	            // })

			    $('.make-deposit').formValidation({
			    	framework: 'bootstrap',
			    	excluded: [':disabled'],
			        icon: {
			           
			            validating: 'glyphicon glyphicon-refresh'
			        },
	                row: {
					    valid: 'has-success1',
					    invalid: 'has-error'
					},
			        fields: {
			            select_package: {
			                validators: {
			                    notEmpty: {
			                        message: '<?php echo $this->lang->line("deposit_package_required");?>'
			                    }
			                }
			            },
			            // select_plan: {
			            //     validators: {
			            //         notEmpty: {
			            //             message: '<?php echo $this->lang->line("deposit_plan_required");?>'
			            //         }
			            //     }
			            // },
			            select_user: {
			                validators: {
			                    notEmpty: {
			                        message: '<?php echo $this->lang->line("deposit_user_required");?>'
			                    }
			                }
			            },
			             select_coin: {
			            	message: '<?php echo $this->lang->line("lbl_select_coin_cannot_empty"); ?>',
			            	 validators: {
			                    notEmpty: {
			                        message: '<?php echo $this->lang->line("lbl_select_coin_cannot_empty"); ?>'
			                    }
			                }
			            },
			            // payment: {
			            //     validators: {
			            //         notEmpty: {
			            //             message: '<?php echo $this->lang->line("deposit_payment_required");?>'
			            //         }
			            //     }
			            // },
			            deposit_date: {
			                validators: {
			                    notEmpty: {
			                        message: '<?php echo $this->lang->line("deposit_date_required");?>'
			                    }
			                }
			            },
			            description: {
			                validators: {
			                    notEmpty: {
			                        message: '<?php echo $this->lang->line("deposit_description_required");?>'
			                    }
			                }
			            },
			            amount: {
			                validators: {
			                    notEmpty: {
			                        message: '<?php echo $this->lang->line("deposit_amount_required");?>'
			                    },
			                    regexp: {
			                        regexp: /^[0-9.]+$/,
			                        message: '<?php echo $this->lang->line("deposit_amount_invalid"); ?>'
			                    }
			                }
			            },
			           
			            
			        }
			    })
				

			});

			$('.bootstrap-select').selectpicker({size: 3});
		 
			$('#icon-bck').on('click',function() {
				window.history.back();
			});

		});
		})(jQuery);
	</script>

</body>
</html>
