<?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">
          Import Data
        </h3>
      </div>
      <div>

      </div>
    </div>
  </div>
  <!-- END: Subheader -->
  <div class="m-content">
    <!--begin::Portlet-->
    <?php if (!empty($this->session->flashdata('error_sl_no')) && $this->session->flashdata('error_sl_no') != "")
    {?>
      <div class="m-portlet">
        <div class="m-portlet__head">
          <div class="m-portlet__head-caption">
            <div class="m-portlet__head-title">
              <h3 class="m-portlet__head-text">
                You Have Some Errors
              </h3>
            </div>
          </div>
        </div>
        <div class="m-portlet__body">
          <?php var_dump($this->session->flashdata('error_sl_no')); ?>
        </div>
      </div>
    <?php } ?>
    <div class="m-portlet">
      <div class="m-portlet__head">
        <div class="m-portlet__head-caption">
          <div class="m-portlet__head-title">
            <h3 class="m-portlet__head-text">
              Import Data From File
            </h3>
          </div>
        </div>
      </div>
      <!--begin::Form-->
      <form autocomplete="off" id="form_data_import" method="post" action="<?php echo base_url().'data_import/import'?>" enctype="multipart/form-data" class="m-form m-form--fit m-form--state m-form--label-align-right ">
        <div class="m-portlet__body">
          <div class="m-form__content">
            <div class="m-alert m-alert--icon alert alert-warning m--hide" role="alert" id="form_data_import_msg">
              <div class="m-alert__icon">
                <i class="la la-warning"></i>
              </div>
              <div class="m-alert__text">
                Oh snap! Change a few things up and try submitting again.
              </div>
              <div class="m-alert__close">
                <button type="button" class="close" data-close="alert" aria-label="Close"></button>
              </div>
            </div>
          </div>
          <div class="form-group m-form__group row">
            <label class="col-lg-4 col-form-label">
              Select Data Type
            </label>
            <div class="col-lg-6">
              <div class="input-group m-input-group m-input-group--pill">
                <select required class="form-control m-select2 m-select2-general" required id="data_type" name="data_type">
                  <option selected disabled>Select Data Type</option>
                  <option value="projects">Projects</option>
                  <option value="client_payments">Client Payments</option>
                  <option value="purchase_bills">Purchase Bills</option>
                  <option value="expense_bills">Expense Bills</option>
                  <option value="subcontract_bills">Subcontract Bills</option>
                  <option value="user_payments">User Payments</option>
                  <option value="salary_payments">Salary Payments</option>
                </select>
              </div>
              <span class="m-form__help"></span>
            </div>
          </div>
          <div class="form-group m-form__group row">
            <label class="col-lg-4 col-form-label">
              Select CSV File
            </label>
            <div class="col-lg-6">
              <div class="custom-file">
                <input required type="file" class="custom-file-input" name="csv" id="csv">
                <label class="custom-file-label" for="customFile">Choose file</label>
              </div>
              <span class="m-form__help"></span>
            </div>
          </div>
        </div>
        <div class="m-portlet__foot m-portlet__foot--fit">
          <div class="m-form__actions m-form__actions">
            <div class="row">
              <div class="col-lg-9 ml-lg-auto">
                <button type="submit" class="btn btn-brand">
                  Submit
                </button>
                <button type="reset" class="btn btn-secondary">
                  Cancel
                </button>
              </div>
            </div>
          </div>
        </div>
      </form>

    </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");?>
<!--begin::Page Snippets -->

<script>

</script>
<script>
$("#data_type").select2({
  placeholder: "Select Data Type",
  dropdownParent: $("#form_data_import")
})

$("#form_data_import").validate( {
  rules: {
    email: {
      email: !0
    }
  },
  invalidHandler:function(e, r) {
    var i=$("#form_work_msg");
    i.removeClass("m--hide").show(), mUtil.scrollTo(i, -200)
  }
  , submitHandler:function(e) {
    mApp.blockPage({
      overlayColor: "#000000",
      type: "loader",
      state: "primary",
      message: "Processing...Please Wait"
    }), setTimeout(function() {}, 3e3);
    this.submit();
  }
}
);
$('.m-select2,.m-select2-multiple',  $("#form_work")).change(function () {
  $("#form_work").validate().element($(this)); //revalidate the chosen dropdown value and show error or success message for the input
  $(this).select2("close");
});
</script>
