<html lang="en">
<head>

	<!-- header -->
		<?php $this->load->view('admin/common_header'); ?>
	<!-- /header -->
	
	<!-- 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 -->
	
	
	<!-- 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>
</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('cur_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 $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($cur_data->currency_id)) { 
								echo $this->lang->line('cur_edit_page_title');
							} else {
								echo $this->lang->line('cur_create_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>
                	
					<div class="panel-body">
						<form class="form-horizontal currencysetting" 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);
							?>
									
									<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 class="form-group  <?php if(form_error('name')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo $this->lang->line('label_cur_name'); ?> <span class="text-danger">*</span></label>
								<div class="col-lg-4">
									<div class="input-group">
										<span class="input-group-addon"><i class="icon-cash2"></i></span>
										<input type="text" name="name" style="cursor:not-allowed;" readonly id="name" class="form-control" placeholder="<?php echo $this->lang->line('place_cur_name'); ?>" value="<?php echo set_value('name',isset($cur_data->currency_name) ? ucfirst($cur_data->currency_name) : ''); ?>">
									</div>
									<?php echo form_error('name', '<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('unit')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo $this->lang->line('label_cur_unit'); ?> <span class="text-danger">*</span></label>
								<div class="col-lg-4">
									<div class="input-group">
										<span class="input-group-addon"><i class="icon-cash2"></i></span>
										<input type="text" name="unit" style="cursor:not-allowed;" readonly class="form-control"  placeholder="<?php echo $this->lang->line('place_cur_unit'); ?>" value="<?php echo set_value('code',isset($cur_data->currency_unit) ? strtoupper($cur_data->currency_unit) : ''); ?>">
									</div>
									<?php echo form_error('unit', '<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('symbol')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo $this->lang->line('label_cur_symbol'); ?> <span class="text-danger">*</span></label>
								<div class="col-lg-4">
									<div class="input-group">
										<span class="input-group-addon"><i class="icon-cash2"></i></span>
										<input type="text" name="symbol" class="form-control"  placeholder="<?php echo $this->lang->line('place_cur_symbol'); ?>" value="<?php echo set_value('symbol',isset($cur_data->currency_symbol) ? $cur_data->currency_symbol : ''); ?>">
									</div>
									<?php echo form_error('symbol', '<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('deimal_point')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo $this->lang->line('label_cur_decimal_point'); ?> <span class="text-danger">*</span></label>
								<div class="col-lg-4">
									<div class="input-group">
										<span class="input-group-addon"><i class="icon-cash2"></i></span>
										<input type="text" name="deimal_point" class="form-control"  placeholder="<?php echo $this->lang->line('place_cur_decimal_point'); ?>" value="<?php echo set_value('deimal_point',isset($cur_data->deimal_point) ? $cur_data->deimal_point : ''); ?>">
									</div>
									<?php echo form_error('deimal_point', '<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('seprator')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo $this->lang->line('label_cur_seprator'); ?> <span class="text-danger">*</span></label>
								<div class="col-lg-6">
									<div class="input-group">
										<span class="input-group-addon"><i class="icon-cash2"></i></span>
										<input type="text" name="seprator" class="form-control"  placeholder="<?php echo $this->lang->line('place_cur_seprator'); ?>" value="<?php echo set_value('symbol',isset($cur_data->seprator) ? $cur_data->seprator : ''); ?>">
									</div>
									<?php echo form_error('seprator', '<div class="form-control-feedback"><i class="icon-cancel-circle2"></i></div><span class="help-block">', '</span>'); ?>
								</div>
							</div> -->

							<?php 
								if(isset($cur_data->currency_id)) { 
									$cur_default = $cur_data->currency_default;
								} else {
									$cur_default = '';
								}
							?>
							<!-- Switch single -->
							<div class="form-group <?php if(form_error('default')) echo "has-error";?>" style='display:none;'>
								<label class="control-label col-lg-3 text-semibold"><?php echo $this->lang->line('label_cur_default'); ?> </label>
								<div class="col-lg-6">
									<div class="checkbox checkbox-switch">
										<label>
											<input type="checkbox" <?php if($cur_default){ echo 'checked="checked"'; }   ?> name="default" 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('default', '<label class="validation-error-label">', '</label>'); ?>
								</div>
							</div>
							<!-- /switch single -->


							<?php 
								if(isset($cur_data->currency_id)) { 
									$cur_status = $cur_data->currency_status;
								} else {
									$cur_status = '';
								}
							?>
							<!-- Switch single -->
							<div class="form-group <?php if(form_error('status')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo $this->lang->line('label_cur_status'); ?> </label>
								<div class="col-lg-6">
									<div class="checkbox checkbox-switch">
										<label>
											<input type="checkbox" <?php if(!isset($cur_data->currency_id)) { echo 'checked'; } ?>  <?php if($cur_status){ echo 'checked="checked"'; }   ?> name="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('status', '<label class="validation-error-label">', '</label>'); ?>
								</div>
							</div>
							<!-- /switch single -->
							
							<?php 
								if(isset($cur_data->currency_id)) { 
							?>
							<input type="hidden" name="currency_id" value="<?php echo $cur_data->currency_id;?>"/>
							<?php } ?>

							<div class="text-right col-lg-7">
								<button type="submit" class="btn btn-primary"><?php if(isset($cur_data->currency_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($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 } ?>

			    $('.currencysetting').formValidation({
			    	framework: 'bootstrap',
			    	excluded: [':disabled'],
			        icon: {
			            // valid: 'glyphicon glyphicon-ok',
			            // invalid: 'glyphicon glyphicon-remove',
			            // validating: 'glyphicon glyphicon-refresh'
			        },
			        row: {
					    valid: 'has-success',
					    invalid: 'has-error'
					},
			        fields: {
			            name: {
			                message: '<?php echo $this->lang->line("cur_name_valid");?>',
			                validators: {
			                    notEmpty: {
			                        message: '<?php echo $this->lang->line("cur_name_required");?>'
			                    },
			                    stringLength: {
			                        min: 4,
			                        message: '<?php echo $this->lang->line("cur_name_long");?>'
			                    },
			                    regexp: {
			                        regexp: /^[a-z]+$/i,
			                        message: '<?php echo $this->lang->line("cur_name_must");?>'
			                    }
			                }
			            },
			            unit: {
			                message: '<?php echo $this->lang->line("cur_unit_valid");?>',
			                validators: {
			                    notEmpty: {
			                        message: '<?php echo $this->lang->line("cur_unit_required");?>'
			                    },
			                    stringLength: {
			                        min: 3,
			                        max: 4,
			                        message: '<?php echo $this->lang->line("cur_unit_long");?>'
			                    },
			                    regexp: {
			                        regexp: /^[a-z]+$/i,
			                        message: '<?php echo $this->lang->line("cur_code_must");?>'
			                    }
			                }
			            },
			            symbol: {
			                message: '<?php echo $this->lang->line("cur_symbol_valid");?>',
			                validators: {
			                    notEmpty: {
			                        message: '<?php echo $this->lang->line("cur_symbol_required");?>'
			                    },
			                    stringLength: {
			                        min: 1,
			                        max: 10,
			                        message: '<?php echo $this->lang->line("cur_symbol_long");?>'
			                    }
			                }
			            },
			            deimal_point: {
			                message: '<?php echo $this->lang->line("cur_point_valid");?>',
			                validators: {
			                    notEmpty: {
			                        message: '<?php echo $this->lang->line("cur_point_required");?>'
			                    },
			                    stringLength: {
			                        min: 1,
			                        max: 1,
			                        message: '<?php echo $this->lang->line("cur_point_long");?>'
			                    },
			                    regexp: {
			                        regexp: /^[0-9]/,
			                        message: '<?php echo $this->lang->line("cur_point_must");?>'
			                    }
			                }
			            }
			            //,
			            // seprator: {
			            //     message: '<?php echo $this->lang->line("cur_seprator_valid");?>',
			            //     validators: {
			            //         notEmpty: {
			            //             message: '<?php echo $this->lang->line("cur_seprator_required");?>'
			            //         },
			            //         stringLength: {
			            //             min: 1,
			            //             max: 1,
			            //             message: '<?php echo $this->lang->line("cur_seprator_long");?>'
			            //         },
			            //         regexp: {
			            //             regexp: /[-!$%^&*()_+|~=`{}\[\]:";'<>?,.\/]/,
			            //             message: '<?php echo $this->lang->line("cur_seprator_must");?>'
			            //         }
			            //     }
			            // }
			            
			        }
			    })

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

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

</body>
</html>
