 
 <?php include 'getprojcode.php';?>
 <form id="" action="" method="POST" enctype="multipart/form-data" autocomplete="off">
    <br><br> 

    <div class="row">
    <div class="col-md-1"></div>
    <div class="col-md-10" style="background-image: url(../img/placeholders/inner-texture-bg.png); border-radius: 8px;">
      <div style='border-radius: 8px;border: 2px solid #7E9350;width:100%;margin-top:1%;margin-bottom:1%;'>
          <center>
            <b style="font-family: century gothic;font-size: 23px;"><i class="fa fa-edit"></i> Add Project</b>
          </center>
          <br /><br />

            <div class="form-group row">
                <input type="hidden" name="userRec" value="<?php echo $userid;?>" required style="width: 90%;">
                <input type="hidden" name="recAppoint" value="<?php echo $tle_id;?>" required style="width: 90%;">
                <input type="hidden" name="Deptrec" value="<?php echo $role_id;?>" required style="width: 90%;">

                <label class="col-form-label col-2 col-lg-2 form-label text-lg-right">Project Name<span class="required" style="color:red">*</span></label>
                <div class="col-3 col-lg-3">
                <textarea type="text" name="prjname" rows="2" class="form-control" placeholder="Project..." required></textarea>
                </div>

                <label class="col-form-label col-2 col-lg-2 form-label text-lg-right">Client<span class="required" style="color:red">*</span></label>
                <div class="col-3 col-lg-3">
                  <select class="select2 form-control w-100" name="clnt" id="clnt" data-placeholder="-select client-" required>
                    <option></option>
                        <?php
                            $sth = $db->query('SELECT * FROM tbl_clients WHERE stsclnt=1 AND ct_pvg=1 ORDER BY ct_id DESC');
                            try
                            {
                                while ($rr2 = $sth->fetch(PDO::FETCH_ASSOC)){
                                ?>
                                  <option value="<?php echo $rr2['ct_id']; ?>"><?php echo $rr2['ct_names']; ?></option>
                                <?php
                                 }
                                }
                                catch (PDOException $ex) {
                                //Something went wrong rollback!
                                echo $ex->getMessage();
                             }
                        ?>	
                  </select>
                </div>
            </div>
            
            <div class="form-group row">
                <label class="col-form-label col-2 col-lg-2 form-label text-lg-right">Agreement/work Order N<sup>o</sup></label>
                <div class="col-3 col-lg-3">
                    <input type="text" class="form-control" name="agreeno" id="agreeno" placeholder="eg: RMF/...">
                </div>

                <label class="col-form-label col-2 col-lg-2 form-label text-lg-right">Project Amount<span class="required" style="color:red">*</span></label>
                <div class="col-3 col-lg-3">
                <input type="text" name="agree_mont" id="agree_mont" class="form-control" required placeholder="0.0" 
                 oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');">                  
                </div>
            </div>

            <div class="form-group row">              
            <label class="col-form-label col-2 col-lg-2 form-label text-lg-right">Signed Date<span class="required" style="color:red">*</span></label>
                <div class="col-3 col-lg-3">                  
                    <input type="date" class="form-control" name="signdate" placeholder="Signed date" required>
                </div>

                <label class="col-form-label col-2 col-lg-2 form-label text-lg-right">Starting Date<span class="required" style="color:red">*</span></label>
                <div class="col-3 col-lg-3">                  
                    <input type="date" class="form-control" name="start_date" placeholder="Starting date" required>
                </div>
            </div>

            <div class="form-group row">                      
            <label class="col-form-label col-2 col-lg-2 form-label text-lg-right">WithHolding Tax<span class="required" style="color:red">*</span></label>
                <div class="col-3 col-lg-3">
                  <select class="select2 form-control w-100" name="withtax" id="withtax" data-placeholder="-select wt-" required>
                      <option></option>
                      <option value="1">Applicable</option>
                      <option value="0">Not applicable</option>
                  </select>
                </div>

                <label class="col-form-label col-2 col-lg-2 form-label text-lg-right">Duration/Month<span class="required" style="color:red">*</span></label>
                <div class="col-3 col-lg-3">
                  <input type="text" name="durat" id="durat" class="form-control" required
                  oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');">   
                  </div>
            </div>

            <div class="form-group row">        
              
              <label class="col-form-label col-2 col-lg-2 form-label text-lg-right">Code<span class="required" style="color:red">*</span></label>
                  <div class="col-3 col-lg-3">
                  <input type="text" class="form-control" name="pcode" id="pcode" value="<?php echo $uniqueNo;?>" readonly placeholder="code: ENGR" required>
                  </div>
  
                  <label class="col-form-label col-2 col-lg-2 form-label text-lg-right">Contract/Work Order</label>
                  <div class="col-3 col-lg-3">
                    <input type="hidden" class="form-control" name="pcode" id="pcode" value="<?php echo $uniqueNo;?>" readonly placeholder="code: ENGR" required>
                    <input type="file" name="file[]" id="file" class="form-control-file" multiple>   
                    </div>
              </div>

        <hr>
        <center>
            <button type="reset" class="btn btn-default btn-sm" style="border-radius: 4px;">Reset</button>
            <button class="btn btn-primary btn-sm" name="btnProj" style="border-radius: 4px;" type="submit" id="">Save Changes</button>
        </center>
         <br>
    </div> <!--border -->
    </div>
  </div>
</form>

<script>
 $(document).ready(function(){
    //apply on typing and focus
  $('#agree_mont').on('blur',function(){
       $(this).manageCommas();
    });
  $('#agree_mont').on('focus',function(){
        $(this).santizeCommas();
    });
  });

  String.prototype.addComma = function() {
    return this.replace(/(.)(?=(.{3})+$)/g,"$1,").replace(',.', '.');
  }
  //Jquery global extension method
  $.fn.manageCommas = function () {
      return this.each(function () {
          $(this).val($(this).val().replace(/(,|)/g,'').addComma());
      });
  }

  $.fn.santizeCommas = function() {
    return $(this).val($(this).val().replace(/(,| )/g,''));
  }   
</script>


