<!DOCTYPE html>
<html lang="en">
<head>
	<!-- Main navbar -->
		<?php $this->load->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>
	
	<!-- Bootsrap swith and validation css files -->	
	<link href="<?php echo base_url();?>/assets/boots/css/bootstrap-switch.css" rel="stylesheet" type="text/css">
	<link href="<?php echo base_url();?>/assets/boots/css/formValidation.min.css" rel="stylesheet" type="text/css">
	
	<!-- 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>    
    div.checker {
    	top: 18px !important;
    }
    .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('promo_banner_title_lbl'); ?></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/'.$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 
						if(isset($banner_data->banner_id)) { 
                           echo $this->lang->line('promotion_edit_title');
                        }
                        else{
                           echo $this->lang->line('promotion_add_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>
                	
					<div class="panel-body">
						<form class="form-horizontal slider" 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);
								}
							?>

							<div class="form-group  <?php if(form_error('banner_title')) echo "has-error";?>">
								<label class="control-label col-lg-2 text-semibold"><?php echo $this->lang->line('banner_title_lbl'); ?> <span class="text-danger">*</span></label>
								<div class="col-lg-6">
									<div class="">
										<input type="text" name="banner_title" id="title" class="form-control" placeholder="<?php echo $this->lang->line('promotion_title_lbl'); ?>" value="<?php echo set_value('banner_title',isset($banner_data->banner_title) ? $banner_data->banner_title : ''); ?>">
									</div>
									<?php echo form_error('banner_title', '<div class="form-control-feedback"></div><span class="help-block">', '</span>'); ?>
								</div>
							</div>

							<div class="form-group  <?php if(form_error('banner_image')) echo "has-error";?>">
								<label class="control-label col-lg-2 text-semibold"><?php echo $this->lang->line('banner_image_lbl'); ?> <span class="text-danger">*</span></label>
								<div class="col-lg-6">
									<div>
										<input type="file" name="banner_image" class="file-input-extensions" value="<?php echo set_value('banner_image', isset($banner_data->banner_image) ? $banner_data->banner_image : '' ); ?>">
									</div>
									<span class="help-block"><?php echo $this->lang->line('slider_image_extension');?></span>
									<?php echo form_error('banner_image', '<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('banner_description')) echo "has-error";?>">
								<label class="control-label col-lg-2 text-semibold"><?php echo $this->lang->line('lbl_slider_description'); ?> <span class="text-danger">*</span></label>
								<div class="col-lg-6">
									<div style="width:100%" class="input-group">
							       		<textarea class="form-control elastic" name="banner_description" rows="5" cols="4" placeholder="<?php echo $this->lang->line('plac_slider_content'); ?>"><?php echo set_value('banner_description',isset($banner_data->banner_description) ? $banner_data->banner_description : ''); ?></textarea>
									</div>
									<?php echo form_error('banner_description', '<div class="form-control-feedback"><i class="icon-cancel-circle2"></i></div><span class="help-block">', '</span>'); ?>
								</div>
							</div>

							<?php 
								if(isset($banner_data->banner_id)) { 
									$banner_status = $banner_data->banner_status;
								} else {
									$banner_status = '';
								}
							?>
							<!-- Switch single -->
							<div class="form-group <?php if(form_error('banner_status')) echo "has-error";?>">
								<label class="control-label col-lg-2 text-semibold"><?php echo $this->lang->line('lbl_slider_status'); ?> </label>
								<div class="col-lg-6">
									<div class="checkbox checkbox-switch">
										<label>
											<input type="checkbox" <?php if($banner_status==='on' || $banner_status===''){ echo 'checked="checked"'; }   ?> name="banner_status" data-on-color="success" data-off-color="danger" data-on-text="<?php echo $this->lang->line('On');?>" data-off-text="<?php echo $this->lang->line('Off');?>" class="switchery">
										</label>
									</div>
									<?php echo form_error('banner_status', '<label class="validation-error-label">', '</label>'); ?>
								</div>
							</div>
							
							<?php 
								if(isset($banner_data->banner_id)) { 
							?>
							<input type="hidden" name="banner_id" value="<?php echo $banner_data->banner_id;?>"/>
							<?php } ?>

							<div class="text-right col-lg-8">
								<button type="submit" class="btn btn-primary"><?php if(isset($banner_data->banner_id)) {  echo $this->lang->line('button_update'); } else { echo $this->lang->line('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(isset($form_err_data)) { ?>
					$.jGrowl('<?php echo trim($form_err_data);?>', {
			            header: '<?php echo $this->lang->line("error");?>',
			            theme: 'bg-danger'
			        });
				<?php } ?>


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

			    $('.slider').formValidation({
			    	framework: 'bootstrap',
			    	excluded: [':disabled'],
			        icon: {
			            validating: 'glyphicon glyphicon-refresh'
			        },
			        fields: {
			        	banner_title: {
			                validators: {
			                    notEmpty: {
			                        message: '<?php echo $this->lang->line("banner_title_required");?>'
			                    },
			                    stringLength: {
			                        min: 10,
			                        message: '<?php echo $this->lang->line("promotional_banner_title_min");?>'
			                    }
			                }
			            },

			          <?php  if(isset($banner_data->banner_id)) { ?>
			            banner_image: {
				            validators: {
				                file: {
				                    extension: 'jpg,jpeg,png,gif',
				                    type: 'image/gif,image/jpg,image/jpeg,image/png, image/png',
				                    message: '<?php echo $this->lang->line("promotional_banner_image_must");?>'
				                }
				            }
				        },
				        <?php } else { ?>

				        	banner_image: {
				            validators: {
				            	notEmpty: {
			                        message: '<?php echo $this->lang->line("banner_image_required");?>'
			                    },
				                file: {
				                    extension: 'jpg,jpeg,png,gif',
				                    type: 'image/gif,image/jpg,image/jpeg,image/png, image/png',
				                    message: '<?php echo $this->lang->line("promotional_banner_image_must");?>'
				                }
				            }
				        },
				        <?php } ?>
			            banner_description: {
			                validators: {
			                    notEmpty: {
			                        message: '<?php echo $this->lang->line("banner_description_required");?>'
			                    },
			                    stringLength: {
			                        min: 20,
			                        message: '<?php echo $this->lang->line("promotional_banner_description_min");?>'
			                    },
			                }
			            }
			            
			        }
			    })
				

			});

			$(".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($banner_data->banner_image)) { ?>
			    	initialPreview: ["<?php echo base_url();?>content/banner/<?php echo $banner_data->banner_image;?>"],
			    	initialPreviewAsData: true, 
			    	initialPreviewFileType: 'image',
			    <?php } ?>
			    allowedFileExtensions: ["jpg", "gif", "png", "jpeg"],
			    uploadExtraData: {
			        img_key: "1000"
			    }
			});
		    
		 	$('#icon-bck').on('click',function() {
				window.history.back();
			});
			
		    $(".switchery").bootstrapSwitch();
		    // $("#countries").msDropdown();

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

</body>
</html>
