<table width="100%" class="table m-table nowrap table-header-fixed table-striped table-bordered table-hover table-header-fixed" id="payments_schedule_view_table">
  <thead>
    <tr class="">
      <th>Sl No</th>
      <th>Type</th>
      <th>Work Name</th>
      <th>Subcontract Name</th>
      <th>Contractor Name</th>
      <th>Stage No</th>
      <th>Stage Name</th>
      <th>Scheduled Date</th>
      <th>Scheduled Amount</th>
      <th>Remarks</th>
      <th>Created By</th>
      <th>Created Date</th>
      <th>Actions</th>
      <th>ID</th>
      <th>work ID</th>
      <th>contractor ID</th>
    </tr>
  </thead>
  <tbody>
  </tbody>
</table>
<div class="modal fade" tabindex="-1" id="payment_schedule_add_modal" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog " role="document" style="max-width: 800px">
    <div class="modal-content">
      <div class="modal-header" style="background-color: #36a3f7;border-radius: 4px">
        <h5 class="modal-title" id="exampleModalLabel" style="color: #ffffff" >
         Add New Subcontract Payment Schedule
       </h5>
       <button type="button" class="close" data-dismiss="modal" aria-label="Close">
        <span aria-hidden="true">
          &times;
        </span>
      </button>
    </div>
    <form autocomplete="off" data-form-type="client_payment" id="form_payment_schedule_add" data-modal-id="payment_schedule_add_modal" method="post" action="<?php echo base_url().'payment_schedule/create'?>" enctype="multipart/form-data" class="m-form m-form--fit m-form--state m-form--label-align-right " >
      <div class="modal-body">
        <div class="m-form__content">
          <div class="m-alert m-alert--icon alert alert-warning m--hide" role="alert" id="form_client_payment_schedule_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="row">
          <div class="col-lg-6" >
            <div class="form-group m-form__group" >
              <label for="user_name">
                Work Name
              </label>
              <div class="m-select2 m-select2--air m-select2--pill">
                <select required style="width: 100%" class="form-control m-select2 form_payment_schedule_add_select" id="payment_schedule_work_add"  name="work_id" data-placeholder="Select Work">
                  <option selected disabled>Select Work</option>
                  <?php
                  foreach($work_contracts as $row): ?>
                    <option data-work-status="<?php echo $row->work_status?>"  value="<?php echo $row->work_id?>"><?php echo $row->work_name?></option>
                    <?php
                  endforeach;
                  ?>
                </select>
              </div>

              <span class="m-form__help"></span>
            </div>
          </div>
          <div class="col-lg-6" >
            <div class="form-group m-form__group" >
              <label for="user_name">
                Subcontract
              </label>
              <div class="m-select2 m-select2--air m-select2--pill">
                <select required style="width: 100%" class="form-control m-select2 form_payment_schedule_add_select" id="payment_schedule_subcontract_add"  name="reference_id" data-placeholder="Select Subcontract">
                  <option selected disabled>Select Subcontract</option>

                </select>
              </div>

              <span class="m-form__help"></span>
            </div>
          </div>

          <div class="col-lg-6">
            <div class="form-group m-form__group" >
              <label for="user_name">
                Scheduled Amount
              </label>
              <div class="m-input-icon m-input-icon--right">
                <input required type="text" name="scheduled_amount" class="form-control form_client_payment_add_fields m-input m-input--pill m-input--air" placeholder="Scheduled Amount" aria-describedby="basic-addon1">
                <span class="m-input-icon__icon m-input-icon__icon--right"><span><?php echo $this->config->item('Currency_currency_format'); ?></span></span>
              </div>
              <span class="m-form__help"></span>
            </div>
          </div>
          <div class="col-lg-6">
            <div class="form-group m-form__group" >
              <label for="user_name">
                Scheduled Date
              </label>
              <div class="m-input-icon m-input-icon--right">
                <input  data-date-format="dd-mm-yyyy" id="payment_scheduled_date_add" required type="text" name="scheduled_date" class="form-control form_client_payment_add_fields m-input m-input--pill m-input--air" placeholder="Scheduled Date" >
                <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="la la-calendar"></i></span></span>
              </div>
              <span class="m-form__help"></span>
            </div>
          </div>

          <div class="col-lg-6">
            <div class="form-group m-form__group" style="  !important">
              <label for="user_name">
                Stage No
              </label>
              <div class="m-input-icon m-input-icon--right">
                <input type="text" name="stage_no" class="form-control form_client_payment_add_fields m-input m-input--pill m-input--air" placeholder="Stage No" aria-describedby="basic-addon1">
                <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="la la-edit"></i></span></span>
              </div>
              <span class="m-form__help"></span>
            </div>
          </div>
          <div class="col-lg-6">
            <div class="form-group m-form__group" style="  !important">
              <label for="user_name">
                Stage Name
              </label>
              <div class="m-input-icon m-input-icon--right">
                <input type="text" name="stage_name" class="form-control form_client_payment_add_fields m-input m-input--pill m-input--air" placeholder="Stage Name" aria-describedby="basic-addon1">
                <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="la la-tag"></i></span></span>
              </div>
              <span class="m-form__help"></span>
            </div>
          </div>

          <div class="col-lg-12">
            <div class="form-group m-form__group" style="  !important">
              <label for="user_name">
                Remarks
              </label>
              <div class="m-input-icon m-input-icon--right">
                <input type="text" name="tr_remarks" class="form-control form_client_payment_add_fields m-input m-input--pill m-input--air" placeholder="Remarks" aria-describedby="basic-addon1">
                <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="la la-edit"></i></span></span>
              </div>
              <span class="m-form__help"></span>
            </div>
          </div>

          <input type="hidden" name="reference_type" value="" id="reference_type_add_subcontract_payment">
          <input type="hidden" name="type" value="subcontract_payment" id="subcontract_payment2">

          <input type="hidden" name="redirect_url" value="<?php echo base_url(uri_string())?>" >
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">
          Close
        </button>
        <button type="submit" class="btn form_submit_btn btn-primary">
          Submit
        </button>
      </div>
    </form>
  </div>
</div>
</div>
<div class="modal fade" tabindex="-1" id="payment_schedule_edit_modal" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog " role="document" style="max-width: 800px">
    <div class="modal-content">
      <div class="modal-header" style="background-color: #36a3f7;border-radius: 4px">
        <h5 class="modal-title" id="exampleModalLabel" style="color: #ffffff" >
         Edit Subcontract Payment Schedule
       </h5>
       <button type="button" class="close" data-dismiss="modal" aria-label="Close">
        <span aria-hidden="true">
          &times;
        </span>
      </button>
    </div>
    <form autocomplete="off" data-form-type="client_payment" id="form_payment_schedule_edit" data-modal-id="payment_schedule_edit_modal" method="post" action="<?php echo base_url().'payment_schedule/update'?>" enctype="multipart/form-data" class="m-form m-form--fit m-form--state m-form--label-align-right " >
      <div class="modal-body">
        <div class="m-form__content">
          <div class="m-alert m-alert--icon alert alert-warning m--hide" role="alert" id="form_payment_schedule_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="row">
          <div class="col-lg-6" >
            <div class="form-group m-form__group" >
              <label for="user_name">
                Work Name
              </label>
              <div class="m-select2 m-select2--air m-select2--pill">
                <select required style="width: 100%" class="form-control m-select2 form_payment_schedule_add_select" id="payment_schedule_work_edit"  name="work_id" data-placeholder="Select Work">
                  <option selected disabled>Select Work</option>
                  <?php
                  foreach($work_contracts as $row): ?>
                    <option data-work-status="<?php echo $row->work_status?>" value="<?php echo $row->work_id?>"><?php echo $row->work_name?></option>
                    <?php
                  endforeach;
                  ?>
                </select>
              </div>

              <span class="m-form__help"></span>
            </div>
          </div>
          <div class="col-lg-6" >
            <div class="form-group m-form__group" >
              <label for="user_name">
                Subcontract
              </label>
              <div class="m-select2 m-select2--air m-select2--pill">
                <select required style="width: 100%" class="form-control m-select2 form_payment_schedule_edit_select" id="payment_schedule_subcontract_edit"  name="reference_id" data-placeholder="Select Subcontract">
                  <option selected disabled>Select Subcontract</option>
                  <?php
                  foreach($contract_data as $row): ?>
                    <option value="<?php echo $row->contract_id?>"><?php echo $row->sub_work_name.' [ '.$row->contractor.' ]';?></option>
                    <?php
                  endforeach;
                  ?>
                </select>
              </div>

              <span class="m-form__help"></span>
            </div>
          </div>

          <div class="col-lg-6">
            <div class="form-group m-form__group" >
              <label for="user_name">
                Scheduled Amount
              </label>
              <div class="m-input-icon m-input-icon--right">
                <input required type="text" name="scheduled_amount" id="scheduled_amount_edit"  class="form-control form_client_payment_add_fields m-input m-input--pill m-input--air" placeholder="Scheduled Amount" aria-describedby="basic-addon1">
                <span class="m-input-icon__icon m-input-icon__icon--right"><span><?php echo $this->config->item('Currency_currency_format'); ?></span></span>
              </div>
              <span class="m-form__help"></span>
            </div>
          </div>
          <div class="col-lg-6">
            <div class="form-group m-form__group" >
              <label for="user_name">
                Scheduled Date
              </label>
              <div class="m-input-icon m-input-icon--right">
                <input  data-date-format="dd-mm-yyyy" id="payment_scheduled_date_edit" required type="text" name="scheduled_date" class="form-control form_client_payment_add_fields m-input m-input--pill m-input--air" placeholder="Scheduled Date" >
                <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="la la-calendar"></i></span></span>
              </div>
              <span class="m-form__help"></span>
            </div>
          </div>

          <div class="col-lg-6">
            <div class="form-group m-form__group" style="  !important">
              <label for="user_name">
                Stage No
              </label>
              <div class="m-input-icon m-input-icon--right">
                <input type="text" name="stage_no" id="stage_no_edit" class="form-control form_client_payment_add_fields m-input m-input--pill m-input--air" placeholder="Stage No" aria-describedby="basic-addon1">
                <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="la la-edit"></i></span></span>
              </div>
              <span class="m-form__help"></span>
            </div>
          </div>
          <div class="col-lg-6">
            <div class="form-group m-form__group" style="  !important">
              <label for="user_name">
                Stage Name
              </label>
              <div class="m-input-icon m-input-icon--right">
                <input type="text" name="stage_name" id="stage_name_edit" class="form-control form_client_payment_add_fields m-input m-input--pill m-input--air" placeholder="Stage Name" aria-describedby="basic-addon1">
                <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="la la-tag"></i></span></span>
              </div>
              <span class="m-form__help"></span>
            </div>
          </div>

          <div class="col-lg-12">
            <div class="form-group m-form__group" style="  !important">
              <label for="user_name">
                Remarks
              </label>
              <div class="m-input-icon m-input-icon--right">
                <input type="text" name="tr_remarks" id="tr_remarks_edit" class="form-control form_client_payment_add_fields m-input m-input--pill m-input--air" placeholder="Remarks" aria-describedby="basic-addon1">
                <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="la la-edit"></i></span></span>
              </div>
              <span class="m-form__help"></span>
            </div>
          </div>

          <input type="hidden" name="reference_type" value="subcontract" id="reference_type_edit_subcontract_payment">
          <input type="hidden" name="type" value="subcontract_payment" id="subcontract_payment1">
          <input type="hidden" name="schedule_id_edit" value="" id="schedule_id_edit">

          <input type="hidden" name="redirect_url" value="<?php echo base_url(uri_string())?>" >
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">
          Close
        </button>
        <button type="submit" class="btn form_submit_btn btn-primary">
          Submit
        </button>
      </div>
    </form>
  </div>
</div>
</div>
