<table width="100%" class="table m-table nowrap table-header-fixed table-striped table-bordered table-hover table-header-fixed" id="emd_view_table">
  <thead>
    <tr class="">
      <th>Sl No</th>
      <th>Branch</th>
      <th>ID</th>
      <th>EMD Date</th>
      <th>Authority</th>
      <th>Project & Details</th>
      <th>Client</th>
      <th>BG No</th>
      <th>Amount</th>
      <th>Expiry Date</th>
      <th>Renewal Date</th>
      <th>Remarks</th>
      <th>Creation</th>
      <th>Action</th>
      <th>Project ID</th>
      <th>Project Details</th>
    </tr>
  </thead>
  <tbody>
  </tbody>
</table>

<div class="modal fade" tabindex="-1" id="emd_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 EMD
        </h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">
            &times;
          </span>
        </button>
      </div>
      <form autocomplete="off" id="form_emd_add" data-modal-id="emd_add_modal" method="post" action="<?php echo base_url().'accounts/create_emd'?>" 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_emd_add_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">
                  Project Name
                </label>
                <?php if($page_name=='security_deposits'){?>
                  <div class="m-select2 m-select2--air m-select2--pill" >
                    <select required style="width: 100%" class="form-control m-select2 form_emd_add_select" id="emd_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>
              <?php }elseif($page_name=='work_profile' || $page_name=='projects_profile'){ ?>
                <div class="m-input-icon m-input-icon--right">
                  <input value="<?php echo $work_data->work_name?>" type="text"  readonly class="form-control m-input m-input--pill m-input--air"  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>
              <?php } ?>
              <span class="m-form__help"></span>
            </div>
            </div>
            <div class="col-lg-6">
            <div class="form-group m-form__group" >
              <label for="user_name">
                Client Name
              </label>
              <div class="m-input-icon m-input-icon--right">
                <?php if($page_name=='security_deposits'){?>
                  <input type="text" name="client_name" readonly class="form-control form_emd_add_fields m-input m-input--pill m-input--air" id="emd_client_name_add" aria-describedby="basic-addon1">
                <?php }elseif($page_name=='work_profile' || $page_name=='projects_profile'){ ?>
                  <input value="<?php echo $work_data->client_name?>" type="text" name="client_name" readonly class="form-control m-input m-input--pill m-input--air" id="emd_client_name_add" aria-describedby="basic-addon1">
                <?php } ?>
                <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="la la-user"></i></span></span>
              </div>
              <span class="m-form__help"></span>
            </div>
            </div>
          </div>
          <div class="row">
            <div class="col-lg-12">
              <div class="form-group m-form__group" >
                <label for="user_name">
                  Project Details
                </label>
                <textarea type="text" rows="3" placeholder="Project Details" name="project_details" class="form-control m-input m-input--pill m-input--air "  aria-describedby="basic-addon1"></textarea>
                <span class="m-form__help"></span>
              </div>
            </div>
            </div>
          <div class="row">
            <div class="col-lg-4">
              <div class="form-group m-form__group">
                <label for="user_name">
                  EMD Date
                </label>
                <div class="input-group m-input-group--air m-input-group--pill date">
                  <div class="input-group-prepend">
                    <span class="input-group-text">
                      <i class="la la-calendar"></i>
                    </span>
                  </div>
                  <input  data-date-format="dd-mm-yyyy" id="emd_date_add" required type="text" name="emd_date" class="form-control form_emd_add_fields m-input " placeholder=" Date" >
                </div>
              </div>
              <span class="m-form__help"></span>
            </div>
            <div class="col-lg-4">
              <div class="form-group m-form__group">
                <label for="user_name">
                  BG No
                </label>
                <div class="input-group m-input-group m-input-group--pill m-input-group--air">
                  <input  type="text" name="bg_no"  class="form-control form_emd_add_fields m-input" placeholder="BG Number" aria-describedby="basic-addon1">
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <div class="col-lg-4">
              <div class="form-group m-form__group">
                <label for="user_name">
                  EMD Amount
                </label>
                <div class="input-group m-input-group m-input-group--pill m-input-group--air">
                  <input required type="text" name="emd_amount"  class="form-control form_emd_add_fields m-input" placeholder="EMD Amount" aria-describedby="basic-addon1">
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <div class="col-lg-4">
              <div class="form-group m-form__group">
                <label for="user_name">
                  Authority
                </label>
                <div class="input-group m-input-group m-input-group--pill m-input-group--air">
                  <input  type="text" name="authority"  class="form-control form_emd_add_fields m-input" placeholder="Authority" aria-describedby="basic-addon1">
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <div class="col-lg-4">
              <div class="form-group m-form__group">
                <label for="user_name">
                  Expiry Date
                </label>
                <div class="input-group m-input-group--air m-input-group--pill date">
                  <div class="input-group-prepend">
                    <span class="input-group-text">
                      <i class="la la-calendar"></i>
                    </span>
                  </div>
                  <input  data-date-format="dd-mm-yyyy" id="emd_expiry_date_add" required type="text" name="expiry_date" class="form-control form_emd_add_fields m-input " placeholder="Expiry Date" >
                </div>
              </div>
              <span class="m-form__help"></span>
            </div>
            <div class="col-lg-4">
              <div class="form-group m-form__group">
                <label for="user_name">
                  Next Renewal Date
                </label>
                <div class="input-group m-input-group--air m-input-group--pill date">
                  <div class="input-group-prepend">
                    <span class="input-group-text">
                      <i class="la la-calendar"></i>
                    </span>
                  </div>
                  <input  data-date-format="dd-mm-yyyy" id="emd_renewal_date_add" required type="text" name="renewal_date" class="form-control form_emd_add_fields m-input " placeholder="Renewal Date" >
                </div>
              </div>
              <span class="m-form__help"></span>
            </div>
            <div class="col-lg-12">
              <div class="form-group m-form__group" >
                <label for="user_name">
                  Remarks
                </label>
                <textarea type="text" rows="2" placeholder="Remarks" name="remarks" class="form-control m-input m-input--pill m-input--air "  aria-describedby="basic-addon1"></textarea>
                <span class="m-form__help"></span>
              </div>
            </div>
            <?php if($page_name=='work_profile' || $page_name=='projects_profile'){ ?>
            <input type="hidden"  name="work_id" value="<?php echo $work_data->work_id?>">
            <input type="hidden"  name="client_id" value="<?php echo $work_data->client_id?>">
            <?php } ?>
            <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="emd_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 EMD
        </h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">
            &times;
          </span>
        </button>
      </div>
      <form autocomplete="off" id="form_emd_edit" data-modal-id="emd_edit_modal" method="post" action="<?php echo base_url().'accounts/update_emd'?>" 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_emd_edit_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">
                  Project Name
                </label>
                <?php if($page_name=='security_deposits'){?>
                  <div class="m-select2 m-select2--air m-select2--pill" >
                    <select required style="width: 100%" class="form-control m-select2 form_emd_edit_select" id="emd_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>
              <?php }elseif($page_name=='work_profile' || $page_name=='projects_profile'){ ?>
                <div class="m-input-icon m-input-icon--right">
                  <input value="<?php echo $work_data->work_name?>" type="text"  readonly class="form-control m-input m-input--pill m-input--air"  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>
              <?php } ?>
              <span class="m-form__help"></span>
            </div>
            </div>
            <div class="col-lg-6">
            <div class="form-group m-form__group" >
              <label for="user_name">
                Client Name
              </label>
              <div class="m-input-icon m-input-icon--right">
                <?php if($page_name=='security_deposits'){?>
                  <input type="text" name="client_name" readonly class="form-control form_emd_edit_fields m-input m-input--pill m-input--air" id="emd_client_name_edit" aria-describedby="basic-addon1">
                <?php }elseif($page_name=='work_profile' || $page_name=='projects_profile'){ ?>
                  <input value="<?php echo $work_data->client_name?>" type="text" name="client_name" readonly class="form-control m-input m-input--pill m-input--air" id="emd_client_name_edit" aria-describedby="basic-addon1">
                <?php } ?>
                <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="la la-user"></i></span></span>
              </div>
              <span class="m-form__help"></span>
            </div>
            </div>
          </div>
          <div class="row">
            <div class="col-lg-12">
              <div class="form-group m-form__group" >
                <label for="user_name">
                  Project Details
                </label>
                <textarea type="text" rows="3" placeholder="Project Details" name="project_details" id="emd_project_details_edit" class="form-control m-input m-input--pill m-input--air "  aria-describedby="basic-addon1"></textarea>
                <span class="m-form__help"></span>
              </div>
            </div>
            </div>
          <div class="row">
            <div class="col-lg-4">
              <div class="form-group m-form__group">
                <label for="user_name">
                  EMD Date
                </label>
                <div class="input-group m-input-group--air m-input-group--pill date">
                  <div class="input-group-prepend">
                    <span class="input-group-text">
                      <i class="la la-calendar"></i>
                    </span>
                  </div>
                  <input  data-date-format="dd-mm-yyyy" id="emd_date_edit" required type="text" name="emd_date" class="form-control form_emd_add_fields m-input " placeholder=" Date" >
                </div>
              </div>
              <span class="m-form__help"></span>
            </div>
            <div class="col-lg-4">
              <div class="form-group m-form__group">
                <label for="user_name">
                  BG No
                </label>
                <div class="input-group m-input-group m-input-group--pill m-input-group--air">
                  <input  type="text" name="bg_no" id="bg_no_edit"  class="form-control form_emd_add_fields m-input" placeholder="BG Number" aria-describedby="basic-addon1">
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <div class="col-lg-4">
              <div class="form-group m-form__group">
                <label for="user_name">
                  EMD Amount
                </label>
                <div class="input-group m-input-group m-input-group--pill m-input-group--air">
                  <input required type="text" name="emd_amount" id="emd_amount_edit"  class="form-control form_emd_add_fields m-input" placeholder="EMD Amount" aria-describedby="basic-addon1">
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <div class="col-lg-4">
              <div class="form-group m-form__group">
                <label for="user_name">
                  Authority
                </label>
                <div class="input-group m-input-group m-input-group--pill m-input-group--air">
                  <input  type="text" name="authority" id="emd_authority_edit" class="form-control form_emd_add_fields m-input" placeholder="Authority" aria-describedby="basic-addon1">
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <div class="col-lg-4">
              <div class="form-group m-form__group">
                <label for="user_name">
                  Expiry Date
                </label>
                <div class="input-group m-input-group--air m-input-group--pill date">
                  <div class="input-group-prepend">
                    <span class="input-group-text">
                      <i class="la la-calendar"></i>
                    </span>
                  </div>
                  <input  data-date-format="dd-mm-yyyy" id="emd_expiry_date_edit" required type="text" name="expiry_date" class="form-control form_emd_add_fields m-input " placeholder="Expiry Date" >
                </div>
              </div>
              <span class="m-form__help"></span>
            </div>
            <div class="col-lg-4">
              <div class="form-group m-form__group">
                <label for="user_name">
                  Next Renewal Date
                </label>
                <div class="input-group m-input-group--air m-input-group--pill date">
                  <div class="input-group-prepend">
                    <span class="input-group-text">
                      <i class="la la-calendar"></i>
                    </span>
                  </div>
                  <input  data-date-format="dd-mm-yyyy" id="emd_renewal_date_edit" required type="text" name="renewal_date" class="form-control form_emd_add_fields m-input " placeholder="Renewal Date" >
                </div>
              </div>
              <span class="m-form__help"></span>
            </div>
            <div class="col-lg-12">
              <div class="form-group m-form__group" >
                <label for="user_name">
                  Remarks
                </label>
                <textarea type="text" rows="2" placeholder="Remarks" name="remarks" id="emd_remarks_edit" class="form-control m-input m-input--pill m-input--air "  aria-describedby="basic-addon1"></textarea>
                <span class="m-form__help"></span>
              </div>
            </div>
            <?php if($page_name=='work_profile' || $page_name=='projects_profile'){ ?>
            <input type="hidden"  name="work_id" value="<?php echo $work_data->work_id?>">
            <input type="hidden"  name="client_id" value="<?php echo $work_data->client_id?>">
            <?php } ?>
            <input type="hidden"  name="emd_id" id="emd_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>
<div class="modal fade" tabindex="-1" id="emd_delete_modal" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog " role="document" >
    <form autocomplete="off" id="form_emd_delete" data-modal-id="emd_delete_modal"  method="post" action="<?php echo base_url().'accounts/delete_emd'?>" class="form-horizontal">
      <div class="modal-content">
        <div class="alert alert-danger" role="alert" style="margin-bottom: 0px">
          <button type="button" class="close" data-dismiss="modal"></button>
          <br/>
          <h4 class="alert-heading">Warning! Please Confirm Your Action</h4>
          <br/>
          <p> Are You Sure to Delete this Data ?. All the Associated Data will Lost. </p>
          <p>
            <button class="btn btn-danger form_submit_btn" type="submit" name="submit">Confirm & Delete</button>
            <button type="button" class="btn btn-primary modal-dismiss" data-dismiss="modal">Cancel</button>
          </p>
          <input type="hidden"  name="emd_id" id="emd_id_delete">
          <input type="hidden" name="redirect_url" value="<?php echo base_url(uri_string())?>" >
        </div>
      </div>
    </form>
  </div>
</div>
