<?php
  $headerArr = Array(0=>'Medicaid_Number',1=>'Members_Last_Name',2=>'Members_First_Name', 
                     3=>'Members_Date_of_Birth',4=>'Members_Age',5=>'Members_Phone_Number',
                     6=>'Members_Alt_Phone',7=>'Trip_Number',8=>'Appointment_Date',
                     9=>'Appointment_Day_of_Week',10=>'Appointment_Time',11=>'Trip_Reason_Code',
                     12=>'Trip_Status',13=>'Vehicle_Type',14=>'Trip_Type',15=>'Wheelchair_Flag', 
                     16=>'Crutches_\/_Walker_\/_Cane_Flag',17=>'Number_of_Car_Seats_Required',
                     18=>'Pregnant_Flag',19=>'Number_of_Additional_Passengers',
                     20=>'Additional_Passengers_With_Appointments',21=>'Trip_Mileage',22=>'Trip_Cost',
                     23=>'Pickup_Address',24=>'Pickup_City',25=>'Pickup_State',26=>'Pickup_Zip_Code',
                     27=>'Delivery_Name',28=>'Delivery_Address',29=>'Delivery_City',30=>'Delivery_State',
                     31=>'Delivery_Zip_Code',32=>'Delivery_Phone_Number',33=>'Special_Needs',
                     34=>'Inst_\/_Directions',35=>'Return_Time',36=>'Attendant_Flag',
                     37=>'Trip_Bid_Status',38=>'Date_Trip_Bid_Status_Was_Changed',
                     39=>'Confirmation_Number',40=>'Copay',41=>'Trip_Status_Date');

  $reqFields = array(0,2,1,4,5,7,23,28,22,14,11,8,10,11,12,13);
  $headerArr = array_replace(array_flip($reqFields),$headerArr);
?>
<div class="content-wrapper">
  <section class="content-header">
    <h1>
      <?= $page_title ?>
      <small><?= $page_desc ?></small>
    </h1>
    <ol class="breadcrumb">
      <li><a href="<?= base_url() ?>"><i class="fa fa-star-o" aria-hidden="true"></i>Home</a></li>
      <li><?= $menu ?></li>
      <li class="active"><?= $sub_menu ?></li>
    </ol>
  </section>
  <section class="content">
    <div class="row">
      <div class="col-md-12">
        <?php if($this->session->flashdata('message')) { 
          $flashdata = $this->session->flashdata('message'); ?>
          <div class="alert alert-<?= $flashdata['class'] ?>">
           <button class="close" data-dismiss="alert" type="button">×</button>
           <?= $flashdata['message'] ?>
         </div>
        <?php } ?>
      </div>
      <div class="col-md-12">
        <div class="box box-warning">
          <div class="box-header with-border">
            <div class="col-md-6">
              <h3 class="box-title">Excel Mapping</h3>
            </div>
          </div>
          <div class="box-body">
            <div class="col-md-7">
              <div style="overflow:scroll;height:400px;"> 
                <table id="mappedHeaders" class="border-cls" style="width:98%;">
                  <?php
                    foreach($headerArr AS $id => $header){
                      $reqDisp = '';
                      $requiredFlag = 'required="no"';
                      if(in_array($id,$reqFields)){
                        $reqDisp = '<i class="fa fa-asterisk text-danger" style="font-size:8px;"></i>';
                        $requiredFlag = 'required="yes"';
                      }
                      echo '<tr class="border-cls tr-cls">
                              <td class="headtag-td">
                                '.str_replace('_',' ',$header).' '.$reqDisp.'
                              </td>
                              <td class="headtag-td">
                                <div type="child" '.$requiredFlag.' class="drag-box" id="order_'.$id.'" ondrop="dropElement(event)" 
                                  ondragover="allowDropElement(event)" headOrder="'.$id.'"></div>
                              </td>
                            </tr>';
                    }
                  ?>
                </table>
              </div>
            </div>
            <div class="col-md-5">
                <div type="parent" class="header-tag-box" ondrop="dropElement(event)" ondragover="allowDropElement(event)">
                  <?php
                    if(!empty($headerArr)){
                      foreach ($headerArr AS $headID => $heading) { ?>
                        <div id="tempHead_<?= $headID ?>" class="header-tag" draggable="true" 
                             ondragstart="dragElement(event)" tmporder="<?= $headID ?>">
                          <?= str_replace(array('/','_'),array('',' '),$heading) ?>
                        </div>
                      <?php }
                    }
                  ?>
                </div>
            </div>
            <div class="col-md-12 btn-mapping">          
              <button id="upload_excell" type="button" class="btn btn-primary" dmclick="0">Import Excell</button>
            </div> 
          </div>
        </div>
      </div>
    </div>
  </section>
  <input type="hidden" name="fileType" value="<?= $fileType ?>">
  <input type="hidden" name="broker_id" value="<?= $broker_id ?>">
  <input type="hidden" name="company_id" value="<?= $company_id ?>">
  <input type="hidden" name="import_file" value="<?= $import_file ?>">
</div>