

<?php $__env->startSection('pageTitle', 'Vega Soft'); ?>
<?php $__env->startSection('page-content'); ?>
  <style>




  </style>
<input type="hidden" id="table_settings_field" branch_id="" branch_name=""  column_heading="<?= $rows->column_heading;?>" column_width="<?= $rows->column_width;?>" column_alighn="<?= $rows->column_alighn;?>"  column_conversion="<?= $rows->column_conversion;?>" settings_row_id="<?= $id;?>" sp_date_picker="<?= $rows->sp_date_picker;?>"  header_from_date="<?=date('d-m-Y', strtotime('-7 days')); ?>"   header_till_date="<?=date('d-m-Y'); ?>"  sp_sort="<?= $rows->menu_id; ?>"  active_mn="<?= $rows->root;?>"  active_mnt="<?= $rows->menu_type;?>">

<div id="form-div">
<input type="hidden" id="hidden_status" value="0">
<input type="hidden" id="row_id" value="0">


<div class="page-header form-header" >
  <h3 class="page-title text-white"> <?= $rows->menu_name;?> </h3>
    <nav aria-label="breadcrumb">
      <ol class="breadcrumb">
      
        <li class="breadcrumb-item text-white  icon-md " aria-current="page"><i class="icon-list slide1"></i> </li>
      </ol>
    </nav>
    

    <input type="hidden" id="table_settings_field" branch_id="" branch_name=""  column_heading="<?= $rows->column_heading;?>" column_width="<?= $rows->column_width;?>" column_alighn="<?= $rows->column_alighn;?>"  column_conversion="<?= $rows->column_conversion;?>" settings_row_id="<?= $id;?>" sp_date_picker="<?= $rows->sp_date_picker;?>"  header_from_date="<?=date('d-m-Y', strtotime('-7 days')); ?>"   header_till_date="<?=date('d-m-Y'); ?>"  sp_sort="<?= $rows->menu_id; ?>"   >
<input type="hidden" class="additional_btns" btn_text="Complete" btn_click_function="complete_po" btn_class="btn btn-warning text-dark btn-sm btn-dtbl" col_width="40"  >

    <?php if($rows->sedp != ""): ?>
  <?php $__currentLoopData = explode(',', $rows->sedp); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $z=>$info): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?> 
     <?php if($info == "1" && $z==1): ?>
       <input type="hidden" class="additional_btns" btn_text="Edit" btn_click_function="call_edit_modal" btn_class="btn btn-success btn-sm btn-dtbl" col_width="30" >
     <?php endif; ?> 
     <?php if($info == "1" && $z==2): ?>
        <input type="hidden" class="additional_btns" btn_text="Remove" btn_click_function="call_remove_modal" btn_class="btn btn-danger btn-sm btn-dtbl" col_width="40"  >
     <?php endif; ?> 
     <?php if($info == "1" && $z==3): ?>
          <input type="hidden" class="additional_btns" btn_text="Print" btn_click_function="call_print_function2" btn_class="btn btn-info btn-sm btn-dtbl" col_width="40"  >
     <?php endif; ?>
  <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
<?php endif; ?>

</div>
<div class="card">
    <div class="card-body">
      <form class="forms-sample" autocomplete="off">






<div class="rows">
  
  <div class="col-md-6">
    <div class="form-group row ">
      <label class="col-sm-4 form-label">P.O CONTRACT NO <i class="text-danger">*</i> </label>
      <div class="col-sm-8">
        <input type="text" class="form-control focusable input_txt" value="<?php echo e(sprintf('%s/%s-%05d', date('Y'),  date('m'), $count)); ?>" id="po_con_no"  onKeyPress="return isNumber(event, this.value);">
      </div>
    </div>
  </div>
   <div class="col-md-6">
    <div class="form-group row ">
      <label class="col-sm-4 form-label">P.O  NO <i class="text-danger">*</i> </label>
      <div class="col-sm-8">
        <input type="text" class="form-control focusable input_txt" id="po_no"  onKeyPress="return isNumber(event, this.value);">
      </div>
    </div>
  </div>
  <div class="col-md-6">
    <div class="form-group row ">
      <label class="col-sm-4 form-label">P.O DATE  <i class="text-danger">*</i></label>
      <div class="col-sm-4">

      <input type="text" class="form-control focusable input_txt mdate to" id="po_date" >
      </div>
    </div>
  </div>
  <div class="col-md-6">
    <div class="form-group row ">
      <label class="col-sm-4 form-label">Po Short code </label>
      <div class="col-sm-4">
      <input type="text" class="form-control focusable input_txt  " style="text-transform:uppercase" id="po_short_code">      </div>
    </div>
  </div>
  <div class="col-md-6">
    <div class="form-group row ">
      <label class="col-sm-4 form-label">P.O DESCRIPTION <i class="text-danger">*</i> </label>
      <div class="col-sm-8">
      <textarea name="" id="po_description" cols="30" rows="10" class="form-control input_txt" style="height:50px !important;"></textarea>
      </div>
    </div>
  </div>
  <div class="col-md-6">
    <div class="form-group row ">
      <label class="col-sm-4 form-label">P.O AMOUNT  <i class="text-danger">*</i></label>
      <div class="col-sm-8">
      <input name="" id="po_amount"  type="text" class="form-control focusable input_txt custom4 "  onKeyPress="return isNumber(event, this.value);">
      </div>
    </div>
  </div>
  <div class="col-md-6">
    <div class="form-group row ">
      <label class="col-sm-4 form-label">P.O LIMIT  <i class="text-danger">*</i></label>
      <div class="col-sm-8">
      <input name="" id="po_limit"  type="text" class="form-control focusable input_txt custom4 "  onKeyPress="return isNumber(event, this.value);">
      </div>
    </div>
  </div>
  <div class="col-md-6">
    <div class="form-group row ">
      <label class="col-sm-4 form-label">EST COMPLETION DATE  <i class="text-danger">*</i></label>
      <div class="col-sm-4">

      <input type="text" class="form-control focusable input_txt mdate" id="est_comp_date" >
      </div>
    </div>
  </div>

</div>









                      <div class="template-demo">
                        
                     <button id="save_btn" type="button" onclick="save_submit_form();" class="btn btn-success btn-icon-text save_btn btn-sm" >
                            <i class="icon-doc btn-icon-prepend"></i> Submit </button>
                        
                     <button id="edit_btn" type="button" onclick="save_submit_form();" class="btn btn-primary btn-icon-text save_btn btn-sm" >
                            <i class="icon-doc btn-icon-prepend"></i> Edit </button>


                      <button type="reset" class="btn btn-danger btn-icon-text reset_btn btn-sm"  >
                            <i class="icon-reload btn-icon-prepend"></i> Reset </button>
                            <input type="hidden" id="row_id" value="0">
                          </div>
                    </form>
    </div>
</div>
</div>

<div id="table-div">
<div class="page-header form-header" >
  <h3 class="page-title text-white">  <?= $rows->menu_name;?> </h3>
    <nav aria-label="breadcrumb">
      <ol class="breadcrumb">
      
        <li class="breadcrumb-item text-white  icon-md " aria-current="page"><i class="icon-plus slide2"></i> </li>
      </ol>
    </nav>
</div>

  

<div class="card">
  


    <div class="col-lg-12 col-sm-12 col-md-12" id="table_result">
                                            
                                            </div>


    
    
</div>
</div>


<div class="modal" tabindex="-1" role="dialog" id="comp_po_mdl">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" >Purchase Order Completion: <span style="font-weight:bold;" id="md_tl"></span> </h5>

        <button type="button" class="close" data-bs-dismiss="modal" aria-label="Close" onclick="hide_modal();">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
      <div class="col-md-12">


<input type="hidden" id="po_id_mdl">
<div class="col-md-12 col-lg-12 col-sm-12">

<div class="col-md-12">
    <div class="form-group row ">
      <label class="col-sm-4 form-label">Completion Date </label>
      <div class="col-sm-8">
      <input name="" id="actual_cmp_dt"  type="text" class="form-control focusable input_txt date_class" >
      </div>
    </div>
  </div>
<div class="col-md-12">
    <div class="form-group row ">
      <label class="col-sm-4 form-label">Po Desc </label>
      <div class="col-sm-8">
<div id="Desc"></div>
      </div>
    </div>
  </div>
<div class="col-md-12">
    <div class="form-group row ">
      <label class="col-sm-4 form-label">Completion Amount </label>
      <div class="col-sm-8">
      <input name="" id="actual_cmp_amt"  type="text" class="form-control focusable input_txt " >
      </div>
    </div>
  </div>



</div>

</div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-sm btn-primary" onclick="save_settlement();">Save </button>
        <button type="button" class="btn btn-sm btn-secondary" data-bs-dismiss="modal" onclick="hide_modal();">Close</button>
      </div>
    </div>
  </div>
</div>


<script type="text/javascript">

set_date();
function start_focus(){
  $('#c_name').focus().click();
}



function save_submit_form() {
 status=0;
 if($.trim($('#po_no').val())==''){
    alert('P.O NO is mandatory');
    $('#po_no').focus();
    status==1;
    return;
 }
 if($.trim($('#po_date').val())==''){
    alert('P.O Date is mandatory');
    $('#po_date').focus();
    status==1;
    return;
 }
 if($.trim($('#po_description').val())==''){
    alert('P.O Description is mandatory');
    $('#po_description').focus();
    status==1;
    return;
 }
 if($.trim($('#po_amount').val())==''){
    alert('P.O Amount is Mandatory');
    $('#po_amount').focus();
    status==1;
    return;
 }
 if($.trim($('#po_limit').val())==''){
    alert('P.O Limit is Mandatory');
    $('#po_limit').focus();
    status==1;
    return;
 }
 if($.trim($('#est_comp_date').val())==''){
    alert('EST COMPLETION DATE is Mandatory');
    $('#est_comp_date').focus();
    status==1;
    return;
 }


 if (status==0) {
Save_form();
 }
}


function  show_form(){
    $("#form-div").show(500);
$("#table-div").hide();
}




$("#po_limit").on('keyup',function(){
if(parseFloat($(this).val().replace(/,/g, ""))>parseFloat($("#po_amount").val().replace(/,/g, ""))){

alert("PO Limit Exceed");
$(this).val(0);
return false;

  }
})


function set_edit_form(row_id) {
  show_form();
$('#row_id' ).val(row_id);
$("#edit_btn").show();
$("#save_btn").hide();

    $('#row_id').val(row_id);
    $('#hidden_status').val(1);
        $.ajax({
              type: 'POST',
               async: false,
                url: '/edit_project',
                data: {
                     '_token': "<?php echo e(csrf_token()); ?>",
                    'cid':"<?php echo e(Session::get('cid')); ?>",
                     row_id: row_id
         
                },
                error: function (request, error) {
                    alert("Please Wait, Loading...");
                },
                success: function (response) {
 datas=response;

     
        
            $('#po_con_no').val(datas.po_con_no); 
            $('#po_no').val(datas.po_no); 
            $('#po_date').val(datas.po_date); 
            $('#po_short_code').val(datas.po_short_code); 
            $('#phone2').val(datas.phone2); 
            $('#po_description').val(datas.po_description); 
            $('#po_amount').val(datas.po_amount); 
            $('#po_limit').val(datas.po_limit); 
            $('#est_comp_date').val(datas.est_comp_date); 
     
   
            
       // start_focus();   
        }
          
     });  
}









  function Save_form() {

           $.ajax({
          url: "/op_project",
          type: "POST",
          data:{
             '_token': "<?php echo e(csrf_token()); ?>",
             'hidden_status':$.trim($('#hidden_status').val()),
              'row_id':$.trim($('#row_id').val()),
              'po_no':$.trim($('#po_no').val()),
              'po_con_no':$.trim($('#po_con_no').val()),
              'po_date':$.trim($('#po_date').val()),
              'po_short_code':$.trim($('#po_short_code').val()),
              'po_description':$.trim($('#po_description').val()),
              'po_amount':$.trim($('#po_amount').val().replace(/,/g, "")),
              'po_limit':$.trim($('#po_limit').val().replace(/,/g, "")),
              'est_comp_date':$.trim($('#est_comp_date').val()),
              'added_by':"<?php echo e(Session::get('user_id')); ?>",
              'company_id':"<?php echo e(Session::get('CID')); ?>"
         
             
          },
          success:function(response){

            
            alert(response.msg);
if(response.flag!=0){
  $('#row_id').val(0);

$('.input_txt').val('');
}
         
           fetch_view_table();


          },
          error: function(response) {
          }
         });
  }





function complete_po(po_id){

  $("#comp_po_mdl").show();
  $("#md_tl").html('');
  $("#po_id_mdl").val(po_id);


  $.ajax({
              type: 'POST',
               async: false,
                url: '/fetch_po_descrpt_cmp',
                data: {
                     '_token': "<?php echo e(csrf_token()); ?>",
                    'cid':"<?php echo e(Session::get('cid')); ?>",
                     po_id: po_id
         
                },
                error: function (request, error) {
                    alert("Please Wait, Loading...");
                },
                success: function (response) {
 datas=response[0];

     $("#Desc").html(datas.po_description);
     $("#actual_cmp_amt").val(datas.po_amount);
     $("#md_tl").html(datas.po_no+' / '+datas.po_con_no);
   
            

        }
          
     }); 






}





function save_settlement(){



  $.ajax({
          url: "/op_cmplt_po",
          type: "POST",
          data:{
             '_token': "<?php echo e(csrf_token()); ?>",
           

              
              'row_id':$('#po_id_mdl').val(),
              'actual_cmp_amt':$.trim($('#actual_cmp_amt').val()),
              'actual_cmp_dt':$.trim($('#actual_cmp_dt').val()),
              'added_by':"<?php echo e(Session::get('user_id')); ?>"
              
           

         
             
          },
          success:function(response){

            

if(response.flag!=0){
  alert(response.msg);
  $('#row_id').val(0);

$('.input_txt').val('');
hide_modal();
fetch_view_table();
}
         
           


          },
          error: function(response) {
          }
         });


}




function hide_modal(){
  $("#comp_po_mdl").fadeOut(100);

}
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.admin', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/trafiqer/public_html/petro/resources/views/project.blade.php ENDPATH**/ ?>