<div class="row">
  <div class="col-lg-12 mt-4">
    <div class="card">
      <div class="card-header form-card-header">
        <h4 class="m-b-0 text-light">UPDATE COMMITTEE OF ADMINISTRATION</h4>
      </div>
      <div class="card-body">
        <form id="update_coa" class="form-material">
          <div class="form-body">
            <div class="row">
              <div class="col-md-12">
                <div class="form-group">
                  <label class="control-label"><strong>NAME <span>*</span></strong></label>
                  <input type="text" id="name" name="name" value="<?php echo $coa[0]->name; ?>" class="form-control">
                  <label for="name" class="error"></label> 
                </div>
              </div>

              <div class="col-md-12">
                <div class="form-group">
                  <label class="control-label"><strong>DESIGNATION <span>*</span></strong></label>
                  <select name="designation" id="designation" class="form-control">
                  <option value="">SELECT DESIGNATION</option>
                  <?php foreach($designation as $val){ 
                    $selected = false;
                    if($val->id == $coa[0]->designation){
                      $selected = true;
                    }  
                  ?>
                  <option value="<?php echo $val->id; ?>" <?php if($selected){ echo 'selected'; }?>><?php echo strtoupper($val->name); ?></option>
                  <?php } ?>
                  </select>
                  <label for="designation" class="error"></label> 
                </div>
              </div>
              
              <?php if($coa[0]->division == '0' || $coa[0]->division == ""){ ?>
              <div class="col-md-12" id="division_div" style="display:none;">
                <div class="form-group">
                  <label class="control-label"><strong>DIVISION</strong></label>
                  <select name="division" id="division" class="form-control">
                  <option value="">SELECT DIVISION</option>
                  <?php 
                  if($division !== "No Data"){
                    foreach($division as $val){
                      echo '<option value="'.$val->id.'">'.strtoupper($val->name).'</option>';
                    }
                  }
                  ?>
                  </select>
                  <label for="division" class="error"></label> 
                </div>
              </div>
              <?php }else{ ?>
              <div class="col-md-12" id="division_div" style="display:none;">
                <div class="form-group">
                  <label class="control-label"><strong>DIVISION</strong></label>
                  <select name="division" id="division" class="form-control">
                  <option value="">SELECT DIVISION</option>
                  </select>
                  <label for="division" class="error"></label> 
                </div>
              </div>
              <?php } ?>

              <div class="col-md-12">
                <div class="form-group">
                  <label class="control-label"><strong>ORGANISATION <span>*</span></strong></label>
                  <input type="text" id="organisation" name="organisation" value="<?php echo $coa[0]->organisation; ?>" class="form-control">
                  <label for="organisation" class="error"></label> 
                </div>
              </div>

              <div class="col-md-12">
                <div class="form-group">
                  <label class="control-label"><strong>ADDRESS <span>*</span></strong></label>
                  <textarea id="address" name="address" class="form-control" rows="3"><?php echo $coa[0]->address; ?></textarea>
                  <label for="address" class="error"></label> 
                </div>
              </div>

              <div class="col-md-12">
                <div class="form-group">
                  <label class="control-label"><strong>OFFICE NO <span>*</span></strong></label>
                  <input type="text" id="office_number" name="office_number" value="<?php echo $coa[0]->office_number; ?>" class="form-control">
                  <label for="office_number" class="error"></label> 
                </div>
              </div>

              <div class="col-md-12">
                <div class="form-group">
                  <label class="control-label"><strong>EMAIL 1 <span>*</span></strong></label>
                  <input type="email" id="email_1" name="email_1" value="<?php echo $coa[0]->email_1; ?>" class="form-control">
                  <label for="email_1" class="error"></label> 
                </div>
              </div>

              <div class="col-md-12">
                <div class="form-group">
                  <label class="control-label"><strong>EMAIL 2</strong></label>
                  <input type="email" id="email_2" name="email_2" value="<?php echo $coa[0]->email_2; ?>" class="form-control">
                  <label for="email_2" class="error"></label> 
                </div>
              </div>
                  
              <div class="col-md-12">
                <div class="form-group">
                  <label class="control-label"><strong>ABOUT</strong></label>
                  <textarea id="about" name="about" class="form-control" rows="3"><?php echo $coa[0]->about; ?></textarea>
                  <label for="about" class="error"></label> 
                </div>
              </div>


              <div class="col-md-12">
                <div class="form-group">
                  <label class="control-label"><strong>IMAGE</strong></label>
                  <input type="file" name="image" id="image" class="form-control"/>
                  <label> Note : image size ( 250 x 250 pixels )</label>
                  <div>
                    <?php
                      $url = '';
                      if($coa[0]->image == "NA" || $coa[0]->image == ""){
                        $url = 'public/custom/images/coa/default.jpg';
                      }else{
                        $url = $coa[0]->image;
                      }
                    ?>
                    <img src="<?php echo base_url().$url; ?>" height="250px" width="250px">  
                  </div>
                  <label for="image" class="error"></label> 
                </div>
              </div>
             
              <div class="col-md-12">
                <div class="form-group">
                  <label class="control-label"><strong>STATUS</strong></label>
                  <select name="status" id="status" class="form-control">
                    <option value="1" <?php if($coa[0]->status == '1'){echo 'selected'; }?>>ACTIVE</option>
                    <option value="0" <?php if($coa[0]->status == '0'){echo 'selected'; }?>>DEACTIVE</option>
                  </select>
                  <label for="status" class="error"></label> 
                </div>
              </div>
            </div>
          </div>
          
          <input type="hidden" id="id" name="id" value="<?php echo $coa[0]->id; ?>">
          <input type="hidden" id="imgpath" name="imgpath" value="<?php echo $coa[0]->image; ?>">

          <div class="form-actions">
            <button type="submit" class="btn btn-info col-md-3">SAVE</button>  
            <button type="button" class="btn btn-primary col-md-3" onclick="window.location.href='<?php echo base_url(); ?>coa/list'">CANCEL</button>  
          </div>
        </form>
      </div>
    </div>
  </div>
</div>