<?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">
          Contractor Profile
        </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().'Subcontracts/contractors/profile/'.$contractor_data->contractor_id ?>" class="m-nav__link">
              <span class="m-nav__link-text">
                Contractor Profile
              </span>
            </a>
          </li>


        </ul>
      </div>
      <div>

      </div>
    </div>
  </div>
  <!-- END: Subheader -->
  <div class="m-content">

    <div class="row">
      <div class="col-xl-3 col-lg-4">
        <div class="m-portlet m-portlet--full-height  ">

          <div class="m-portlet__body" style="padding-top: 0px">
            <div class="m-card-profile">
              <div class="m-card-profile__title m--hide">
                Contractor Profile
              </div>
              <div class="m-card-profile__pic">
                <div class="m-card-profile__pic-wrapper">
                  <img src="<?php echo base_url()?>/template/assets/app/media/img/users/user.png" alt=""/>
                </div>
              </div>
              <div class="m-card-profile__details">
                <span class="m-card-profile__name">
                  #<?php echo $contractor_data->contractor_id ?>
                  <br/><?php echo $contractor_data->contractor_name ?>
                </span>
                <br>

              </div>

              <div class="m-card-profile__details">
                <span class="m-card-profile__name">

                </span>
              </div>
              <br/>
            </div>
            <ul class="m-nav m-nav--hover-bg m-portlet-fit--sides">
              <li class="m-nav__separator m-nav__separator--fit" style="margin-top: 0px"></li>
              <li class="m-nav__section m--hide">
                <span class="m-nav__section-text">
                  Section
                </span>
              </li>
              <li class="m-nav__item profile_nav" id="nav_info" data-nav="info" data-table-name=''>
                <a href="javascript:;" class="m-nav__link">
                  <i class="m-nav__link-icon fa fa-info-circle"></i>
                  <span class="m-nav__link-title">
                    <span class="m-nav__link-wrap">
                      <span class="m-nav__link-text">
                        Contractor Info
                      </span>
                    </span>
                  </span>
                </a>
              </li>
              <li class="m-nav__item profile_nav" id="nav_labours" data-nav="labours" data-table-name='labour_view_table'>
                <a href="javascript:;" class="m-nav__link">
                  <i class="m-nav__link-icon fa fa-users"></i>
                  <span class="m-nav__link-title">
                    <span class="m-nav__link-wrap">
                      <span class="m-nav__link-text">
                        Labours
                      </span>
                    </span>
                  </span>
                </a>
              </li>
            </ul>
          </div>
        </div>
      </div>
      <div class="col-xl-9 col-lg-8">
        <div id="div_info" class="profile_nav_div">
          <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">
                    Contractor Info
                  </h3>
                </div>
              </div>
            </div>
            <div class="m-portlet__body">
              <form autocomplete="off" class="m-form m-form--fit m-form--label-align-right">
                <div class="m-portlet__body">
                  <div class="form-group m-form__group row">
                    <label class="col-xl-3 col-lg-3 col-form-label">
                      Contractor ID
                    </label>
                    <div class="col-xl-7 col-lg-7">
                      <div class="input-group m-input-group--air">
                        <div class="input-group-prepend">
                          <span class="input-group-text">
                            <i class="fa fa-hashtag"></i>
                          </span>
                        </div>
                        <input disabled type="text" class="form-control m-input m-input--solid" value="<?php echo $contractor_data->contractor_id?>">
                      </div>
                    </div>
                  </div>
                  <div class="form-group m-form__group row">
                    <label class="col-xl-3 col-lg-3 col-form-label">
                      Contractor Name
                    </label>
                    <div class="col-xl-7 col-lg-7">
                      <div class="input-group m-input-group--air">
                        <div class="input-group-prepend">
                          <span class="input-group-text">
                            <i class="fa fa-user"></i>
                          </span>
                        </div>
                        <input disabled type="text" class="form-control m-input m-input--solid" value="<?php echo $contractor_data->contractor_name?>">
                      </div>
                    </div>
                  </div>
                  <div class="form-group m-form__group row">
                    <label class="col-xl-3 col-lg-3 col-form-label">
                      Mobile
                    </label>
                    <div class="col-xl-7 col-lg-7">
                      <div class="input-group m-input-group--air">
                        <div class="input-group-prepend">
                          <span class="input-group-text">
                            <i class="fa fa-phone "></i>
                          </span>
                        </div>
                        <input disabled type="text" class="form-control m-input m-input--solid" value="<?php echo $contractor_data->phone ?>">
                      </div>
                    </div>
                  </div>
                  <div class="form-group m-form__group row">
                    <label class="col-xl-3 col-lg-3 col-form-label">
                      Address
                    </label>
                    <div class="col-xl-7 col-lg-7">
                      <div class="input-group m-input-group--air date">
                        <div class="input-group-prepend">
                          <span class="input-group-text">
                            <i class="fa fa-map-marker"></i>
                          </span>
                        </div>
                        <input  disabled type="text" class="form-control m-input m-input--solid"  value="<?php echo $contractor_data->contractor_address?>">
                      </div>
                    </div>
                  </div>
                  <div class="form-group m-form__group row">
                    <label class="col-xl-3 col-lg-3 col-form-label">
                      Contact Person
                    </label>
                    <div class="col-xl-7 col-lg-7">
                      <div class="input-group m-input-group--air date">
                        <input  disabled type="text" class="form-control m-input m-input--solid"  value="<?php echo $contractor_data->contact_person?>">
                      </div>
                    </div>
                  </div>
                  <div class="form-group m-form__group row">
                    <label class="col-xl-3 col-lg-3 col-form-label">
                      <?php echo $this->config->item('Tax_tax_name') ?> No
                    </label>
                    <div class="col-xl-7 col-lg-7">
                      <div class="input-group m-input-group--air date">
                        <input  disabled type="text" class="form-control m-input m-input--solid"  value="<?php echo $contractor_data->tax_no?>">
                      </div>
                    </div>
                  </div>
                  <div class="form-group m-form__group row">
                    <label class="col-xl-3 col-lg-3 col-form-label">
                      PAN No
                    </label>
                    <div class="col-xl-7 col-lg-7">
                      <div class="input-group m-input-group--air date">
                        <input  disabled type="text" class="form-control m-input m-input--solid"  value="<?php echo $contractor_data->pan_no?>">
                      </div>
                    </div>
                  </div>
                  <div class="form-group m-form__group row">
                    <label class="col-xl-3 col-lg-3 col-form-label">
                      Aadhar No
                    </label>
                    <div class="col-xl-7 col-lg-7">
                      <div class="input-group m-input-group--air date">
                        <input  disabled type="text" class="form-control m-input m-input--solid"  value="<?php echo $contractor_data->aadhar_no?>">
                      </div>
                    </div>
                  </div>
                  <div class="form-group m-form__group row">
                    <label class="col-xl-3 col-lg-3 col-form-label">
                      Bank A/C No
                    </label>
                    <div class="col-xl-7 col-lg-7">
                      <div class="input-group m-input-group--air date">
                        <input  disabled type="text" class="form-control m-input m-input--solid"  value="<?php echo $contractor_data->bank_account_no?>">
                      </div>
                    </div>
                  </div>
                  <div class="form-group m-form__group row">
                    <label class="col-xl-3 col-lg-3 col-form-label">
                      <?= $this->config->item('bank_ifsc_name')?> Code
                    </label>
                    <div class="col-xl-7 col-lg-7">
                      <div class="input-group m-input-group--air date">
                        <input  disabled type="text" class="form-control m-input m-input--solid"  value="<?php echo $contractor_data->bank_ifsc?>">
                      </div>
                    </div>
                  </div>
                  <div class="form-group m-form__group row">
                    <label class="col-xl-3 col-lg-3 col-form-label">
                      Bank Name
                    </label>
                    <div class="col-xl-7 col-lg-7">
                      <div class="input-group m-input-group--air date">
                        <input  disabled type="text" class="form-control m-input m-input--solid"  value="<?php echo $contractor_data->bank_name?>">
                      </div>
                    </div>
                  </div>
                  <div class="form-group m-form__group row">
                    <label class="col-xl-3 col-lg-3 col-form-label">
                      Branch
                    </label>
                    <div class="col-xl-7 col-lg-7">
                      <div class="input-group m-input-group--air date">
                        <input  disabled type="text" class="form-control m-input m-input--solid"  value="<?php echo $contractor_data->bank_branch?>">
                      </div>
                    </div>
                  </div>
                </div>
              </form>
            </div>
          </div>
        </div>
        <div id="div_labours" class="profile_nav_div">
          <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">
                    List of Labours
                  </h3>
                </div>
              </div>
              <div class="m-portlet__head-tools">

                <?php if($this->session->userdata('user_role') != 'auditor') { ?>

                  <a href="#" data-toggle="modal" data-target="#labour_add_modal" class="btn btn-focus m-btn m-btn--custom m-btn--icon m-btn--air m-btn--pill">
                    <span>
                      <i class="la la-plus"></i>
                      <span>
                        Create New Labour
                      </span>
                    </span>
                  </a>

                <?php } ?>

              </div>
            </div>
            <div class="m-portlet__body">
              <!--begin: Datatable -->
              <?php $this->view("modules/include_tables/table_subcontract_labours");?>
              <!--end: Datatable -->
              <?php $this->view("modules/include_modals/modal_subcontract_labours");?>

            </div>
          </div>
        </div>

      </div>

    </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");?>
<!--begin::Page Snippets -->
<script>
  $("#table_filter_status").selectpicker();
  $("[data-switch=true]").bootstrapSwitch()
</script>

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

  function hide_all(){
    $(".profile_nav").removeClass('m-nav__item--active');
    $(".profile_nav_div").hide();
  }
  function active(menu_name){
    hide_all();
    $("#nav_"+menu_name).addClass('m-nav__item--active');
    $("#div_"+menu_name).show();
    $("#div_"+menu_name).fadeIn("slow");
    $('html, body').animate({
      scrollTop: eval($("#div_"+menu_name).offset().top - 150)
    }, 500);
  }
//  Hide All Div and In Active All Menu
hide_all();
//  Active First Menu and Its div
active('info');
$('body').on('click', '.profile_nav', function() {
  var nav = $(this).attr('data-nav');
  active(nav);
})
</script>
<script>
  jQuery(document).ready(function() {
    $('.profile_nav').on('click', function(e){
      var table_name = $(this).attr('data-table-name');
      if(table_name!=''){
        var tables = table_name.split(',');
        $.each(tables, function( index, value ){
          var table_name = value;
          $('#'+table_name).dataTable().fnDestroy();
          // eval("Datatable_"+table_name).init("reload");
        eval(table_name).ajax.reload();
      });
      }
    });
  })
</script>
<?php $this->view("modules/include_scripts/subcontractor_labours_scripts");?>
<script>
$(".form_submit_btn").click(function (e) {
  e.preventDefault();
  var a = $(this),
  l = $(this).closest("form"),
  action = l.attr('action');
  var form_id = l.attr('id');
  l.validate({
    rules: {
      op_balance: {
        number: !0
      },
      daily_wage: {
        number: !0
      },
      contact_no: {
        number: !0
      }
    }, invalidHandler: function (e, r) {
      var i = $("#" + form_id + "_msg");
      i.removeClass("m--hide").show(), mUtil.scrollTo(i, -200)
    }, submitHandler: function (e) {
    }
  }), l.valid() && (a.addClass("m-loader m-loader--right m-loader--light").attr("disabled", !0),
  l.ajaxSubmit({
    url: action,
    success: function (e, t, r, s) {
      var modal_id = l.attr('data-modal-id');
      var form_type = l.attr('data-form-type');
      $("#" + form_id + "_msg").addClass("m--hide");
      // Block UI
      mApp.blockPage({
        overlayColor: "#000000",
        type: "loader",
        state: "success",
        message: "Please wait..."
      }), setTimeout(function () {
        mApp.unblockPage()
      }, 2e3);
      var obj = $.parseJSON(e);
      if (obj.status == 1) {

        select_contractors('contractor_add');
        select_contractors('contractor_edit');
        select_contractors('table_filter_contractor');


        a.removeClass("m-loader m-loader--right m-loader--light").attr("disabled", !1);
        $("#"+modal_id).modal('toggle');
        $("."+form_id+"_fields").val('');
        $("."+form_id+"_select").val('').trigger("change");
        toastr[obj.flashdata_type](obj.flashdata_msg, obj.flashdata_title);
        labour_view_table.ajax.reload();
        select_work_type("work_type_add");
        select_work_type("work_type_edit");
        $('input[name=fixed_wage]').prop('checked', false);

        $(".custom-file-input").val(null);
        $(".custom-file-label").text('');
      } else {
        a.removeClass("m-loader m-loader--right m-loader--light").attr("disabled", !1);
        toastr[obj.flashdata_type](obj.flashdata_msg, obj.flashdata_title);
      }
      if (obj == null) {
        setTimeout(function () {
          a.removeClass("m-loader m-loader--right m-loader--light").attr("disabled", !1);
          toastr["warning"]("Your Attempt is Timed Out. Please Try Again.", "Timed Out");
        }, 2e4)
      }
    },error: function() {
      a.removeClass("m-loader m-loader--right m-loader--light").attr("disabled", !1);
      toastr["error"]("Sorry. There Has Been Some Error Occurred. Please Try Again.", "Error");
    }
  })
)
});

</script>
