<?php $this->load->view('header');?>

	<div class="row-fluid">
		<div class="span12">

			<!-- BEGIN PAGE TITLE & BREADCRUMB-->

			<h3 class="page-title"><?php echo $this->lang->line('hf_currency_rate');?> </h3>

			<ul class="breadcrumb">

				<li><i class="icon-home"></i><a href="<?php echo base_url();?>home/"><?php echo $this->lang->line('hf_home');?></a> <i class="icon-angle-right"></i></li>
				<li><?php echo $this->lang->line('hf_setting');?> <i class="icon-angle-right"></i></li>
				<li><?php echo $this->lang->line('hf_currency_rate');?></li>
			</ul>
			<!-- END PAGE TITLE & BREADCRUMB-->
		</div>
	</div>
	
	<div class="row-fluid">
		<div class="span12">
			<form id="currency_rate-form" class="form-horizontal" method="post" action="<?php echo base_url();?>setting/currency_rate_submit/" onsubmit="return validateForm('currency_rate-form')">
				<?php 
					$alert_box = '';
					$alert_msg = '';
					
					if($this->session->userdata('form_msg_type') == 100) {
						$alert_box = 'success';
						$alert_msg = $this->session->userdata('form_msg');
					}
					else if($this->session->userdata('form_msg_type') == 200) {
						$alert_box = 'error';
						$alert_msg = $this->session->userdata('form_msg');
					}
					
					if($this->session->userdata('form_msg_type') == 100 OR $this->session->userdata('form_msg_type') == 200) {
						$this->session->unset_userdata(array('form_msg_type' => '', 'form_msg' => ''));
					}

					if( ! empty($alert_msg)) {
				?>
				<div class="alert alert-<?php echo $alert_box;?>">
					<button class="close" data-dismiss="alert"></button>
					<?php echo $alert_msg;?>
				</div>
				<?php }?>
				
				<?php 
					if($currencies->num_rows() > 0) {
						foreach($currencies->result() as $row) {
				?>
					<input type="hidden" id="cid_<?php echo $row->currency_id;?>" name="cid[]" class="m-wrap medium" value="<?php echo (isset($row->currency_id) ? $row->currency_id : 0)?>" />
					<div class="control-group">
						<label class="control-label"><?php echo $this->lang->line(get_currency_type_without_symbol($row->currency_id));?> (<?php echo $this->lang->line('header_in');?>):</label>
						<div class="controls">
							<input type="text" id="drate_<?php echo $row->currency_id;?>" name="drate[]" class="m-wrap medium" value="<?php echo (isset($row->t_currency_rate) ? $row->t_currency_rate : 0)?>" />
						</div>
					</div>
					<div class="control-group">
						<label class="control-label"><?php echo $this->lang->line(get_currency_type_without_symbol($row->currency_id));?> (<?php echo $this->lang->line('header_out');?>):</label>
						<div class="controls">
							<input type="text" id="wrate_<?php echo $row->currency_id;?>" name="wrate[]" class="m-wrap medium" value="<?php echo (isset($row->w_currency_rate) ? $row->w_currency_rate : 0)?>" />
						</div>
					</div>
				<?php 
						} 
					}							
				?>
				
				<div class="control-group">
					<label class="control-label"><?php echo $this->lang->line('setting_security_key');?></label>
					<div class="controls">
						<input type="password" id="security_key" name="security_key" class="m-wrap medium" />
					</div>
				</div>
				
				<div class="form-actions">
					<input class="no_display" type="hidden" id="<?php echo $this->security->get_csrf_token_name(); ?>" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash(); ?>" />
					<button type="submit" class="btn blue"><i class="icon-ok"></i> <?php echo $this->lang->line('setting_submit');?></button>
				</div>
			</form>
		</div><!-- End span12 -->
		
	</div> <!-- End Row Fluid -->
	
<?php $this->load->view('footer');?>