<script src="<?php echo base_url()?>media/select2/select2.full.min.js"></script>
<script src="<?php echo base_url()?>media/select2/i18n/id.js"></script>
<link href="<?php echo base_url()?>media/select2/select2.min.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="<?php echo base_url()?>media/admin/backend/base/jquery.ui.all.css">
<script type="text/javascript" src="<?php echo base_url('media/admin/date_picker/jquery-ui.js'); ?>"></script>
 
<style type="text/css">
input{border:1px solid silver; padding:5px; }
.form-control{margin-bottom: 10px}
.form-group{margin-bottom: 0px}
.select2{margin-bottom: 10px}
</style>
<div class="row" style="margin-top:2px">
  <div class="col-md-12">
    <ul class="nav nav-tabs" id="rxrTab">
      <li class="active"><a href="#identitas" data-toggle="tab"><?=strtoupper($tipe)?> ENTRY</a></li>
    </ul>

    <div class="tab-content">
      <div class="tab-pane in active" id="identitas">
        <br>
          <div class="form-group" style="margin-bottom:30px; margin-top: 0px; padding-bottom: 30px; border-radius:4px; background: linear-gradient(to right, #d14415,#d16b49, #fad2d2 ,transparent,transparent,transparent,transparent)">
            <div class="col-sm-12 col-md-12" style="text-align: left; color: #fff">
              <h2><strong><?php $a = explode("_", $untuk); echo strtoupper($a[2])?></strong></h2>
            </div>
            <br><br>
          </div>

          <div class="form-group">
          <br>

           
          </div>
         
          <?= form_open_multipart('setting/submit_entry', array('class'=>"form-horizontal")) ?>
          <input type="hidden" name="tabel" value="<?=$untuk?>">
          <input type="hidden" name="tipe" value="<?=$tipe?>">
          <?php  $array_in = $this->Content_m->array_in_dinamic();?>
          
          <?php if($tipe == 'update'){ ?>
          <input type="hidden" name="id" value="<?=$id?>">
          <?php }?>

          <?php 
          $fields = $this->M_general->get_kolom($untuk);
          $c=0;
          foreach ($fields as $field) { ?>
          <div class="form-group">

              <?php if($c=='0'){ ?>
              <input type="hidden" name="tabel_id" value="<?=$field?>" type="text">
              <?php }?>

              <?php if($tipe == 'update' && $c=='0'){ ?>
              <input type="hidden" name="<?=$field?>" value="<?=$id?>" type="text">
              
              <?php 
              $row = $this->Content_m->get_row($untuk,$field,$id);
              }?>

              <?php if($c!=0){ ?>

              <?php if(!in_array($field,$array_in)){ ?>
              <label class="col-sm-2 col-md-2 control-label"><?=ucwords(strtolower($this->M_general->string_explode2($field)))?></label>
              <?php }else if($untuk == 't_employee_application' && $c <='2'){?>
              <label class="col-sm-2 col-md-2 control-label">Employee</label>
              <?php }?>
              <div class="col-sm-10 col-md-10">
                  <?php 
                 
                  if(in_array($field,$array_in)){ ?>
                  <input type="hidden" name="<?=$field?>" value="0">
                  <?php }else if($field == 'employee_id'){ $cek = isset($row->$field)?$row->$field : $id; ?>
                      <?php if($untuk == 't_employee_application'){?>
                      <select name="employee_id" required class="select2" style="width:100%">
                          <option value=""></option>
                          <?php foreach ($this->Content_m->select_db2('t_employee')->result() as $key) { ?>
                              <option value="<?=$key->id_employee?>" <?=$cek==$key->id_employee?'selected':''?>><?=$key->first_name?> <?=$key->last_name?></option>
                          <?php }?>
                      </select>
                      <?php }else{?>
                      <input type="hidden" name="employee_id" value="<?=$cek?>">
                      <?php }?>
                  <input type="hidden" name="dari_menu" value="<?=$dari_menu?>">
                  <input type="hidden" name="nav_menu" value="<?=$nav_menu?>">
                  <input type="hidden" name="sub_nav" value="<?=$sub_nav?>">
                  <?php }else if($field == 'active'){ $cek = isset($row->$field)?$row->$field : '';?>
                  <select name="active" class="select2" style="width:80%">
                    <option value="1" <?=$cek=='1'?'selected':''?>>Active</option>
                    <option value="0" <?=$cek=='0'?'selected':''?>>inActive</option>
                  </select>
                  <?php }else if($field == 'tindakan_lab'){ $cek = isset($row->$field)?$row->$field : '';?>
                  <select name="<?=$field?>" class="select2" style="width:80%">
                    <?php 
                    $this->db->where_in('id_tindakan',array('2','14','15','16','17'));
                    foreach ($this->M_general->select_db2('siak_re_account_chart')->result() as $key ) { ?>
                      <option value="<?=$key->id?>" <?=$key->id==$cek?'selected':''?>><?=$key->name?></option>
                    <?php }?>
                  </select>
                  <?php }else if($field == 'template_set'){ $cek = isset($row->$field)?$row->$field : '';?>
                  <select name="<?=$field?>" class="select2" style="width:80%">
                    <?php 
                    $this->db->group_by('keterangan');
                    foreach ($this->M_general->select_db2('bbmc_re_laboratorium_set')->result() as $key ) { ?>
                      <option value="<?=$key->keterangan?>" <?=$key->keterangan==$cek?'selected':''?>><?=$key->keterangan?></option>
                    <?php }?>
                  </select>
                  <?php }else if($field == 'id_bidang'){ $cek = isset($row->$field)?$row->$field : '';?>
                  <select name="<?=$field?>" class="select2" style="width:80%">
                    <option value=""></option>
                    <?php foreach ($this->M_general->select_db2('bbmc_re_bidang')->result() as $key) { ?>
                      <option value="<?=$key->id_bidang?>" <?=$cek==$key->id_bidang?'selected':''?>><?=$key->bidang?></option>
                    <?php }?>
                  </select>
                  <?php }else if($field == 'id_bhp'){ $cek = isset($row->$field)?$row->$field : '';?>
                  <select name="<?=$field?>" class="select2" style="width:80%">
                    <option value=""></option>
                    <?php foreach ($this->M_general->select_db2('bbmc_re_bahan_habis_pakai')->result() as $key) { ?>
                      <option value="<?=$key->id_re_bahan_habis_pakai?>" <?=$cek==$key->id_re_bahan_habis_pakai?'selected':''?>><?=$key->nama_item?></option>
                    <?php }?>
                  </select>
                  <?php }else if($field == 'stok_keluar' || $field == 'stok_request'){ $cek = isset($row->$field)?$row->$field : '';?>
                  <input type="number" name="<?=$field?>" class="form-control" style="width:100%" value="<?=$cek?>">
                  
                  <?php }else if($field == 'id_unit'){ $cek = isset($row->$field)?$row->$field : '';?>
                  <select name="<?=$field?>" class="select2" style="width:80%">
                    <option value=""></option>
                    <?php foreach ($this->M_general->select_db2('bbmc_re_unit')->result() as $key) { ?>
                      <option value="<?=$key->id_unit?>" <?=$cek==$key->id_unit?'selected':''?>><?=$key->unit?></option>
                    <?php }?>
                  </select>
                  <?php }else if($field == 'ticket_void' || $field == 'visa'){ $cek = isset($row->$field)?$row->$field : '';?>
                  <select name="<?=$field?>" class="select2" style="width:100%">
                    <option value=""></option>
                    <option value="Yes" <?=$cek=='Yes'?'selected':''?>>Yes</option>
                    <option value="No" <?=$cek=='No'?'selected':''?>>No</option>
                  </select>
                  <?php }else if($field == 'ticket_type'){ $cek = isset($row->$field)?$row->$field : '';?>
                  <select name="ticket_type" class="select2" style="width:100%">
                    <option value=""></option>
                    <option value="Airline" <?=$cek=='Airline'?'selected':''?>>Airline</option>
                    <option value="Ship" <?=$cek=='Ship'?'selected':''?>>Ship</option>
                  </select>
                  <?php }else if($field == 'airline_id'){ $cek = isset($row->$field)?$row->$field : '';?>
                  <select name="airline_id" class="select2" style="width: 100%">
                    <?php foreach ($this->Content_m->select_db2('r_airline')->result() as $key) { ?>
                      <option value=""></option>
                      <option value="<?=$key->id_airline?>" <?=$cek==$key->id_airline?'selected':''?>><?=$key->airline_name?></option>
                    <?php }?>
                  </select>
                  <?php }else if($field == 'reason_id'){ $cek = isset($row->$field)?$row->$field : '';?>
                  <select name="reason_id" class="select2" style="width: 100%">
                    <?php foreach ($this->Content_m->select_db2('r_reason')->result() as $key) { ?>
                      <option value=""></option>
                      <option value="<?=$key->id_reason?>" <?=$cek==$key->id_reason?'selected':''?>><?=$key->reason?></option>
                    <?php }?>
                  </select>
                  <?php }else if($field == 'application_id'){ $cek = isset($row->$field)?$row->$field : '';?>
                  <select name="application_id" class="select2" style="width:100%">
                    <option value=""></option>
                    <?php 
                    $this->db->where('employee_id !=','');
                    foreach ($this->Content_m->select_db2('t_employee_application')->result() as $key ) { ?>
                        <option value="<?=$key->id_application?>" <?=$cek==$key->id_application?'selected':''?>>
                        <?="[".$key->id_application."]"?> <?="[".$key->employee_id."]"?> <?=$key->application_date?> <?=$this->M_general->get_value('t_employee','id_employee',$key->employee_id,'first_name')?> <?=$this->M_general->get_value('t_employee','id_employee',$key->employee_id,'last_name')?></option>
                    <?php }?>
                  </select>
                  <?php }else if($field == 'type'){ $cek = isset($row->$field)?$row->$field : '';?>
                  <select name="active" class="select2" style="width:100%">
                    <option value="Applicant" <?=$cek=='Applicant'?'selected':''?>>Applicant</option>
                    <option value="Candidate" <?=$cek=='Candidate'?'selected':''?>>Candidate</option>
                    <option value="Crew Member" <?=$cek=='Crew Member'?'selected':''?>>Crew Member</option>
                    <option value="Ticket" <?=$cek=='Ticket'?'selected':''?>>Ticket</option>
                    <option value="Charge Status" <?=$cek=='Charge Status'?'selected':''?>>Charge Status</option>
                    <option value="Interview Status" <?=$cek=='Interview Status'?'selected':''?>>Interview Status</option>
                    <option value="Pre Screening" <?=$cek=='Pre Screening'?'selected':''?>>Pre Screening</option>
                    <option value="Working Status" <?=$cek=='Working Status'?'selected':''?>>Working Status</option>
                    <option value="Member Status" <?=$cek=='Member Status'?'selected':''?>>Member Status</option>
                  </select>
                  <?php }else if($field == 'ship_type_id'){ $cek = isset($row->$field)?$row->$field : '';?>
                  <select name="ship_type_id" class="select2" style="width: 100%">
                    <?php foreach ($this->Content_m->select_db2('r_ship_type')->result() as $key) { ?>
                      <option value=""></option>
                      <option value="<?=$key->id_ship_type?>" <?=$cek==$key->id_ship_type?'selected':''?>><?=$key->ship_type?></option>
                    <?php }?>
                  </select>
                  <?php }else if($field == 'ship_id'){ $cek = isset($row->$field)?$row->$field : '';?>
                  <select name="ship_id" class="select2" style="width: 100%">
                    <?php foreach ($this->Content_m->select_db2('r_ship')->result() as $key) { ?>
                      <option value=""></option>
                      <option value="<?=$key->id_ship?>" <?=$cek==$key->id_ship?'selected':''?>><?=$key->ship_name?></option>
                    <?php }?>
                  </select>
                  <?php }else if($field == 'country_id'){ $cek = isset($row->$field)?$row->$field : '';?>
                  <select name="country_id" class="select2" style="width: 100%">
                    <?php foreach ($this->Content_m->select_db2('r_country')->result() as $key) { ?>
                      <option value=""></option>
                      <option value="<?=$key->id_country?>" <?=$cek==$key->id_country?'selected':''?>><?=$key->country?></option>
                    <?php }?>
                  </select>
                  <?php }else if($field == 'document_type_id'){ $cek = isset($row->$field)?$row->$field : '';?>
                  <select name="document_type_id" class="select2" style="width: 100%">
                    <?php 
                    if($this->session->userdata('id_pool_division') == '3'){$this->db->where('id_document_type','1');}
                    foreach ($this->Content_m->select_db2('r_document_type')->result() as $key) { ?>
                      <option value=""></option>
                      <option value="<?=$key->id_document_type?>" <?=$cek==$key->id_document_type?'selected':''?>><?=$key->document_type?></option>
                    <?php }?>
                  </select>
                  <?php }else if($field == 'id_jabatan'){ $cek = isset($row->$field)?$row->$field : '';?>
                  <select name="id_jabatan" class="select2" style="width: 100%">
                    <?php foreach ($this->Content_m->select_db('global_jabatan')->result() as $key) { ?>
                      <option value=""></option>
                      <option value="<?=$key->id_global_jabatan?>" <?=$cek==$key->id_global_jabatan?'selected':''?>><?=$key->nama_jabatan?></option>
                    <?php }?>
                  </select>
                  <?php }else if($field == 'addresstype_id'){ $cek = isset($row->$field)?$row->$field : '';?>
                  <select name="addresstype_id" class="select2" style="width: 100%">
                    <?php foreach ($this->Content_m->select_db2('r_address_type')->result() as $key) { ?>
                      <option value=""></option>
                      <option value="<?=$key->id_address_type?>" <?=$cek==$key->id_address_type?'selected':''?>><?=$key->address_type?></option>
                    <?php }?>
                  </select>
                  <?php }else if($field == 'city'){ $cek = isset($row->$field)?$row->$field : '';?>
                  <select name="city" class="select2" style="width: 100%">
                    <?php foreach ($this->Content_m->select_db2('r_city')->result() as $key) { ?>
                      <option value=""></option>
                      <option value="<?=$key->id_city?>" <?=$cek==$key->id_city?'selected':''?>><?=$key->city?></option>
                    <?php }?>
                  </select>
                  <?php }else if($field == 'phonetype_id'){ $cek = isset($row->$field)?$row->$field : '';?>
                  <select name="phonetype_id" class="select2" style="width: 100%">
                    <?php foreach ($this->Content_m->select_db2('r_phone_type')->result() as $key) { ?>
                      <option value=""></option>
                      <option value="<?=$key->id_phone_type?>" <?=$cek==$key->id_phone_type?'selected':''?>><?=$key->phone_type?></option>
                    <?php }?>
                  </select>
                  <?php }else if($field == 'relationship_id'){ $cek = isset($row->$field)?$row->$field : '';?>
                  <select name="relationship_id" class="select2" style="width: 100%">
                    <?php foreach ($this->Content_m->select_db2('r_relationship')->result() as $key) { ?>
                      <option value=""></option>
                      <option value="<?=$key->id_relationship?>" <?=$cek==$key->id_relationship?'selected':''?>><?=$key->relationship?></option>
                    <?php }?>
                  </select>
                  <?php }else if($field == 'interviewer_id'){ $cek = isset($row->$field)?$row->$field : '';?>
                  <select name="interviewer_id" class="select2" style="width: 100%">
                    <?php foreach ($this->Content_m->select_db2('r_interviewer')->result() as $key) { ?>
                      <option value=""></option>
                      <option value="<?=$key->id_interviewer?>" <?=$cek==$key->id_interviewer?'selected':''?>><?=$key->name?></option>
                    <?php }?>
                  </select>
                  <?php }else if($field == 'interview_type_id'){ $cek = isset($row->$field)?$row->$field : '';?>
                  <select name="interview_type_id" class="select2" style="width: 100%">
                    <?php foreach ($this->Content_m->select_db2('r_interview_type')->result() as $key) { ?>
                      <option value=""></option>
                      <option value="<?=$key->id_interview_type?>" <?=$cek==$key->id_interview_type?'selected':''?>><?=$key->name?></option>
                    <?php }?>
                  </select>
                  <?php }else if($field == 'port_id' || $field == 'from_port_id' || $field == 'to_port_id'){ $cek = isset($row->$field)?$row->$field : '';?>
                  <select name="<?=$field?>" class="select2" style="width: 100%">
                    <?php foreach ($this->Content_m->select_db2('r_port')->result() as $key) { ?>
                      <option value=""></option>
                      <option value="<?=$key->id_port?>" <?=$cek==$key->id_port?'selected':''?>><?=$key->port_name?></option>
                    <?php }?>
                  </select>
                  <?php }else if($field == 'charge_status_id' || $field == 'interview_status_id' || $field == 'document_status_id' || $field == 'ticket_status_id' || $field == 'employee_status_id' || $field == 'personal_data_status' || $field == 'document_status' || $field == 'medical_status'  ){ $cek = isset($row->$field)?$row->$field : '';?>
                  <select name="<?=$field?>" class="select2" style="width: 100%">
                    <?php foreach ($this->Content_m->select_db2('r_status')->result() as $key) { ?>
                      <option value=""></option>
                      <option value="<?=$key->id_status?>" <?=$cek==$key->id_status?'selected':''?>><?=$key->status?></option>
                    <?php }?>
                  </select>
                  <?php }else if($field == 'ship_position_id'){ $cek = isset($row->$field)?$row->$field : '';?>
                  <select name="ship_position_id" class="select2" style="width: 100%">
                    <?php foreach ($this->Content_m->select_db2('r_ship_position')->result() as $key) { ?>
                      <option value=""></option>
                      <option value="<?=$key->id_ship_position?>" <?=$cek==$key->id_ship_position?'selected':''?>><?=$key->position?></option>
                    <?php }?>
                  </select>

                  <?php }else if($field == 'document_file' || $field == 'charge_file' || $field == 'certificate_file' || $field == 'reference_file' || $field == 'contract_file' || $field == 'ticket_file'){ $cek = isset($row->$field)?$row->$field : '';?>
                    <input type="file" class="form-control" name="<?=$field?>" accept=",.pdf, .jpeg, .jpg, .png">
                    <input type="hidden" name="document_name" value="<?=$cek?>">
                    <?php if($cek != ''){ ?>
                    <a target="_Blank" href="<?=site_url()?>media/upload/file/<?=$cek?>" style="color:blue; text-decoration: underline;">View File</a>
                    <br><br>
                    <?php }?>
                    
                  <?php }else{ ?>
                  <input class="form-control <?=$field?>" name="<?=$field?>" value="<?php echo isset($row->$field)? $row->$field : ''?>" type="text" style="width:100%; " placeholder="" autocomplete="off">
                  <?php 
                  }?>
              </div>
              <?php }?>
          </div>
          <?php $c++;}?>
          <hr><br><br>
          <div class="form-group">
            <div class="col-sm-offset-3 col-sm-9 col-md-offset-2 col-md-10">
              <button type="submit" class="btn btn-success">SUBMIT</button>
            </div>
          </div>
          <br><br>

          
          <?= form_close() ?>

     
    </div>
  </div>

</div>


<script type="text/javascript">

$(".input_text").select2({
     placeholder: "",
     language: "id",
    });

$( "#date" ).datepicker({
    changeMonth: true,
    changeYear: true,
    yearRange: "-60:+0",
    dateFormat: 'yy-mm-dd'
});

$( ".tanggal_lahir, .interview_date, .available_join_date, .start_date, .end_date, .expiration_date, .issued_date, .application_date, .departure_date, .arrival_date" ).datepicker({
    changeMonth: true,
    changeYear: true,
    yearRange: "-60:+0",
    dateFormat: 'yy-mm-dd'
});

$(".select2").select2({
     placeholder: "",
     language: "id",
    });

</script>




