<!DOCTYPE html>
<html lang="en">
<head>
	<!-- header -->
		<?php
		helper('form');
		$session = session();
		$validation = \Config\Services::validation();
		use App\Libraries\MyEncrypt;
        
        $this->session = \Config\Services::session();
		 echo view('admin/common_header'); ?>
	<!-- /header -->
	    <script src="https://cdn.ckeditor.com/4.4.3/basic/ckeditor.js"></script>
	<script src="<?php echo base_url('/assets/boots/js/jquery.js');?>"></script>
	<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/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>
	<script type="text/javascript" src="<?php echo base_url('assets/js/plugins/forms/selects/bootstrap_select.min.js');?>"></script>
	<!-- Theme JS files -->
	<script type="text/javascript" src="<?php echo base_url();?>/assets/js/core/app.js"></script>
	<script type="text/javascript" src="<?php echo base_url('assets/js/pages/form_bootstrap_select.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>
	<!-- /theme JS files -->
<script src="<?php echo base_url('assets/boots/js/bootstrap-switch.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 -->
    

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

	<!-- /theme JS files -->

    <!-- notify JS files -->
	    
	<!-- /select box JS files -->
	
	<style type="text/css">
	    .has-error span.select2-container
	    {
	    	border:1px solid #d84315;
	    }

	    .has-success span.select2-container
	    {
	    	border:1px solid #43a047;
	    }

	     .multiselect-container {
	    	width:100% !important;
	    }

	    div.form-group  div.btn-group ul.multiselect-container.dropdown-menu {
	    	padding: 0px !important;
	    }	 
	    .form-horizontal .checkbox .checker, .form-horizontal .checkbox-inline .checker
	    {
 			top:0; 
		}   

		.multiselect-container > li > a .checker, .multiselect-container > li > a .choice {
  left: 12px;
  margin-top: 10px;
  top: 50%;
}

element {
    width: 141px;
    margin-left: 0px;
}
	</style>
</head>

<body class="navbar-top-md-md">
	<!-- <div class="pre_loader"></div> -->
	<!-- 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 -->
	<?php echo 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">

				<!-- Horizontal form -->
				<div class="panel panel-flat">
					<div class="panel-heading">
						<h5 class="panel-title"><? echo "Trader Account"; ?></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 trader_acc" action="<?php echo $action;?>" method="post" enctype="multipart/form-data">
						<input type="hidden" name="ijd" id="ijd" value="<?php echo $id;?>">
							<?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
								}
							?>

								<?php

								if($up_id)
				
								{
                              		 $co_id=$up_id->coin_id;
									$condition = "coid = '".$co_id."'";  
									$coin_info = $this->common_model->GetRow('coin_info',$condition);
                          ?>						

							<div class="form-block form-group">
								<label class="control-label col-lg-3 text-semibold"><?php echo "Trade Name" ?> <span class="text-danger">*</span></label>
								<div class="col-lg-3">
								  <input id="ac_name" value="<?php echo $up_id->trade_mode;?>" type="text"  name="trade_mode"  class="form-control" >
									
								</div>
							</div>

							<input type="hidden"  value="<?php echo $up_id->id;?>" name="id" id="id" class="form-control" />							

							<div class="form-group ">
								<label class="control-label col-lg-3 text-semibold"><?php echo "List Pairs"; ?> <span class="text-danger">*</span></label>
								<div class="col-lg-3">
									<select name="coin_id" id="select_payer_id" class="select-search form-control" >
										<option value="">None Selected</option>
									<?php 
					               		// $market_currency = $this->db->query("select * from coin_info")->getResult();
					               		 foreach ($required_pairs as $users) { ?>
										<option value="<?php echo $users; ?>" <?php if($trade->coinid == $users) echo "selected";?>><?php echo $users; ?> </option>
										<?php } ?>	
									</select>
									
								</div>
							</div>


                            <div class="form-group" id="stratgy">
                                <label class="control-label col-lg-3 text-semibold"><?php echo "Strategy Name" ?> <span class="text-danger">*</span> </label>
                                  <div class="col-lg-3">
                                    <input  type="text" value="<?php echo ucfirst($up_id->stratgy);?>" name="stratgy" class="form-control" >
                                    <div class="messageContainer"></div>
                                      
                                  </div>
                            </div>
                            <?php
                              $trader;
                            ?>
                            

                            <div  id="sel_strategy" class="form-group"  style="display:none">
								<label class="control-label col-lg-3 text-semibold"><?php echo "Strategy Name"; ?> <span class="text-danger">*</span></label>
								<div class="col-lg-4">
									<select name="stratgy1" id="strategy" class="select-search form-control" >
										<option ><?php echo lang('language_lang.none_selected'); ?></option>
					               		<?php foreach ($trader as $trade ) {?>
										<option value="<?php echo $trade->id; ?>" <?php if($trade){echo $trade->stratgy;}else{ echo '';}?>><?php echo ucfirst($trade->stratgy); ?></option>
										<?php } ?>	
									</select>
									
								</div>
							</div>


							 <div class="form-group <?php if($validation->getError('trade_image')) echo "has-error";?>">
	                          <label class="control-label col-lg-3 text-semibold"><?php echo "Trade Image";?> <span class="text-danger"> * </span> </label>
	                          <div class="col-lg-6">
	                          	<div>
	                          		<img src=<?php echo base_url().'/public/uploads/trader/'. $up_id->trade_image;?> width=100 height=100 >
	                          		
	                              <input type="file"  class="file-input-extensions" name="trade_image" id="trade_image" value="<?php echo set_value('trade_image', base_url('/public/uploads/trader/'.$up_id->trade_image)); ?>">
	                          		
	                          </div>
	                          <span class="help-block"><?php echo lang('language_lang.site_logo_extension');?></span>
	                              
	                              <?php echo $validation->getError('trade_image', '<div class="form-control-feedback"><i class="icon-cancel-circle2"></i></div><span class="help-block">', '</span>'); ?>
                                    <div class="messageContainer"></div>
	                          </div>
                        </div>
						

                            <div class="form-group">
                                <label class="control-label col-lg-3 text-semibold"><?php echo "profit (%)" ?>  <span class="text-danger">*</span></label>
                                  <div class="col-lg-3">
                                    <input type="text" value="<?php echo $up_id->profit;?>" name="profit" class="form-control" >
                                    <div class="messageContainer"></div>
                                      
                                </div>
                            </div>



                           <!--  <div class="form-group ">
								<label class="control-label col-lg-3 text-semibold"><?php echo "Duration(Days)"; ?> <span class="text-danger">*</span></label>
								<div class="col-lg-3">
									<div style="width:100%" class="input-group">
										<input type="text" name="duration" id="duration" class="form-control" placeholder="<?php echo "Duration"; ?>" value="<?php echo (isset($up_id->duration) ? $up_id->duration : ''); ?>" >

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


                              <div class="form-group">
                                <label class="control-label col-lg-3 text-semibold"><?php echo "Admin fees (%)" ?> <span class="text-danger">*</span> </label>
                                  <div class="col-lg-3">
                                        <input type="text" value="<?php echo $up_id->admin_fee;?>" name="admin_fee" class="form-control" >
                                      <div class="messageContainer"></div>
                                      
                                  </div>
                              </div>
 -->

                            <div class="form-group">
								<label class="control-label col-lg-3 text-semibold"><?php echo "Description"; ?> </label>
								<div class="col-lg-4">
									<div style="width:100%" class="input-group">
							        	<textarea class="" name="description" id="editor-readonly" style="width: 410px; height: 103px;" placeholder="Description"><?php echo (isset($up_id->description) ? $up_id->description : ''); ?></textarea>
									</div>
									
								</div>
							</div>

							<div class="form-group <?php if($validation->getError('address')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo "Address" ?> <span class="text-danger">*</span></label>
								<div class="col-lg-3">
									<input type="text" value="<?php echo $up_id->address;?>" name="address" id="address" class="form-control" >
									<?php echo $validation->getError('address', '<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($validation->getError('amount')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo "Amount" ?> <span class="text-danger">*</span></label>
								<div class="col-lg-3">
									<input type="text" value="<?php echo $up_id->amount;?>" name="amount" id="amount" class="form-control" ><?php echo $validation->getError('amount', '<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($validation->getError('facebook')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo "Facebook" ?></label>
								<div class="col-lg-3">
									<input type="text" value="<?php echo $up_id->facebook;?>" name="facebook" id="facebook" class="form-control" /><?php echo $validation->getError('facebook', '<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($validation->getError('twitter')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo "Twitter" ?></label>
								<div class="col-lg-3">
									<input type="text" value="<?php echo $up_id->twitter;?>" name="twitter" id="twitter" class="form-control" />
									<?php echo $validation->getError('twitter', '<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($validation->getError('youtube')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo "Youtube" ?></label>
								<div class="col-lg-3">
									<input type="text" value="<?php echo $up_id->youtube;?>" name="youtube" id="youtube" class="form-control" />
									<?php echo $validation->getError('youtube', '<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($validation->getError('telegram')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo "Telegram" ?></label>
								<div class="col-lg-3">
									<input type="text" value="<?php echo $up_id->telegram;?>" name="telegram" id="telegram" class="form-control" /><?php echo $validation->getError('telegram', '<div class="form-control-feedback"><i class="icon-cancel-circle2"></i></div><span class="help-block">', '</span>'); ?>	

								</div>
							</div>




							<div class="clearfix"><br></div>
							<div class="clearfix"><br></div>

							<div class="panel-heading">
								<h5 class="panel-title" style="margin-left:-15px;"><? echo "Trader Settings"; ?></h5>
								
		                	</div>


		                	<div class="clearfix"><br></div>


		                	<div class="form-group">
                                <label class="control-label col-lg-3 text-semibold"><?php echo "First Buy in Amount" ?> 
                                <span class="text-danger">*</span> </label><span>
                                	<div class="col-lg-3">
                                    	<input type="text" value="<?php echo (isset($up_id->first_buy_amount) ? $up_id->first_buy_amount : ''); ?>" name="first_buy_amount" id="first_buy_amount" class="form-control" >
                                    	<span  class="input-group-addon col-lg-1" style="margin-top:-38px;margin-left:258px;height:38px;width:50px;text-align-last: left;padding: 12px 10px;">USDT</span>
                                    	<div class="messageContainer"></div>
                               	 	</div>
                              	</span>
                             </div>


                             <?php
                             $query=$this->db->query("SELECT * FROM trader where id=1")->getResult();
                             $open_pos=$query[0];
                             $open_position_doubled=$open_pos->open_position_doubled;
                             ?>

                            <div class="form-group">
                                <label class="control-label col-lg-3 text-semibold"><?php echo "Open Position doubled" ?></label>
                                <div class="col-lg-8">
					            <div class="checkbox checkbox-switch" style="-webkit-box-sizing: border-box;-moz-box-sizing: border-box;">
					                	
									<label>
                                        <?php
                                	       $on='ON';
                                            $off='OFF';
                                    	?>
									   <input type="checkbox" class="switch" data-on-text="<?php echo $on?>" data-off-text="<?php echo $off; ?>" data-on-color="primary" data-off-color="default" name="open_position_doubled" <?php if($up_id->open_position_doubled==='on'){ echo 'checked="checked"'; }   ?>>
									</label>
									
							    </div>
                             </div>
                         </div>


                            <div class="form-group">
                                <label class="control-label col-lg-3 text-semibold"><?php echo "Margin column limit" ?> <span class="text-danger">*</span> </label>
                                <div class="col-lg-3">
                                    <input type="text" value="<?php echo (isset($up_id->margin_column_limit) ? $up_id->margin_column_limit : ''); ?>" name="margin_column_limit" id="margin_column_limit" class="form-control" ><span class="input-group-addon col-lg-1" style="margin-top:-38px;margin-left:258px;height:38px;width:50px;text-align-last: left;padding: 12px 6px;">Times</span>
									<div class="messageContainer"></div>
                                    <div class="messageContainer"></div>
                                     
                                </div>
                            </div>


                              <div class="form-group">
                                <label class="control-label col-lg-3 text-semibold"><?php echo "Whole poistion take profit ratio" ?> <span class="text-danger">*</span> </label>
                                  <div class="col-lg-3">

                             		<input type="text" name="whole_profit_ratio" class="form-control"  placeholder="Whole poistion take profit ratio" value="<?php echo (isset($up_id->whole_profit_ratio) ? $up_id->whole_profit_ratio : ''); ?>" >

									<span class="input-group-addon col-lg-1" style="margin-top:-38px;margin-left:270px;height:38px;width:35px;padding: 12px 12px;">%</span>
									<div class="messageContainer"></div>
                                     
                                  </div>
                             </div>


                             <div class="form-group">
                                <label class="control-label col-lg-3 text-semibold"><?php echo "Whole poistion take profit callback" ?> <span class="text-danger">*</span> </label>
                                  <div class="col-lg-3">

                             		<input type="text" name="whole_profit_callback" class="form-control"  placeholder="Whole poistion take profit callback" value="<?php echo (isset($up_id->whole_profit_callback) ? $up_id->whole_profit_callback : ''); ?>" >

									<span class="input-group-addon col-lg-1" style="margin-top:-38px;margin-left:270px;height:38px;width:35px;text-align: left;padding: 12px 12px">%</span>
									<div class="messageContainer"></div>
                                     
                                  </div>
                             </div>
                             <div>
                                <label class="control-label col-lg-4 text-semibold"><?php echo "Margin Configuration" ?></label><br>
                            </div>

                         <div class="col-lg-12">
                        <div class="form-group col-lg-6" name="config_field" id="config_field">                        	
                                
                            <div class="col-lg-6">
						        <div class="modal-head">
                                	<label class="control-label col-lg-11 text-semibold"><?php echo "Margincall Drop" ?></label><br>
                                 </div>                             
 									<span class="col-lg-10" id="ex_demo1"></span>
 									<?php echo $validation->getError('margincall_drop', '<div class="form-control-feedback"><i class="icon-cancel-circle2"></i></div><span class="help-block">', '</span>'); ?>   
                            </div>

                             
                            <div class="col-lg-6">
						        <div class="modal-head">
                            	    <label class="control-label col-lg-11 text-semibold"><?php echo "Margin Buyin Ratio" ?></label>
                                </div><br>
                                  	<span class="col-lg-10" id="ex_demo2"></span>
                                   
                            </div>
                        </div>
                        <div class="form-group col-lg-6" name="config_field" id="config_field">
                            <div class="col-lg-8">
						        <div class="modal-head">
						            <label class="control-label col-lg-12 text-semibold"><?php echo "Distributed and take profit Allocation" ?><br><?php echo "Percentage of spilt-to-profit"?>
						        	</label>
						        </div>
						            <span class="col-lg-8" id="ex_demo" style="width:236px;"></span>
						            <div id="fld"></div>
						    </div>
                        </div>
                    </div>
                    <div class="<?php if($validation->getError('sub_position_callback')) echo "has-error";?>" id="subposition">
                    <div class="form-group">
                        <label class="control-label col-lg-3 text-semibold"><?php echo "Sub-position take-profit callback" ?></label>
                        <div class="col-lg-3">
                            <input type="text" value="<?php echo (isset($up_id->sub_position_callback) ? $up_id->sub_position_callback : ''); ?>" name="sub_position_callback" id="sub_position_callback" class="form-control" /><label class="input-group-addon col-lg-1" style="margin-top:-38px;margin-left:258px;height:38px;width:50px;text-align: left;padding: 12px 6px;">Times</label>
                        </div>
                	</div>
                	  <?php echo $validation->getError('sub_position_callback', '<div class="form-control-feedback"><i class="icon-cancel-circle2"></i></div><span class="help-block">', '</span>'); ?>
						    <div class="messageContainer"></div>                             
                                     
                </div>

                                  
                            


                             <div class="form-group">
                                <label class="control-label col-lg-3 text-semibold"><?php echo "Buy in callback" ?> <span class="text-danger">*</span> </label>
                                <div class="col-lg-3">

                             		<input type="text" name="buyin_callback" class="form-control"  placeholder="Buy in callback" value="<?php echo (isset($up_id->buyin_callback) ? $up_id->buyin_callback : ''); ?>" >

									<span class="input-group-addon col-lg-1" style="margin-top:-38px;margin-left:270px;height:38px;width:35px;padding: 12px 12px">%</span>
									<div class="messageContainer"></div>
                                     
                                  </div>
                             </div>

                              <div class="form-group <?php if($validation->getError('coin_id')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo "Strategy Mode"; ?> <span class="text-danger">*</span></label>
								<div class="col-lg-3">
									<select name="strategy_mode" id="strategy_mode" class="select-search form-control" >
										<option value=""><?php echo lang('language_lang.none_selected'); ?></option>
					   
					               		
										<option value="1" <?php if($up_id->strategy_mode == 1) echo "selected";?>>Whole ware house mode</option>
										<option value="2" <?php if($up_id->strategy_mode == 2) echo "selected";?>>Subbin mode</option>
										<option value="3" <?php if($up_id->strategy_mode == 3) echo "selected";?>>Subbin Realtime Settlement mode</option>
										
									</select>
									
									<?php echo $validation->getError('coin_id', '<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($validation->getError('coin_id')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo "Strategy Type"; ?> <span class="text-danger">*</span></label>
								<div class="col-lg-3">
									<select name="strategy_type" id="strategy_type" class="select-search form-control" >
										<option value=""><?php echo lang('language_lang.none_selected'); ?></option>
					               		<option value="Cycle Strategy" <?php if($up_id->strategy_type == "Cycle Strategy") echo "selected";?>>Cycle Strategy</option>
										<option value="Oneshot Strategy" <?php if($up_id->strategy_type == "Oneshot Strategy") echo "selected";?>>Oneshot Strategy</option>
									</select>
									<?php echo $validation->getError('coin_id', '<div class="form-control-feedback"><i class="icon-cancel-circle2"></i></div><span class="help-block">', '</span>'); ?>	
								</div>
							</div>



                          	<input type="hidden" name="recid" value="<?php echo $coin; ?>" >

							<div class="clearfix"><br></div>

							<div class="text-right col-lg-7">
	                            <button id="btn" type="submit" class="btn btn-primary"><?php echo lang('language_lang.button_update'); ?> <i class="icon-arrow-right14 position-right"></i></button>
							</div>
					<?php } ?>	</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() {
			var num = $('#margin_column_limit').val();

			$('.trader_acc').formValidation({
		    	framework: 'bootstrap',
		    	excluded: [':disabled'],
		        icon: {
		            validating: 'glyphicon glyphicon-refresh'
		        },
		        fields: {
		            trade_mode: {
		            	validators: {
							notEmpty: {
							    message: '<?php echo "Trade Mode Cannot be Empty";?>'
							}
		               }
		            },
		            coin_id: {
		                message: '<?php echo "Select Coin";?>',
		                validators: 
		                {
		                   notEmpty: {
							    message: '<?php echo "Coin Cannot be Empty";?>'
							}
		                }
		            },
		            
		          
		            stratgy: {
		                message: '<?php echo "Enter stratgy";?>',
		                validators: {
		                    notEmpty: {
							    message: '<?php echo "Strategy Name Cannot be Empty";?>'
							}
		                }
		            },
		                
		            profit: {
		                message: '<?php echo "Profit Required";?>',
		                validators: {
		                    notEmpty: {
		                        message: '<?php echo "Enter Account Number";?>'
		                    },
		                    regexp: {
                                        regexp: /^[0-9.]+$/,
                                        message: '<?php echo "Values only in numbers"; ?>'
                                    }
		                }
		            },
		            trade_image: {
			            validators: {
			                file: {
			                    extension: 'jpg,jpeg,png,gif',
			                    type: 'image/jpg,image/jpeg,image/png, image/png',
			                    message: '<?php echo "Please choose Your Trader Image";?>'
			                }
			            }
			        },
		              
					 duration: {
					                message: '',
					                validators: {
					                    notEmpty: {
					                        message: "The Trade duration is required and can\'t be empty"
					                    },
					                  }
					            },
		             admin_fee: {
		                message: '<?php echo "Fees Reuired";?>',
		                validators: {
		                    notEmpty: {
		                        message: '<?php echo "Enter Account Number";?>'
		                    },
		                    regexp: {
                                        regexp: /^[0-9.]+$/,
                                        message: '<?php echo "Values only in number Format"; ?>'
                                    }
		               			 }
		           			 },
		           			 duration: {
		              
		                validators: {
		                    notEmpty: {
		                        message: '<?php echo "Enter Duration Days";?>'
		                    },
		                    regexp: {
                                        regexp: /^[0-9.]+$/,
                                        message: '<?php echo "Values only in number Format"; ?>'
                                    }
		               			 }
		           			 },
		           	description: {
		                message: '<?php echo "Description Required";?>',
		                validators: {
		                    notEmpty: {
		                        message: '<?php echo "Enter Account Number";?>'
		                    			}		                   
		               			 	}
		           			 },
		           	first_buy_amount: {
		                message: '<?php echo "First buyin amount Required";?>',
		                validators: {
		                    notEmpty: {
		                        message: '<?php echo "First buyin amount Required";?>'
		                    			},
		                    	regexp: {
                                        regexp: /^[0-9.]+$/,
                                        message: '<?php echo "Values only in numbers"; ?>'
                                    }		                   
		               			 	}
		           			 },
		           	margin_column_limit: {
		                message: '<?php echo "Margin Column Limit Required";?>',
		                validators: {
		                    notEmpty: {
		                        message: '<?php echo "Margin Column Limit Required";?>'
		                    			},
		                    	regexp: {
                                        regexp: /^[0-9.]+$/,
                                        message: '<?php echo "Values only in numbers"; ?>'
                                    }		                   
		               			 	}
		           			 },
		            whole_profit_ratio: {
		                message: '<?php echo "Whole poistion take profit ratio";?>',
		                validators: {
		                    notEmpty: {
		                        message: '<?php echo "Whole poistion take profit ratio";?>'
		                    			},

		                    	regexp: {
                                        regexp: /^[0-9.]+$/,
                                        message: '<?php echo "Values only in numbers"; ?>'
                                    }		                   
		               			 	}
		           			 },
		           	whole_profit_callback: {
		                message: '<?php echo "Whole poistion take profit callback";?>',
		                validators: {
		                    notEmpty: {
		                        message: '<?php echo "Whole poistion take profit callback";?>'
		                    			},

		                    	regexp: {
                                        regexp: /^[0-9.]+$/,
                                        message: '<?php echo "Values only in numbers"; ?>'
                                    }		                   
		               			 	}
		           			 },
		           	address: {
		                message: '<?php echo "Address";?>',
		                validators: {
		                    notEmpty: {
		                        message: '<?php echo "Address";?>'
		                    			}		                   
		               			 	}
		           			 },
		           	amount: {
		                message: '<?php echo "Enter Amount";?>',
		                validators: {
		                    notEmpty: {
		                        message: '<?php echo "Enter Amount";?>'
		                    			},
		                    		regexp: {
                                        regexp: /^[0-9.]+$/,
                                        message: '<?php echo "Values only in numbers"; ?>'
                                    }		                   
		               			 	}
		           			 },
		           	buyin_callback: {
		                message: '<?php echo "Enter Buy In Callback Value";?>',
		                validators: {
		                    notEmpty: {
		                        message: '<?php echo "Enter Buy In Callback Value";?>'
		                    			},
		                    		regexp: {
                                        regexp: /^[0-9.]+$/,
                                        message: '<?php echo "Values only in numbers"; ?>'
                                    }		                   
		               			 	}
		               			 }
		           
		        }
		    });
			

			$('.select-search').select2();


            $('#select_payer_id').change(function(){

      			var coin_id = $('#select_payer_id').val();
      			

      			if(coin_id) {
		        	$.ajax({
		                type: 'post',
		                url : '<?php echo base_url();?>/admin/finance/trader',
		                data : {'coin_id':coin_id, 'trade_mode':trade_mode},
		                success : function(msg)
		                {
		                   
		                }
		            });
				}
      
             });
 			$(".deposit_date").datepicker({
	            	dateFormat: 'yy-mm-dd',
	            	maxDate: 0
	            }).on('change', function(e) {
	            	$('.trader_acc').formValidation('revalidateField','deposit_date');
	            })

			});	
 			 


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

		$(".switch").bootstrapSwitch();

	});
	})(jQuery);


	</script>  

	<script type="text/javascript">
	jQuery.noConflict();
	(function( $ ) {
	$(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 } ?>

		$('.multiselect-full-featured1').multiselect({
		        includeSelectAllOption: true,
		        enableFiltering: true,
		        enableCaseInsensitiveFiltering: true,
		        templates: {
		            filter: '<li class="multiselect-item multiselect-filter"><i class="icon-search4"></i> <input class="form-control" type="text"></li>'
		        },
		        onSelectAll: function() {
		            $.uniform.update();
		        }
		    });

		    $(".styled, .multiselect-container input").uniform({ radioClass: 'choice'});


		$(document).ready(function() {

			$('.select-search').select2();           

            $('#select_payer_id').change(function(){
      			var coin_id = $('#select_payer_id').val();      			
      
             });

	});
	})
})(jQuery);

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

                    $(document).ready(function() {
                    	$('#subposition').css('display', 'none');
                    	var id= $('#id').val();
						    // var num = 7;
				var num = $('#margin_column_limit').val();

				if(num>=5)
				{
					$('#subposition').css('display', 'block');
				}
				else
				{
					$('#subposition').css('display', 'none');
				}
				

				$.ajax({

					type: 'post',
					dataType:'html',
					url : '<?php echo base_url();?>/admin/finance/config_field1',
					data : {'number1':num,'id':id},
					headers: {'X-Requested-With': 'XMLHttpRequest'},
					success : function(msg)
						{

							if(msg)
							{
								$('#ex_demo1').html(msg);
							}
						}
				});

				$.ajax({
					type: 'post',
					dataType:'html',
				    url : '<?php echo base_url();?>/admin/finance/config_field2',
				    data : {'number2':num,'id':id},
				    headers: {'X-Requested-With': 'XMLHttpRequest'},
				    success : function(msg)
				    {
					    if(msg)
					    {
						    $('#ex_demo2').html(msg);
					    }
				    }
				});

				$.ajax({
					type: 'post',
					dataType:'html',
				    url : '<?php echo base_url();?>/admin/finance/config_field0',
				    data : {'number':num,'id':id},
					headers: {'X-Requested-With': 'XMLHttpRequest'},
				    success : function(msg)
				    {
					    if(msg)
					    {
						    $('#ex_demo').html(msg);
						}
					}
				});
                    	
                    	$.jGrowl.defaults.closer = false;

				        <?php if(isset($form_err_data)) { ?>
				          $.jGrowl('<?php echo trim($form_err_data);?>', {
				                  header: '<?php echo lang("language_lang.error");?>',
				                  theme: 'bg-danger'
				              });
				        <?php } ?>


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

			
			$(document).on("keyup", '#margin_column_limit', function() {
    
					var id= $('#id').val();
						    // var num = 7;
				var num = $('#margin_column_limit').val();
				if(num>=5)
				{
					$('#subposition').css('display', 'block');
				}
				else
				{
					$('#subposition').css('display', 'none');
				}
				

				$.ajax({

					type: 'post',
					dataType:'html',
					url : '<?php echo base_url();?>/admin/finance/config_field4',
					data : {'number1':num,'id':id},
					headers: {'X-Requested-With': 'XMLHttpRequest'},
					success : function(msg)
						{

							if(msg)
							{
								$('#ex_demo1').html(msg);
							}
						}
				});

				$.ajax({
					type: 'post',
					dataType:'html',
				    url : '<?php echo base_url();?>/admin/finance/config_field5',
				    data : {'number2':num,'id':id},
				    headers: {'X-Requested-With': 'XMLHttpRequest'},
				    success : function(msg)
				    {
					    if(msg)
					    {
						    $('#ex_demo2').html(msg);
					    }
				    }
				});

				$.ajax({
					type: 'post',
					dataType:'html',
				    url : '<?php echo base_url();?>/admin/finance/config_field3',
				    data : {'number':num,'id':id},
					headers: {'X-Requested-With': 'XMLHttpRequest'},
				    success : function(msg)
				    {
					    if(msg)
					    {
						    $('#ex_demo').html(msg);
						}
					}
				});

			});



		   
		        })
                        
                    });
                    
                   

                })(jQuery);
            
        </script>
<script type="text/javascript">
jQuery.noConflict();
(function( $ ) {
	$(function() {
		$(document).ready(function() {
			 var form = $(".trader_acc");
          	
            form.on("submit",function () {
            for($i = 0; $i<=$num ;$i++ )
		   { 
                $('.margincall_drop$i').each(function() 
               {
        			$(this).rules("margincall_drop$i", 
            		{
            			validators{
		                	notEmpty: {
					                 messages: "All Fields in Margin Configuration is required",
					              }
					          }
					 });
			 

            	})
        	}
          });
    });
	});
});(jQuery);

</script>


</body>
</html>
