<html lang="en">
<head>

	<!-- header -->
		<?php 
		helper('form');
		$session = \Config\Services::session();
		$validation = \Config\Services::validation();


		echo 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 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.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 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 
							if(isset($cur_data->currency_id)) { 
								echo lang('language_lang.cur_edit_page_title');
							} else {
								echo lang('language_lang.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="<?= 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('name')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo lang('language_lang.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" id="name" class="form-control" placeholder="<?php echo lang('language_lang.place_cur_name'); ?>" value="<?php echo set_value('name',isset($cur_data->currency_name) ? ucfirst($cur_data->currency_name) : ''); ?>">
									</div>
									<?php echo $validation->getError('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($validation->getError('unit')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo lang('language_lang.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" class="form-control"  placeholder="<?php echo lang('language_lang.place_cur_unit'); ?>" value="<?php echo set_value('code',isset($cur_data->currency_unit) ? strtoupper($cur_data->currency_unit) : ''); ?>">
									</div>
									<?php echo $validation->getError('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($validation->getError('symbol')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo lang('language_lang.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 lang('language_lang.place_cur_symbol'); ?>" value="<?php echo set_value('symbol',isset($cur_data->currency_symbol) ? $cur_data->currency_symbol : ''); ?>">
									</div>
									<?php echo $validation->getError('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($validation->getError('deimal_point')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo lang('language_lang.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 lang('language_lang.place_cur_decimal_point'); ?>" value="<?php echo set_value('deimal_point',isset($cur_data->deimal_point) ? $cur_data->deimal_point : ''); ?>">
									</div>
									<?php echo $validation->getError('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($validation->getError('seprator')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo lang('language_lang.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 lang('language_lang.place_cur_seprator'); ?>" value="<?php echo set_value('symbol',isset($cur_data->seprator) ? $cur_data->seprator : ''); ?>">
									</div>
									<?php echo $validation->getError('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($validation->getError('default')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo lang('language_lang.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 lang('language_lang.On');?>" data-off-text="<?php echo lang('language_lang.Off');?>" class="switchery">
										</label>
									</div>
									<?php echo $validation->getError('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($validation->getError('status')) echo "has-error";?>">
								<label class="control-label col-lg-3 text-semibold"><?php echo lang('language_lang.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 lang('language_lang.On');?>" data-off-text="<?php echo lang('language_lang.Off');?>" class="switchery">
										</label>
									</div>
									<?php echo $validation->getError('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 lang('language_lang.button_update'); } else { 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 } ?>

			    $('.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 lang("language_lang.cur_name_valid");?>',
			                validators: {
			                    notEmpty: {
			                        message: '<?php echo lang("language_lang.cur_name_required");?>'
			                    },
			                    stringLength: {
			                        min: 4,
			                        message: '<?php echo lang("language_lang.cur_name_long");?>'
			                    },
			                    regexp: {
			                        regexp: /^[a-z]+$/i,
			                        message: '<?php echo lang("language_lang.cur_name_must");?>'
			                    }
			                }
			            },
			            unit: {
			                message: '<?php echo lang("language_lang.cur_unit_valid");?>',
			                validators: {
			                    notEmpty: {
			                        message: '<?php echo lang("language_lang.cur_unit_required");?>'
			                    },
			                    stringLength: {
			                        min: 3,
			                        max: 4,
			                        message: '<?php echo lang("language_lang.cur_unit_long");?>'
			                    },
			                    regexp: {
			                        regexp: /^[a-z]+$/i,
			                        message: '<?php echo lang("language_lang.cur_code_must");?>'
			                    }
			                }
			            },
			            symbol: {
			                message: '<?php echo lang("language_lang.cur_symbol_valid");?>',
			                validators: {
			                    notEmpty: {
			                        message: '<?php echo lang("language_lang.cur_symbol_required");?>'
			                    },
			                    stringLength: {
			                        min: 1,
			                        max: 10,
			                        message: '<?php echo lang("language_lang.cur_symbol_long");?>'
			                    }
			                }
			            },
			            deimal_point: {
			                message: '<?php echo lang("language_lang.cur_point_valid");?>',
			                validators: {
			                    notEmpty: {
			                        message: '<?php echo lang("language_lang.cur_point_required");?>'
			                    },
			                    stringLength: {
			                        min: 1,
			                        max: 1,
			                        message: '<?php echo lang("language_lang.cur_point_long");?>'
			                    },
			                    regexp: {
			                        regexp: /^[0-9]/,
			                        message: '<?php echo lang("language_lang.cur_point_must");?>'
			                    }
			                }
			            }
			            //,
			            // seprator: {
			            //     message: '<?php echo lang("language_lang.cur_seprator_valid");?>',
			            //     validators: {
			            //         notEmpty: {
			            //             message: '<?php echo lang("language_lang.cur_seprator_required");?>'
			            //         },
			            //         stringLength: {
			            //             min: 1,
			            //             max: 1,
			            //             message: '<?php echo lang("language_lang.cur_seprator_long");?>'
			            //         },
			            //         regexp: {
			            //             regexp: /[-!$%^&*()_+|~=`{}\[\]:";'<>?,.\/]/,
			            //             message: '<?php echo lang("language_lang.cur_seprator_must");?>'
			            //         }
			            //     }
			            // }
			            
			        }
			    })

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

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

</body>
</html>
