<!DOCTYPE html>
<html lang="en">
<head>
	<!-- header -->
		<?php
		helper('form');
		$session = session();
		$validation = \Config\Services::validation();


		 echo view('admin/common_header'); ?>
	<!-- /header -->
	<script type="text/javascript" src="<?php echo base_url();?>/assets/js/plugins/forms/selects/select2.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 -->

	<!-- select box theme JS files -->
	<script type="text/javascript" src="<?php echo base_url('assets/js/plugins/forms/selects/bootstrap_select.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>

    <!-- select box JS files -->
	<script type="text/javascript" src="<?php echo base_url('assets/js/pages/form_bootstrap_select.js');?>"></script>
	<!-- /select box JS files -->

	
</head>

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

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

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


		<!-- Second navbar -->
		<?php echo 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 lang('language_lang.referral_page_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 echo view('admin/'.$module_name.'_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 echo lang('language_lang.referral_page_title'); ?></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">
						<form class="form-horizontal form-referral" action="<?=site_url($action);?>" method="post">
							<?php 
								if($validation->listErrors()) { 
									$form_err_data = str_replace('<p>', '', $validation->listErrors());
									$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 lang("language_lang.error");?>',
								            theme: 'bg-danger'
								        });
								    
									})(jQuery);


									</script>
							<?php
								}
							?>
							<div class="form-group ">
								<label class="control-label col-lg-4 text-semibold"><?php echo lang('language_lang.referral_program'); ?></label>
	                            <div class="col-lg-6">
									<div  class="checkbox checkbox-switch">
										<label>
											<input type="checkbox" data-on-color="primary" data-off-color="Off" class="switchery" data-on-text="<?php echo lang('language_lang.On'); ?>" data-off-text="<?php echo lang('language_lang.Off'); ?>" data-on-color="primary" data-off-color="default" name="ref_program" <?php if($ref_program==='on'){ echo 'checked="checked"'; }   ?>>
										</label>
									</div>
								</div>
							</div>

				            <div class="form-group ">
								<label class="control-label col-lg-4 text-semibold"><?php echo ucwords(lang('language_lang.referral_upline')); ?></label>
 	                            <div class="col-lg-6">
						          	<div class="checkbox checkbox-switch">
										<label>
											<input type="checkbox" data-on-color="primary" data-off-color="Off" class="switchery" data-on-text="<?php echo lang('language_lang.On'); ?>" data-off-text="<?php echo lang('language_lang.Off'); ?>" data-on-color="primary" data-off-color="default" name="ref_upline_reg" <?php if($ref_upline_reg==='on'){ echo 'checked="checked"'; }   ?>>
										</label>
							     	</div>
							    </div>
							</div>

				            <div class="form-group ">
								<label class="control-label col-lg-4 text-semibold"><?php echo ucwords(lang('language_lang.referral_auto_upline')); ?></label>
 	                            <div class="col-lg-6">
							        <div class="checkbox checkbox-switch">
										<label>
											<input type="checkbox" data-on-color="primary" data-off-color="Off" class="switchery" data-on-text="<?php echo lang('language_lang.On'); ?>" data-off-text="<?php echo lang('language_lang.Off'); ?>" data-on-color="primary" data-off-color="default" name="ref_auto_upline" <?php if($ref_auto_upline==='on'){ echo 'checked="checked"'; }   ?>>
										</label>
								    </div>
							    </div>
						  	</div>

						  	<div class="form-group" style="display:none;">
								<label class="control-label col-lg-4 text-semibold"><?php echo lang('language_lang.referral_comm_not_add'); ?></label>
									<div class="col-lg-6">
									<div class="checkbox checkbox-switch">
										<label>
											<input type="checkbox" data-on-color="primary" data-off-color="Off" class="switchery" data-on-text="<?php echo lang('language_lang.On'); ?>" data-off-text="<?php echo lang('language_lang.Off'); ?>" data-on-color="primary" data-off-color="default" name="ref_not_add_refcomm" <?php if($ref_not_add_refcomm==='on'){ echo 'checked="checked"'; }   ?>>
										</label>
									</div>
								</div>
						    </div>

				            <!-- <div class="form-group ">
								<label class="control-label col-lg-4 text-semibold"><?php echo ucwords(lang('language_lang.referral_comm_aftr_reg')); ?></label>
  	                            <div class="col-lg-6">
							        <div class="checkbox checkbox-switch">
										<label>
											<input type="checkbox" data-on-color="primary" data-off-color="Off" class="switchery" data-on-text="<?php echo lang('language_lang.On'); ?>" data-off-text="<?php echo lang('language_lang.Off'); ?>" data-on-color="primary" data-off-color="default" name="ref_direct_sponser_comm" <?php if($ref_direct_sponser_comm==='on'){ echo 'checked="checked"'; }   ?>>
										</label>
								    </div>
							    </div>
							</div> -->

			                <div class="form-group" style="display:none;">
								<label class="control-label col-lg-4 text-semibold"><?php echo ucwords(lang('language_lang.referral_comm_aftr_Dep')); ?></label>
  	                            <div class="col-lg-6">
							        <div class="checkbox checkbox-switch">
										<label>
											<input type="checkbox" data-on-color="primary" data-off-color="Off" class="switchery" data-on-text="<?php echo lang('language_lang.On'); ?>" data-off-text="<?php echo lang('language_lang.Off'); ?>" data-on-color="primary" data-off-color="default" name="ref_comm_aft_deposit_status" <?php if($ref_comm_aft_deposit_status==='on'){ echo 'checked="checked"'; }   ?>>
										</label>
								    </div>
							    </div>
							</div>

							<!-- <div style="margin-top:20px;" class="form-group  has-feedback <?php if($validation->getError('ref_comm_amt_reg')) echo "has-error";?>">
								<label class="control-label col-lg-4 text-semibold"><?php echo ucwords(lang('language_lang.referral_comm_amnt_aftr_reg')); ?>  <span class="text-danger">*</span></label>
								<div class="col-lg-4">
									<div style="width:74%" class="input-group">
									<span class="input-group-addon" style="font-size: 18px;"><strong><?php echo $currency_info->currency_symbol;?></strong></span>										
										<input type="text" name="ref_comm_amt_reg" class="form-control"  placeholder="<?php echo lang('language_lang.plac_reg_comm_amnt'); ?>" value="<?php echo set_value('ref_comm_amt_reg',isset($this->data['ref_comm_amt_reg']) ? number_format($this->data['ref_comm_amt_reg'], $currency_info->deimal_point, '.', '') : ''); ?>">
									<span class="input-group-addon"><?php echo strtoupper($currency_info->currency_unit);?></span>
									</div>
									<?php echo $validation->getError('ref_comm_amt_reg', '<div class="form-control-feedback"><i class="icon-cancel-circle2"></i></div><span class="help-block">', '</span>'); ?>
								</div>
							</div> -->

							<!-- <div style="margin-top:10px;" class="form-group  has-feedback <?php if($validation->getError('ref_comm_aft_deposit')) echo "has-error";?>">
								<label class="control-label col-lg-4 text-semibold"><?php echo ucwords(lang('language_lang.referral_comm_amnt_aftr_Dep')); ?>  <span class="text-danger">*</span></label>
								<div class="col-lg-4">
									<div style="width:74%" class="input-group"> -->
									<!-- <span class="input-group-addon" style="font-size: 18px;"><strong><?php echo $currency_info->currency_symbol;?></strong></span>										 -->
										<!-- <input type="text" name="ref_comm_aft_deposit" class="form-control"  placeholder="<?php echo lang('language_lang.plac_dep_comm_amnt'); ?>" value="<?php echo set_value('ref_comm_aft_deposit',isset($this->data['ref_comm_aft_deposit']) ? number_format($this->data['ref_comm_aft_deposit'], $currency_info->deimal_point, '.', '') : ''); ?>"> -->
									<!-- <span class="input-group-addon"><?php echo strtoupper($currency_info->currency_unit);?></span> -->
									<!-- <span class="input-group-addon">%</span>
									</div>
									<?php echo $validation->getError('ref_comm_aft_deposit', '<div class="form-control-feedback"><i class="icon-cancel-circle2"></i></div><span class="help-block">', '</span>'); ?>
								</div>
							</div> -->

		                    <div class="form-group" style="display:none;">
								<label class="control-label col-lg-4 text-semibold"><?php echo lang('language_lang.referral_comm_solid'); ?></label>
 								<div class="col-lg-4">
	                                <div class="checkbox checkbox-switch">
									<label>
										<input type="checkbox" data-on-color="primary" data-off-color="Off" class="switchery" data-on-text="<?php echo lang('language_lang.On'); ?>" data-off-text="<?php echo lang('language_lang.Off'); ?>" data-on-color="primary" data-off-color="default" name="ref_solid_comm" <?php if($ref_solid_comm==='on'){ echo 'checked="checked"'; }   ?>>
									</label>
								    </div>
							    </div>
							</div>

							<div style="margin-top:20px;display:none;" class="form-group  has-feedback <?php if($validation->getError('ref_solid_comm_amnt')) echo "has-error";?>">
								<label class="control-label col-lg-4 text-semibold"><?php echo ucwords(lang('language_lang.referral_comm_solid_amnt')); ?>  <span class="text-danger">*</span></label>
								<div class="col-lg-4">
									<div style="width:74%" class="input-group">
									<span class="input-group-addon" style="font-size: 18px;"><strong><?php echo $currency_info->currency_symbol;?></strong></span>										
										<input type="text" name="ref_solid_comm_amnt" class="form-control"  placeholder="<?php echo lang('language_lang.plac_solid_amnt'); ?>" value="<?php echo set_value('ref_solid_comm_amnt',isset($this->data['ref_solid_comm_amnt']) ? number_format($this->data['ref_solid_comm_amnt'], $currency_info->deimal_point, '.', '') : ''); ?>">
									<span class="input-group-addon"><?php echo strtoupper($currency_info->currency_unit);?></span>
									</div>
									<?php echo $validation->getError('ref_solid_comm_amnt', '<div class="form-control-feedback"><i class="icon-cancel-circle2"></i></div><span class="help-block">', '</span>'); ?>
								</div>
							</div>

		                   

							

								

							<div class="form-group  has-feedback <?php if($validation->getError('ref_user')) echo "has-error";?>" >
							    <label class="control-label col-lg-4 text-semibold"><?php echo lang('language_lang.referral_ID'); ?>  <span class="text-danger">*</span></label>
						    	<?php 
							    	if(isset($ref_user)) {
							    		$ref_user_select = $ref_user;
							    	} else {
							    		$ref_user_select = '';
							    	}
							    	
						    	?>
								<div class="col-lg-3">
									<select name="ref_user" class="select-search form-control">
										<option value="" <?php if($ref_user_select=='') echo 'selected';?>><?php echo ucfirst(lang('language_lang.select'));?></option>
										<?php foreach ($uusers_list as $user ) { ?>
											<option <?php if($ref_user_select==$user->uusersid) { echo 'selected'; } ?> value="<?php echo $user->uusersid;?>" ><?php echo $user->username;?></option>
										<?php } ?>
									</select>
									<?php echo $validation->getError('ref_user', '<div style="right:20px;" class="form-control-feedback"><i class="icon-cancel-circle2"></i></div><span class="help-block">', '</span>'); ?>
								</div>
							</div>
							
							
		                    
						
							<div class="col-lg-7 text-right">
								<button type="submit" class="btn btn-primary"><?php echo lang('language_lang.button_update'); ?> <i class="icon-arrow-right14 position-right"></i></button>
							</div>
						</form>
					</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($session->getFlashData('error_message')) { ?>
				$.jGrowl("<?php echo $session->getFlashData('error_message');?>", {
		            header: '<?php echo lang("language_lang.error");?>',
		            theme: 'bg-danger'
		        });
            <?php } ?>
                    
            <?php if($session->getFlashData('success_message')) { ?>
                $.jGrowl("<?php echo $session->getFlashData('success_message');?>", {
		            header: '<?php echo lang("language_lang.success");?>',
		            theme: 'bg-success'
		        });
            <?php } ?>

		    $('.form-referral').formValidation({
		    	framework: 'bootstrap',
		    	excluded: [':disabled'],
		        icon: {
		            // valid: 'glyphicon glyphicon-ok',
		            // invalid: 'glyphicon glyphicon-remove',
		            validating: 'glyphicon glyphicon-refresh'
		        },
		        fields: {
		            ref_comm_amt_reg: {
		                message: '<?php echo lang("language_lang.referral_comm_reg_valid"); ?>',
		                validators: {
		                    notEmpty: {
		                        message: '<?php echo lang("language_lang.referral_comm_reg_amnt_required"); ?>'
		                    },
		                    regexp: {
		                        regexp: /^[0-9.]+$/,
		                        message: '<?php echo lang("language_lang.referral_comm_amnt_reg_num"); ?>'
		                    }
		                }
		            },
		            ref_comm_aft_deposit: {
		                message: '<?php echo lang("language_lang.referral_comm_dep_valid"); ?>',
		                validators: {
		                    notEmpty: {
		                        message: '<?php echo lang("language_lang.referral_comm_dep_amnt_required"); ?>'
		                    },
		                    regexp: {
		                        regexp: /^[0-9.]+$/,
		                        message: '<?php echo lang("language_lang.referral_comm_dep_reg_num"); ?>'
		                    }
		                }
		            },
		            ref_solid_comm_amnt: {
		                message: '<?php echo lang("language_lang.referral_comm_solid_valid"); ?>',
		                validators: {
		                    notEmpty: {
		                        message: '<?php echo lang("language_lang.referral_comm_solid_amnt_required"); ?>'
		                    },
		                    regexp: {
		                        regexp: /^[0-9.]+$/,
		                        message: '<?php echo lang("language_lang.referral_comm_amnt_solid_num"); ?>'
		                    }
		                }
		            },
		            ref_mlm_plan: {
		                message: '<?php echo lang("language_lang.referral_force_mlm_valid"); ?>',
		                validators: {
		                    notEmpty: {
		                        message: '<?php echo lang("language_lang.referral_force_mlm_required");?>'
		                    },
		                    digits: {
		                        message: '<?php echo lang("language_lang.referral_force_mlm_digits");?>'

		                    },
		                    regexp: {
		                        regexp: /^[1-9]{0,1}$/,
		                        message: '<?php echo lang("language_lang.referral_force_mlm_exceed"); ?>'
		                    }

		               }
		            },
		            /*ref_mlm_plan2: {
		                message: '<?php echo lang("language_lang.referral_force_mlm_valid"); ?>',
		                validators: {
		                    notEmpty: {
		                        message: '<?php echo lang("language_lang.referral_force_mlm_required");?>'
		                    },
		                    digits: {
		                        message: '<?php echo lang("language_lang.referral_force_mlm_digits");?>'

		                    },
		                    regexp: {
		                        regexp: /^[1-9]{0,1}$/,
		                        message: '<?php echo lang("language_lang.referral_force_mlm_exceed"); ?>'
		                    }
		               }
		            }, */
		            ref_user: {
		                message: '<?php echo lang("language_lang.referral_id_valid");?>',
		                validators: {
		                    notEmpty: {
		                        message: '<?php echo lang("language_lang.referral_id_required"); ?>'
		                    }
		                }
		            }

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

	});
	})(jQuery);

	
	</script>

</body>
</html>
