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

	<!-- file upload JS files -->
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/plugins/uploaders/fileinput.min.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>
	

	<!-- Theme JS files -->
	<script type="text/javascript" src="<?php echo base_url();?>assets/js/core/app.js"></script>
	<!-- /theme JS files -->

	<!-- file upload JS files -->
	<script type="text/javascript" src="<?php echo base_url();?>/assets/boots/js/fileinput.min.js"></script>
	
	<!-- bootsrap switch checkbox JS files -->
    <script src="<?php echo base_url();?>/assets/boots/js/bootstrap-switch.js"></script>

    <!-- notify JS files -->
    <script type="text/javascript" src="<?php echo base_url();?>assets/js/plugins/notifications/jgrowl.min.js"></script>
    <style>
		.kv-file-content img.file-preview-image {
	    	width: 150px !important;
	    }
	</style>
   
</head>

<body class="navbar-top-md-md">
	<!-- <div class="pre_loader"></div> -->
	<!-- 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 -->
	<div class="page-header">
		<div class="page-header-content">
			<div class="page-title">
				<h4><i id="icon-bck" class="icon-arrow-left52 position-left"></i> <span class="text-semibold"><?php echo $this->lang->line('lbl_stacking_title'); ?></span></h4>

				<ul class="breadcrumb breadcrumb-caret position-right">
					<?php foreach ($breadcrumbs as $breadcrumb) { if(isset($breadcrumb['href'])){?>
					    <li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
					<?php } else { ?> <li><?php echo $breadcrumb['text']; ?></li><?php } } ?>
				</ul>
			</div>
			<?php $this->load->view('admin/user_header'); ?>
			
		</div>
	</div>
	<!-- /page header -->


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

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

			<!-- Main content -->
			<div class="content-wrapper">

				<!-- Horizontal form -->
				<div class="panel panel-flat">
					<div class="panel-heading">
						<h5 class="panel-title">
						<?php 
							if(isset($this->data['gateway_name'])) { 
								$gate_name = $this->data['gateway_name'];
								echo $this->lang->line($gate_name.'_gateway');
							}
						?>
						</h5>
						<div class="heading-elements">
							<ul class="icons-list">
		                		<li><a data-action="collapse"></a></li>
		                		<li><a data-action="close"></a></li>
		                	</ul>
	                	</div>
                	</div>

                	<?php $currency_info = defaultcurrency();?>
					<div class="panel-body">
						<div class="row">
							<div class="col-md-10">

								<form class="form-horizontal paymentsetting" name="lending" action="<?php echo $action;?>" method="post" enctype="multipart/form-data">
									<div>
										<?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 from_daa = '<?php $form_err_data;?>';
													$.jGrowl(from_daa, {
											            header: '<?php echo $this->lang->line("error");?>',
											            theme: 'bg-danger'
											        });
											    
												})(jQuery);


												</script>
										<?php
											}
										?>
									</div>
									<?php
									if(isset($this->data['lending']))
									{
										$lending=$this->data['lending'];
										
										$this->load->library('MyEncrypt');
										$myencrypt = new MyEncrypt;
										$to_day=date("Y",strtotime($lending[0]->from_mth));

										$f_day=date("m",strtotime($lending[0]->from_mth));
										$t_day=date("m",strtotime($lending[0]->to_mth));

										$profit=$lending[0]->profit;
										$days=$lending[0]->days;
										$lend_id=$lending[0]->id;
										
										$payment_id = $myencrypt->encode($lend_id);
										$balance=$to_day;

									}
									else
									{
										$this->load->library('MyEncrypt');
										$myencrypt = new MyEncrypt;

										$profit="";
										$days="";
										$lend_id="";
										$payment_id ="";
										$balance="";

									}

									?>
									<input type="hidden" name="payment_id" id="payment_id" value="<?php echo $payment_id; ?>"/>
									
									<div class="form-group">
										<label class="control-label col-lg-3 text-semibold"><?php echo $this->lang->line('lbl_from_month'); ?> <span class="text-danger">*</span></label>
										<div class="col-lg-4">
											<select class="form-control" id="from_month" name="from_month">
												<option value="01" <?php if($f_day=='01') echo "selected=='selected'";?>>January</option>
												<option value="02" <?php if($f_day=='02') echo "selected=='selected'";?>>February</option>
												<option value="03" <?php if($f_day=='03') echo "selected=='selected'";?>>March</option>
												<option value="04" <?php if($f_day=='04') echo "selected=='selected'";?>>April</option>
												<option value="05" <?php if($f_day=='05') echo "selected=='selected'";?>>May</option>
												<option value="06" <?php if($f_day=='06') echo "selected=='selected'";?>>June</option>
												<option value="07" <?php if($f_day=='07') echo "selected=='selected'";?>>July</option>
												<option value="08" <?php if($f_day=='08') echo "selected=='selected'";?>>August</option>
												<option value="09" <?php if($f_day=='09') echo "selected=='selected'";?>>September</option>
												<option value="10" <?php if($f_day=='10') echo "selected=='selected'";?>>October</option>
												<option value="11" <?php if($f_day=='11') echo "selected=='selected'";?>>November</option>
												<option value="12" <?php if($f_day=='12') echo "selected=='selected'";?>>December</option>

											</select>
							            </div>
										
									</div>

									<div class="form-group">
										<label class="control-label col-lg-3 text-semibold"><?php echo $this->lang->line('lbl_to_month'); ?> <span class="text-danger">*</span></label>
										<div class="col-lg-4">
											<select class="form-control" id="to_month" name="to_month">
												<option value="01" <?php if($f_day=='01') echo "selected=='selected'";?>>January</option>
												<option value="02" <?php if($f_day=='02') echo "selected=='selected'";?>>February</option>
												<option value="03" <?php if($f_day=='03') echo "selected=='selected'";?>>March</option>
												<option value="04" <?php if($f_day=='04') echo "selected=='selected'";?>>April</option>
												<option value="05" <?php if($f_day=='05') echo "selected=='selected'";?>>May</option>
												<option value="06" <?php if($f_day=='06') echo "selected=='selected'";?>>June</option>
												<option value="07" <?php if($f_day=='07') echo "selected=='selected'";?>>July</option>
												<option value="08" <?php if($f_day=='08') echo "selected=='selected'";?>>August</option>
												<option value="09" <?php if($f_day=='09') echo "selected=='selected'";?>>September</option>
												<option value="10" <?php if($f_day=='10') echo "selected=='selected'";?>>October</option>
												<option value="11" <?php if($f_day=='11') echo "selected=='selected'";?>>November</option>
												<option value="12" <?php if($f_day=='12') echo "selected=='selected'";?>>December</option>

											</select>
							            </div>
										
									</div>


									<div class="form-group  has-feedback <?php if(form_error('year')) echo "has-error";?>">
										<label class="control-label col-lg-3 text-semibold"><?php echo $this->lang->line('lbl_stack_year'); ?> (YYYY)<span class="text-danger">*</span></label>
										<div class="col-lg-4">
											<input type="text" name="year" id="year" onkeyup="numchk(this)" class="form-control"  value="<?php echo $balance;?>">
											<?php echo form_error('year', '<div class="form-control-feedback"><i class="icon-cancel-circle2"></i></div><span class="help-block">', '</span>'); ?>	
							            </div>
										
									</div>

									<div class="form-group">
									<div class="col-lg-3">
									</div>
									<div class="col-lg-6">
										<div  id="bal_err" name="bal_err" style="color:red;"></div>	
										</div>
									</div>

								

									<div class="form-group  has-feedback <?php if(form_error('profit')) echo "has-error";?>">
										<label class="control-label col-lg-3 text-semibold"><?php echo $this->lang->line('lbl_stack_profit'); ?> (%)<span class="text-danger">*</span></label>
										<div class="col-lg-4">
											<input type="text" name="profit" id="profit" onkeyup="numchk(this)" class="form-control"  value="<?php echo $profit;?>">
											<?php echo form_error('profit', '<div class="form-control-feedback"><i class="icon-cancel-circle2"></i></div><span class="help-block">', '</span>'); ?>	
							            </div>
										
									</div>
									<div class="form-group">
									<div class="col-lg-3">
									</div>
									<div class="col-lg-6">
										<div  id="profit_err" name="profit_err" style="color:red;"></div>	
										</div>
									</div>

									<div class="form-group  has-feedback <?php if(form_error('days')) echo "has-error";?>">
										<label class="control-label col-lg-3 text-semibold"><?php echo $this->lang->line('lbl_stack_days'); ?> <span class="text-danger">*</span></label>
										<div class="col-lg-4">
											   	<input type="text" name="days" id="days" onkeyup="numchk(this)" class="form-control" value="<?php echo $days;?>">
											   	<?php echo form_error('days', '<div class="form-control-feedback"><i class="icon-cancel-circle2"></i></div><span class="help-block">', '</span>'); ?>	
							            </div>
							            
									</div>

									<div class="form-group">
									<div class="col-lg-3">
									</div>
									<div class="col-lg-6">
										<div  id="day_err" name="day_err" style="color:red;"></div>	
										</div>
									</div>

									

									
									<div class="text-right col-lg-6">
										<button type="submit" id="submit" name="submit" class="btn btn-primary"><?php echo $this->lang->line('button_update');  ?> <i class="icon-arrow-right14 position-right"></i></button>
									</div>
								</form>

							</div>
							
						</div>
					</div>
				</div>
				<!-- /horizotal form -->

			</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() {
				
				$.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 } ?>
				});

			
		    
		 	$('#icon-bck').on('click',function() {
				window.history.back();
			});

			$('#submit').on('click',function() {
				
				$flag1=0;
				$flag2=0;
				var year="<?php echo date("Y");?>";
				
				var days=$("#days").val();
				var profit=$("#profit").val();
				var payment_id=$("#payment_id").val();
				var balance=$("#year").val();
				$("#bal_err").html('');
				$("#day_err").html('');
				$("#profit_err").html('');
				
				if(balance=="")
                {
                  $flag=1;
                  $("#bal_err").html('Please Enter year');
                }
                if(balance!='')
                {
                	var mq =/^[0-9]+$/;
					if(!mq.test(balance))
               		{
               			$flag=1;
                  		$("#bal_err").html('Please Enter only numbers');	
               		}
               		else
               		{
               			if(balance.length!='4')
               			{
               				$flag=1;
                  		   $("#bal_err").html('Please Enter valid year');	

               			}
               			else
               			{
               				if(balance < year)
               				{
               					$flag=1;
                  		 		$("#bal_err").html('Entered Year is already exceed');	

               				}

               			}
               		}
                } 

				if(days=="")
                {
                  $flag=1;
                  $("#day_err").html('Please Enter Duration');
                }

                if(days!='')
                {
                	var mq =/^[0-9]+$/;
					if(!mq.test(days))
               		{
               			$flag=1;
                  		$("#day_err").html('Please Enter only numbers');	
               		}

                }

                if(profit=="")
                {
                  $flag=1;
                  $("#profit_err").html('Please Enter percentage');
                }

                if(profit!='')
                {
                	var mq =/^[0-9.]+$/;
					if(!mq.test(profit))
               		{
               			$flag=1;
                  		$("#profit_err").html('Please Enter only numbers');	
               		}
                }
                if($flag!='1')
                {
                	return false;
               

                }

				return false;
               

			

				
			});
		   

		});
		})(jQuery);
	

	function numchk (tag)

{       

  var1=tag.value; // tval is textbox (element) checking for characters only

    s=var1.substr(var1.length-1,1);    

  m=s.charCodeAt(0);            

  if (!((m>=48 && m<=57 )||(m==46) || isNaN(m)))

  {

    //alert ("Invalid input");  

    ch=var1.substr(0,var1.length-1);    

    tag.value=ch;           

  }

}
		

	</script>



</body>
</html>
