<?php
session_start();
include("../../php_crud/my_class.php");
$obj = new my_class();
extract($_REQUEST);

if ($district_id != '') {
  $table_name = "HYDROLOGY.UPAZILA_TBL@HYDRO10";
  $cols = "UPZL_CODE";
  $where_cond = "DST_CODE='$district_id'";
  $upazila_list = "";
  foreach ($obj->View_colmn_By_Cond($table_name, $cols, $where_cond) as $upazila_id) {
    $upazila_list .=  "'" . $upazila_id['UPZL_CODE'] . "',";
  }
  $upazila_list = substr($upazila_list, 0, -1);
?>
  <select id="well_id" name="well_id" class="chosen-select" style="height:32px !important;" onchange="load_well_id_information(this.value)">
    <option value="">----select----</option>
    <?php
    $table_name = "HYDROLOGY.BLPUMP_TBL@HYDRO10 PT_WELLS LEFT JOIN HYDROLOGY.UPAZILA_TBL UPZ ON PT_WELLS.UPZL_CODE=UPZ.UPZL_CODE";
    $cols = "PT_WELLS.WELL_ID,UPZ.UPZL_NAME,PT_WELLS.PREREG_NO";
    $where_cond = "WELL_DATA_TYPE='4' AND PT_WELLS.UPZL_CODE IN ($upazila_list)ORDER BY PT_WELLS.WELL_ID ASC";
    foreach ($obj->View_colmn_By_Cond($table_name, $cols, $where_cond) as $pt_well_info) {
      echo '<option value="' . $pt_well_info['WELL_ID'] . '">' . $pt_well_info['WELL_ID'] . ' (' . $pt_well_info['UPZL_NAME'] . ')</option>';
    }
    ?>
  </select>
<?php } else { ?>
  <select id="well_id" name="well_id" class="chosen-select" style="height:32px !important;" onchange="">
    <option value="">----select----</option>
  </select>
<?php } ?>
<script>
  $('.chosen-select').chosen({
    allow_single_deselect: true,
    search_contains: true
  });
  //resize the chosen on window resize
  $(window)
    .off('resize.chosen')
    .on('resize.chosen', function() {
      $('.chosen-select').each(function() {
        var $this = $(this);
        $this.next().css({
          'width': '100%'
        });
      })
    }).trigger('resize.chosen');
  //resize chosen on sidebar collapse/expand
  $(document).on('settings.ace.chosen', function(e, event_name, event_val) {
    if (event_name != 'sidebar_collapsed') return;
    $('.chosen-select').each(function() {
      var $this = $(this);
      $this.next().css({
        'width': '100%'
      });
    })
  });
</script>