<?php $this->view("includes/Inc_pagehead");?>
<!-- Page Styles Goes Here-->

<?php $this->view("includes/Inc_navigation");?>
<div class="m-grid__item m-grid__item--fluid m-wrapper">
  <!-- BEGIN: Subheader -->
  <div class="m-subheader ">
    <div class="d-flex align-items-center">
      <div class="mr-auto">
        <h3 class="m-subheader__title m-subheader__title--separator">
          Work Hour Report
        </h3>
        <ul class="m-subheader__breadcrumbs m-nav m-nav--inline">
          <li class="m-nav__item m-nav__item--home">
            <a href="#" class="m-nav__link m-nav__link--icon">
              <i class="m-nav__link-icon la la-home"></i>
            </a>
          </li>
          <li class="m-nav__separator">
            -
          </li>
          <li class="m-nav__item">
            <a href="<?php echo $this->session->userdata("dashboard_link")?>" class="m-nav__link">
              <span class="m-nav__link-text">
                Home
              </span>
            </a>
          </li>
          <li class="m-nav__separator">
            -
          </li>
          <li class="m-nav__item">
            <a href="<?php echo base_url().'user/work_hour_report' ?>" class="m-nav__link">
              <span class="m-nav__link-text">
                Work Hour Report
              </span>
            </a>
          </li>
        </ul>
      </div>
      <div>

      </div>
    </div>
  </div>
  <!-- END: Subheader -->
  <div class="m-content">
    <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded">
      <div class="m-portlet__head">
        <div class="m-portlet__head-caption">
          <div class="m-portlet__head-title">
            <h3 class="m-portlet__head-text">
              Work Hour Report of Users
            </h3>
          </div>
        </div>
        <div class="m-portlet__head-tools">

        </div>
      </div>
      <div class="m-portlet__body">
        <form  autocomplete="off" id="form_user_select" method="post" action="<?php echo base_url()?>user/work_hour_report" enctype="multipart/form-data" class=" form m-form m-form--fit m-form--state m-form--label-align-right ">
          <div style="border-bottom: 1px dashed #ebedf2;padding-left: 30px;padding-top: 30px;padding-right: 30px;padding-bottom: 15px;">
            <div class="form-group m-form__group row">
              <label class="col-lg-3 col-form-label">User:</label>
              <div class="col-lg-5">
                <div class="m-select2 m-select2--air">
                  <select style="width: 100%"  class="form-control m-select2 m-select2-general " required id="user_select" name="user_id">
                    <option selected disabled>Select User</option>
                    <?php foreach ($users as $key => $value) { ?>
                      <option value="<?php echo $value->user_id?>"><?php echo $value->user_alias?></option>
                    <?php } ?>
                  </select>
                </div>
                <span class="m-form__help"></span>
              </div>
              <div class="col-lg-3">
                <button type="submit" class="btn btn-brand">
                  <i class="fa fa-search"></i> Get Report
                </button>
              </div>
            </div>
          </div>
        </form>
        <?php if($user_data!=''){ ?>
          <div class="row" style="margin-bottom: 40px;margin-top: 20px">
            <div class="m-form m-form--label-align-right m--margin-bottom-10">
              <div class="row align-items-center">
                <div class="col-xl-12 order-2 order-xl-1">
                  <div class="form-group m-form__group row ">
                    <div class="col-md-3">
                      <div class="m-form__group ">
                        <label>
                          Joined Date:
                        </label>
                        <input readonly value="<?php if($user_data->joined_date!='0000-00-00'){ echo date('d-m-Y',strtotime($user_data->joined_date));} ?>"   type="text" class="form-control m-input m-input--air m-input--pill"  >
                      </div>
                    </div>
                    <?php
                    if($user_data->joined_date!='0000-00-00'){
                      $current_month_day = date('Y-m-').date('d',strtotime($user_data->joined_date));
                      $start_date = date('d-m-Y', strtotime('-1 month', strtotime($current_month_day)));
                      $end_date = date('d-m-Y', strtotime('-1 day', strtotime($current_month_day)));
                    }else{
                      $start_date = "01-".date('m-Y');
                      $end_date = date('t-m-Y');
                    }
                    ?>
                    <div class="col-md-3">
                      <div class="m-form__group ">
                        <label>
                          Start Date:
                        </label>
                        <input data-date-format="dd-mm-yyyy" value="<?php echo $start_date?>"  id="table_filter_work_hour_start_date"   type="text" class="form-control m-input m-input--air m-input--pill table_filter_work_hour"  >
                      </div>
                    </div>
                    <div class="col-md-3">
                      <div class="m-form__group ">
                        <label>
                          End Date:
                        </label>
                        <input data-date-format="dd-mm-yyyy" value="<?php echo $end_date?>"  id="table_filter_work_hour_end_date"   type="text" class="form-control m-input m-input--air m-input--pill table_filter_work_hour"  >
                      </div>
                    </div>
                    <div class="col-md-3">
                      <a href="javascript:;" style="margin-top: 25px" id="btn_print_work_hour_report" class="btn btn-focus m-btn m-btn--custom m-btn--icon m-btn--air m-btn--pill">
                        <span>
                          <i class="la la-print"></i>
                          <span>
                            Print Report
                          </span>
                        </span>
                      </a>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <table width="100%" class="table m-table nowrap table-header-fixed table-striped table-bordered table-hover table-header-fixed" id="work_hour_report_view_table">

            </table>
          </div>
        <?php } ?>
      </div>
    </div>
  </div>

</div>
</div>
<!-- end:: Body -->
<!-- begin::Footer -->

<?php $this->view("includes/Inc_footer");?>
<!-- end::Footer -->
</div>
<!-- end:: Page -->

<?php $this->view("includes/Inc_sidebar");?>
<?php $this->view("includes/Inc_scripts");?>

<script>
$("#user_work_hour_menu").addClass('m-menu__item--active');

$("#user_select").select2({
  placeholder: "Select User",
  dropdownParent: $("#form_user_select")
})

$("#form_user_select").validate( {
  rules: {
    user: {
      required: !0
    }
  },
  invalidHandler:function(e, r) {
    var i=$("#form_account_head_edit_msg");
    i.removeClass("m--hide").show(), mUtil.scrollTo(i, -200)
  }
  , submitHandler:function(e) {
    this.submit();
  }
})

</script>
<?php if($user_data!=''){ ?>
  <script>
    var user_id = "<?php echo $user_data->user_id?>";
    $("#user_select").val(user_id).trigger('change');
  </script>
<!-- Work Hour Report  Scripts -->
<?php $this->view("modules/include_scripts/user_work_hour_report_view_scripts");?>
<?php } ?>
