<!DOCTYPE html>
<html lang="en">
<head>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
  <?php $this->load->view('front/includes/header-script')?>
  <title><?=FRONT_TITLE?></title>
  <script type="text/javascript">
    function class_total()
    {
      var a = document.getElementById("class_price_m").value;
      var b = document.getElementById("class_price_n").value;
      var c = document.getElementById("class_price_s").value;
      if (a == "")
        a = 0;
      if (b == "")
        b = 0;
      if (c == "")
        c = 0;
      var total = parseInt(a) + parseInt(b) + parseInt(c);
      if (!isNaN(total)) {
        document.getElementById("total").value = parseInt(total);
      }

    }
  </script>
  <script>
    function member(fid) 
    {
      var m_first_name = document.getElementById("m_first_name"+fid).value;          
      var m_last_name = document.getElementById("m_last_name"+fid).value;
      var m_email_id = document.getElementById("m_email_id"+fid).value;
      var m_phone_no = document.getElementById("m_phone_no"+fid).value;
      var result = m_first_name + '  ' + m_last_name + '  ' + m_email_id + '  ' + m_phone_no;
      document.getElementById('member'+fid).textContent = result;
    }
    function nonmember(fid) 
    {

      var n_first_name = document.getElementById("n_first_name"+fid).value;  
      var n_last_name = document.getElementById("n_last_name"+fid).value;
      var n_email_id = document.getElementById("n_email_id"+fid).value;
      var n_phone_no = document.getElementById("n_phone_no"+fid).value;
      var result = n_first_name + '  ' + n_last_name + '  ' + n_email_id + '  ' + n_phone_no;
      document.getElementById('nonmember'+fid).textContent = result;
    }
    function employer(fid) 
    {
      var s_first_name = document.getElementById("s_first_name"+fid).value;          
      var s_last_name = document.getElementById("s_last_name"+fid).value;
      var s_email_id = document.getElementById("s_email_id"+fid).value;
      var s_phone_no = document.getElementById("s_phone_no"+fid).value;
      var result = s_first_name + '  ' + s_last_name + '  ' + s_email_id + '  ' + s_phone_no;
      document.getElementById('employer'+fid).textContent = result;
    }
  </script>
</head>
<body>
  <header>
   <div class="container">
    <div class="logo d-flex">
     <img src="<?=base_url();?>assets/front/img/logo.jpg" alt=""> 
     <span class="d-flex align-items-center justify-content-center">
      <h1>Continuing Education Registration</h1>
    </span>
  </div>
</div>
</header>
<section class="abc-tab">
 <div class="container">
      <?php
    $success_msg= $this->session->flashdata('success_msg');
    $error_msg= $this->session->flashdata('error_msg');
    if($success_msg) { ?>
     <div class="alert alert-success">
       <?php echo $success_msg; ?>
       <a href="#" class="close" data-dismiss="alert" aria-label="close" >×</a>
     </div>
   <?php } if($error_msg){ ?>
     <div class="alert alert-danger">
      <a href="#" class="close" data-dismiss="alert" aria-label="close" >×</a>
       <?php echo $error_msg; ?>
     </div>
   <?php } ?>
  <div class="d-flex flex-row nav">
    <?php 
    $urlcheck = $this->uri->segment(2);
    if($urlcheck=="")
    {
      $urlcheck = isset($first_loc)? $first_loc : '';
    }
    foreach($reg_location as $value) { ?>
      <div><a class="<?php if($urlcheck==$value['locat_id']) { echo "active";} ?>" href="<?= base_url();?>loc-class/<?=$value['locat_id']?>"><?=$value['locat_name']?></a></div>
    <?php  } ?>
  </div>

  <?php
  foreach ($reg_class as $value) { ?>
    <?php echo form_open('reg-manage'); ?>
    <div class="abc-detail d-flex">
     <div class="title">
      <h2 class="justify-content-center d-flex">Class Title</h2>
      <div class="adv"><?=$value['class_name']?>  Hours<span class="hr-span"><?=$value['class_hours']?></span></div>
      <div class="date"><input type="checkbox" name="form_class[]" id="<?=$value['form_id']?>" value="<?=$value['form_id']?>">
       <label for="<?=$value['form_id']?>"></label>
       <span>Start Date:</span>
       <span><?=date("d-m-Y",strtotime($value['calss_start_date']))?></span>
       <span><?=date('h:i A',strtotime($value['calss_start_time']))?></span>
       <span><?=$value['class_day']?></span>
     </div>
   </div>
   <div class="seat">
    <h2 class="justify-content-center d-flex">Seats Remaining</h2>
    <span> 25</span>
  </div>
</div>
<br>
<div class="abc-expand <?=$value['form_id']?>">
 <?php $registrants = explode(",", $value['class_registrants']); 
 foreach ($registrants as $val)
 {
  if($val == "M") $m = true;
  if($val == "N") $n = true;
  if($val == "S") $s = true;
}
?>
<div class="member d-flex"> <?php if(isset($m)) { ?><span>Member / Alumni: $<?=$value['class_price_m']?>.00</span><?php } ?>   <?php if(isset($n)) { ?><span> Non -Member: $<?=$value['class_price_n']?>.00</span><?php } ?>     <?php if(isset($s)) { ?><span>SE: $<?=$value['class_price_s']?>.00</span><?php } ?></div>
<div class="d-flex class-des">
  <div class="col-md-5 no-pad">
   <h2>Class Description</h2>
   <p><?=$value['class_description']?></p>
   <span>Instructor:<?=$value['instr_name']?></span>
 </div>
 <div class="col-md-7">
   <h2>Class Details</h2>
   <p>Start Date: <?=date("d-m-Y",strtotime($value['calss_start_date']))?><br>
    End Date: <?=date("d-m-Y",strtotime($value['calss_end_date']))?><br>
    Time: <?=date('h:i A',strtotime($value['calss_start_time']))?> – <?=date('h:i A',strtotime($value['calss_end_time']))?><br>
    Location: <?=$value['class_room']?><br>
    Days of Week: <?=$value['class_day']?><br>
    Seats Available: <?=$value['class_seats']?><br>
  </p>
</div>
</div>
<div class="attendee">
  <h3>Attendee Info</h3>
  <?php if(isset($m)) { ?>
    <label>Member / Alumni</label>
    <div class="member flex-row d-flex flex-wrap">
     <div class="col-sm-10 no-pad">
      <ul class="d-flex">
        <input type="hidden" name="class_price_m_<?=$value['form_id']?>" id="class_price_m" value="<?=$value['class_price_m']?>"> 
        <li><input type="text" onKeyUp="member(1<?=$value['form_id']?>)" name="m_first_name_<?=$value['form_id']?>[]" id="m_first_name1<?=$value['form_id']?>" placeholder="First Name*"></li>
        <li><input type="text" onKeyUp="member(1<?=$value['form_id']?>)" name="m_last_name_<?=$value['form_id']?>[]" id="m_last_name1<?=$value['form_id']?>" placeholder="Last Name*"></li>
        <li><input type="email" onKeyUp="member(1<?=$value['form_id']?>)" name="m_email_id_<?=$value['form_id']?>[]" id="m_email_id1<?=$value['form_id']?>" placeholder="Email Address*"></li>
        <li><input type="text" onKeyUp="member(1<?=$value['form_id']?>)" name="m_phone_no_<?=$value['form_id']?>[]" id="m_phone_no1<?=$value['form_id']?>" placeholder="Phone Number*"></li>
      </ul>
    </div>
    <div class="col-sm-2 enroll-btnm" form-data="<?=$value['form_id']?>" mem-price="<?=$value['class_price_m']?>">
      <label class="d-flex">
       <span>+</span>
       <p>Enroll Attendee</p>
     </label>
   </div>
   <div class="col-sm-10 clone-append no-pad"> </div>
 </div>
<?php } if(isset($n)) { ?>
 <label>Non-Member</label>
 <div class="member flex-row d-flex flex-wrap">
   <div class="col-sm-10 no-pad">
    <ul class="d-flex">
      <input type="hidden" name="class_price_n_<?=$value['form_id']?>" id="class_price_n" value="<?=$value['class_price_n']?>"> 
      <li><input type="text" onKeyUp="nonmember(1<?=$value['form_id']?>)" name="n_first_name_<?=$value['form_id']?>[]" id="n_first_name1<?=$value['form_id']?>" placeholder="First Name*"></li>
      <li><input type="text" onKeyUp="nonmember(1<?=$value['form_id']?>)" name="n_last_name_<?=$value['form_id']?>[]" id="n_last_name1<?=$value['form_id']?>" placeholder="Last Name*"></li>
      <li><input type="email" onKeyUp="nonmember(1<?=$value['form_id']?>)" name="n_email_id_<?=$value['form_id']?>[]" id="n_email_id1<?=$value['form_id']?>" placeholder="Email Address*"></li>
      <li><input type="text" onKeyUp="nonmember(1<?=$value['form_id']?>)" name="n_phone_no_<?=$value['form_id']?>[]" id="n_phone_no1<?=$value['form_id']?>" placeholder="Phone Number*"></li>
    </ul>
  </div>
  <div class="col-sm-2 enroll-btnn" form-data="<?=$value['form_id']?>" nmem-price="<?=$value['class_price_n']?>">
    <label class="d-flex">
     <span>+</span>
     <p>Enroll Attendee</p>
   </label>
 </div>
 <div class="col-sm-10 clone-append no-pad"> </div>
</div>
<?php } if(isset($s)) { ?>
 <label>Subscribing Employer</label>
 <div class="member flex-row d-flex flex-wrap">
   <div class="col-sm-10 no-pad">
    <ul class="d-flex">
      <input type="hidden" name="class_price_s_<?=$value['form_id']?>" id="class_price_s" value="<?=$value['class_price_s']?>"> 
      <li><input type="text" onKeyUp="employer(1<?=$value['form_id']?>)" name="s_first_name_<?=$value['form_id']?>[]" id="s_first_name1<?=$value['form_id']?>" placeholder="First Name*"></li>
      <li><input type="text" onKeyUp="employer(1<?=$value['form_id']?>)" name="s_last_name_<?=$value['form_id']?>[]" id="s_last_name1<?=$value['form_id']?>" placeholder="Last Name*"></li>
      <li><input type="email" onKeyUp="employer(1<?=$value['form_id']?>)" name="s_email_id_<?=$value['form_id']?>[]" id="s_email_id1<?=$value['form_id']?>" placeholder="Email Address*"></li>
      <li><input type="text" onKeyUp="employer(1<?=$value['form_id']?>)" name="s_phone_no_<?=$value['form_id']?>[]" id="s_phone_no1<?=$value['form_id']?>" placeholder="Phone Number*"></li>
    </ul>
  </div>
  <div class="col-sm-2 enroll-btns" form-data="<?=$value['form_id']?>" smem-price="<?=$value['class_price_s']?>">
    <label class="d-flex">
     <span>+</span>
     <p>Enroll Attendee</p>
   </label>
 </div>
 <div class="col-sm-10 clone-append no-pad"> </div>
</div>
<?php } ?>
</div>
<div class="class-total">
  <h3>Class Totals</h3>
  <div class="alumi">
    <?php if(isset($m)) { ?>
     <label>Member / Alumni</label>
     <span class="almeb<?=$value['form_id']?>">
       <div class="d-flex alumi-content mebdiv">
        <div class="col-sm-8"><span style="color: grey;" id="member1<?=$value['form_id']?>"></span><span class="cls-btn"> X </span></div>
        <div class="col-sm-4">$ <?=$value['class_price_m']?>.00</div>
      </div>
    </span>
    <input name="mebhid" id="mebhid<?=$value['form_id']?>" type="hidden" value="1">
  <?php } if(isset($n)) { ?>
   <label>Non-Member</label>
   <span class="alnmeb<?=$value['form_id']?>">
     <div class="d-flex alumi-content nmebdiv">
      <div class="col-sm-8"><span style="color: grey;" id="nonmember1<?=$value['form_id']?>"></span><span class="cls-btn"> X </span></div>
      <div class="col-sm-4">$ <?=$value['class_price_n']?>.00</div>
    </div>
  </span>
  <input name="nmebhid" id="nmebhid<?=$value['form_id']?>" type="hidden" value="1">
<?php } if(isset($s)) { ?>
 <label>Subscribing Employer</label>
 <span class="alsmeb<?=$value['form_id']?>">
   <div class="d-flex alumi-content smebdiv">
    <div class="col-sm-8"><span style="color: grey;" id="employer1<?=$value['form_id']?>"></span><span class="cls-btn"> X </span></div>
    <div class="col-sm-4">$ <?=$value['class_price_s']?>.00</div>
  </div>
</span>
<input name="smebhid" id="smebhid<?=$value['form_id']?>" type="hidden" value="1">
<?php } ?>
</div>
<div class="d-flex alumi-content class-sum">
  <div class="col-sm-8">Class Total</div>
  <div class="col-sm-4">$ 958.00</div>
</div>
</div>
</div>
<?php }  ?>
<div class="d-flex justify-content-between abc-btn">
  <div class="p-2"><a href="<?= base_url();?>reg-class"><button type="button" class="btn" style="background: #899ec4;">Back</button></a></div>
  <div class="p-2"><button type="reset" class="btn" style="background: #ff0000; color: #fff; ">Reset</button></div>
  <div class="p-2"><button type="submit" class="btn" style="background: #333366; color: #fff;">Review Order</button>
  </div>
</div>
<span class="sum"><?=$value['class_price_m']?></span>
<span class="sum"><?=$value['class_price_n']?></span>
<span class="sum"><?=$value['class_price_s']?></span>
<span id="subtotal">0.00</span>
<?php echo form_close(); ?>
</section>
<script type="text/javascript">
  var sum = 0;
  $('.sum').each(function() {
    sum += +$(this).text()||0;
  });
  $("#subtotal").text(sum);
</script>
<!-- Optional JavaScript -->
<?php $this->load->view('front/includes/footer-script')?>
</body>
</html>