<table width="100%" class="table m-table nowrap table-header-fixed table-striped table-bordered table-hover table-header-fixed" id="documents_view_table">
  <thead>
    <tr class="">
      <th>Sl No</th>
      <th>Document ID</th>
      <th>Work</th>
      <th>Title</th>
      <th>Description</th>
      <th>File</th>
      <th>Visible to</th>
      <th>Creation</th>
      <th>Actions</th>
      <th>Document ID</th>
      <th>Work ID</th>
      <th class="hidden">IS URL</th>
      <th class="hidden">link</th>

    </tr>
  </thead>
  <tbody>
  </tbody>
</table>
<div class="modal fade" tabindex="-1" id="document_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: #00c5dc;border-radius: 4px">
        <h5 class="modal-title" id="exampleModalLabel" style="color: #ffffff" >
          Add New Document
        </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="document" data-modal-id="document_add_modal" id="form_document_add" method="post" action="<?php echo base_url().'documents/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_document_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-12" >
              <div class="form-group m-form__group" >
                <label for="user_name">
                  Document Title
                </label>
                <div class="m-input-icon m-input-icon--right">
                  <input required type="text" class="form-control m-input m-input--pill m-input--air"  aria-describedby="basic-addon1" name="title">
                  <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-12" >
              <div class="form-group m-form__group" >
                <label for="user_name">
                  Description
                </label>
                <textarea type="text" id="description" name="description" 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=='documents_view'){?>
              <div class="col-lg-12" >
                <div class="form-group m-form__group m-select2 m-select2--air m-select2--pill" >
                  <label for="user_name">
                    Work
                  </label>
                  <select style="width: 100%" class="form-control m-select2 m-select2-general" required id="work_id" name="work_id" data-placeholder="Select Work">
                    <option disabled="" selected="">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>
                  <span class="m-form__help"></span>
                </div>
              </div>
            <?php }elseif($page_name=='work_profile' || $page_name=='projects_profile'){ ?>
              <input type="hidden" name="work_id" value="<?php echo $work_data->work_id?>" />
            <?php } ?>

            <div class="col-lg-8" >
              <div class="form-group m-form__group" >
                <label for="user_name">
                  <!-- Select the Document -->
                  Google Drive Link
                </label>
                <div class="m-input-icon m-input-icon--right ">
                  <!-- <div class="custom-file">
                    <input required type="file" class="custom-file-input m-input m-input--pill m-input--air" name="uploaded_file" id="customFile">
                    <label class="custom-file-label" for="customFile">Choose file</label>
                  </div> -->

                  <div class="m-input-icon m-input-icon--right">
                    <input required type="url" class="form-control m-input m-input--pill m-input--air"  aria-describedby="basic-addon1" name="file">
                    <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fab fa-google-drive"></i></span></span>
                  </div>

                </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">
                  Visible to all
                </label>
                <div >
                  <span class="m-bootstrap-switch m-bootstrap-switch--pill m-bootstrap-switch--air">
                    <input name="visible_status" data-switch="true" type="checkbox" data-on-color="success" data-off-color="danger" data-on-text="Yes" data-off-text="No" checked="checked">
                  </span>
                </div>
              </div>
            </div>

          </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary " data-dismiss="modal">
            Close
          </button>
          <button type="submit" class="btn btn-primary form_submit_btn">
            Submit
          </button>
        </div>
      </form>
    </div>
  </div>
</div>

<div class="modal fade" tabindex="-1" id="document_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: #00c5dc;border-radius: 4px">
        <h5 class="modal-title" id="exampleModalLabel" style="color: #ffffff" >
          Edit Document
        </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="document" data-modal-id="document_edit_modal" id="form_document_edit" method="post" action="<?php echo base_url().'documents/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_document_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-12" >
              <div class="form-group m-form__group" >
                <label for="user_name">
                  Document Title
                </label>
                <div class="m-input-icon m-input-icon--right">
                  <input required type="text" id="title_edit" class="form-control m-input m-input--pill m-input--air"  aria-describedby="basic-addon1" name="title">
                  <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-12" >
              <div class="form-group m-form__group" >
                <label for="user_name">
                  Description
                </label>
                <textarea type="text" id="description_edit" name="description" 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=='documents_view'){?>
              <div class="col-lg-12" >
                <div class="form-group m-form__group m-select2 m-select2--air m-select2--pill" >
                  <label for="user_name">
                    Work
                  </label>
                  <select style="width: 100%" class="form-control m-select2 m-select2-general" required id="work_id_edit" name="work_id_edit" data-placeholder="Select Work">
                    <option disabled="" selected="">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>
                  <span class="m-form__help"></span>
                </div>
              </div>
            <?php }elseif($page_name=='work_profile' || $page_name=='projects_profile'){ ?>
              <input type="hidden" name="work_id" value="<?php echo $work_data->work_id?>" />
            <?php } ?>

            <div class="col-lg-8" id="drive_link_edit_div" style="display: none">
              <div class="form-group m-form__group" >
                <label for="user_name">
                  Google Drive Link
                </label>
                <div class="m-input-icon m-input-icon--right ">
                  <div class="m-input-icon m-input-icon--right">
                    <input required type="url" id="drive_link_edit" class="form-control m-input m-input--pill m-input--air"  aria-describedby="basic-addon1" name="file">
                    <span class="m-input-icon__icon m-input-icon__icon--right"><span><i class="fab fa-google-drive"></i></span></span>
                  </div>

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

            <div class="col-lg-4" id="visible_edit_div">
              <div class="form-group m-form__group">
                <label for="user_name">
                  Visible to all
                </label>
                <div >
                  <span class="m-bootstrap-switch m-bootstrap-switch--pill m-bootstrap-switch--air">
                    <input name="visible_status" id="visible_status_edit" data-switch="true" type="checkbox" data-on-color="success" data-off-color="danger" data-on-text="Yes" data-off-text="No" checked="checked">
                  </span>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="modal-footer">
          <input type="hidden" name="id_edit" id="document_id_edit">
          <button type="button" class="btn btn-secondary " data-dismiss="modal">
            Close
          </button>
          <button type="submit" class="btn btn-primary form_submit_btn">
            Submit
          </button>
        </div>
      </form>
    </div>
  </div>
</div>
<div class="modal fade" tabindex="-1" id="document_delete_modal" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog " role="document" >
    <form autocomplete="off" data-form-type="document"  data-modal-id="document_delete_modal" id="form_document_delete" method="post" action="<?php echo base_url().'documents/delete'?>" 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 Document ? This can not be undone ! </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" value name="id_delete" id="document_id_delete">
        </div>
      </div>
    </form>
  </div>
</div>
