<!DOCTYPE html>
<html lang="en">
<head>
	<!-- Main navbar -->
		<?php
        helper('form');
		$session = session();
		$validation = \Config\Services::validation();
		echo view('admin/common_header'); ?>
	<!-- /main navbar -->
	


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

	<!-- 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>
	

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

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

	<!-- 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>
    <!-- Theme JS files -->
	<script type="text/javascript" src="<?php echo base_url('assets/ckeditor/ckeditor.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>
	<script type="text/javascript" src="<?php echo base_url('assets/js/plugins/forms/selects/select2.min.js');?>"></script>

	<script type="text/javascript" src="<?php echo base_url('assets/js/core/app.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 -->
    
    

</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 -->
	<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">Trade Pairs Settings</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">
					   Add Trade Pairs
						</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>
                	
					<div class="panel-body">
						<form class="form-horizontal tradepair" action="<?=site_url($action);?>" method="post" enctype="multipart/form-data">
							<?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  <?php if($validation->getError('coin_name')) echo "has-error";?>">
								<label class="control-label col-lg-2 text-semibold">Coin Name <span class="text-danger">*</span></label>
								<div class="col-lg-4">
									<div style="width:100%" class="input-group">
									<input name="coin_name" class="form-control elastic" cols="4" rows="3" placeholder="Enter Coin Name (ex:bitcoin)" value="<?php echo set_value('coin_name',isset($pairdata->coin_name) ? ucfirst($pairdata->coin_name) : ''); ?>">
									</div>
									<?php echo $validation->getError('coin_name', '<div class="form-control-feedback"></div><span class="help-block">', '</span>'); ?>
								</div>
							</div>

                            <div class="form-group  <?php if($validation->getError('pair_name')) echo "has-error";?>">
								<label class="control-label col-lg-2 text-semibold">Pair Name <span class="text-danger">*</span></label>
								<div class="col-lg-4">
									<div style="width:100%" class="input-group">
									<input name="pair_name" class="form-control elastic" cols="4" rows="3" placeholder="Enter Pair Name (ex: BTC)" value="<?php echo set_value('pair_name',isset($pairdata->pair_name) ? ucfirst($pairdata->pair_name) : ''); ?>">
									</div>
									<?php echo $validation->getError('pair_name', '<div class="form-control-feedback"></div><span class="help-block">', '</span>'); ?>
								</div>
							</div>


								
							<div class="form-group  <?php if($validation->getError('coin_image')) echo "has-error";?>">
								<label class="control-label col-lg-2 text-semibold"> Upload Image <span class="text-danger">*</span></label>
								
								<div class="col-lg-4">
									<div>
										<input type="file" name="coin_image" class="file-input-extensions" value="<?php echo set_value('coin_image', isset($pairdata->coin_image) ? "/..".$pairdata->coin_image : '' ); ?>">
									</div>
									<span class="help-block"><?php echo lang('language_lang.site_logo_extension');?></span>
									<?php echo $validation->getError('coin_image', '<div class="form-control-feedback"><i class="icon-cancel-circle2"></i></div><span class="help-block">', '</span>'); ?>
								</div>
							</div>
							

							<?php 
								if(isset($pairdata->id)) { 
									$coin_status = $pairdata->status;
								} else {
									$coin_status = '';
								}
							?>
							<!-- Switch single -->
							<div class="form-group <?php if($validation->getError('coin_status')) echo "has-error";?>">
								<label class="control-label col-lg-2 text-semibold"><?php echo lang('language_lang.faq_status'); ?> </label>
								<div class="col-lg-6">
									<div class="checkbox checkbox-switch">
										<label>
											<input type="checkbox" <?php if($coin_status==='1' || $coin_status===''){ echo 'checked="checked"'; }   ?> name="coin_status" data-on-color="success" data-off-color="danger" data-on-text="<?php echo lang('language_lang.On');?>" data-off-text="<?php echo lang('language_lang.Off');?>" class="switchery">
										</label>
									</div>
									<?php echo $validation->getError('coin_status', '<label class="validation-error-label">', '</label>'); ?>
								</div>
							</div>
							<!-- /switch single -->

						   <div class="text-right col-lg-4">
								<button type="submit" class="btn btn-primary"><?php  echo lang('language_lang.button_save');  ?> <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 } ?>

	          

			    $('.tradepair').formValidation({
			    	framework: 'bootstrap',
			    	excluded: [':disabled'],
			        icon: {
			            validating: 'glyphicon glyphicon-refresh'
			        },
			        fields: {
			            coin_name: {
			                message: '<?php echo "Coin name is invalid";?>',
			                validators: {
			                    notEmpty: {
			                        message: '<?php echo "Coin name is required and can not be empty";?>'
			                    }
			                }
			            },
			            pair_name: {
			                message: '<?php echo "Pair name is invalid";?>',
			                validators: {
			                    notEmpty: {
			                        message: '<?php echo "Pair name is required and can not be empty";?>'
			                    }
			                }
			            },
			   
			            
			        }
			    })
				

			});

            $(".file-input-extensions").fileinput({
		    uploadUrl: "http://localhost/file-upload-single/1", // server upload action
		    uploadAsync: false,
		    minFileCount: 1,
		    maxFileCount: 1,
		    overwriteInitial: true,
		    showUpload: false,
		    <?php //if(isset($news_data->news_image)) { ?>
		    	// initialPreview: ["<?php //echo base_url('assets/images/news/'.$news_data->news_image);?>"],
		    	// initialPreviewAsData: true, // identify if you are sending preview data only and not the raw markup
		    	// initialPreviewFileType: 'image', // image is the default and can be overridden in config below
		    <?php //} ?>
		    allowedFileExtensions: ["jpg", "gif", "png", "jpeg"],
		    uploadExtraData: {
		        img_key: "10000"
		    }
		});

		    // $('[name="page_content"]').ckeditor();
		 	$('#icon-bck').on('click',function() {
				window.history.back();
			});
			
		    $(".switchery").bootstrapSwitch();
		    // $("#countries").msDropdown();

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

</body>
</html>
