<?php
  $Currency = getCurrency();
  
?>
<!-- PAGE-INDEX-STARTS -->

<div class="breadcrumbs">
    <div class="breadcrumbs-inner">
        <div class="row m-0">
            <div class="col-sm-4">
                <div class="page-header float-left">
                    <div class="page-title">
                        <h1><?= $pTitle ?></h1>
                    </div>
                </div>
            </div>
            <div class="col-sm-8">
                <div class="page-header float-right">
                    <div class="page-title">
                        <ol class="breadcrumb text-right">
                            <li><a href="<?= base_url() ?>">Dashboard</a></li>
                            <li><a ><?= $menu ?></a></li>
                            <li class="active"><?= $smenu ?></li>
                        </ol>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- PAGE-INDEX-ENDS -->
<?php
  $pospart_code = getpospart_code();
  $country = getCurrency();
  
?>
<!-- PAGE-CONTENT-STARTS -->

<div class="content">
  <div class="animated fadeIn">
      <div class="row">
        <div class="col-lg-12">
        <?php 
        $url = (!isset($Posparts_id)||empty($Posparts_id))
        ?'Pos_parts/createPosparts':'Pos_parts/updatePosparts/'.$Posparts_id;
        if($this->session->flashdata('message')) { 
        $flashdata = $this->session->flashdata('message'); ?>
          <div class="alert alert-<?= $flashdata['class'] ?>">
            <button class="close" data-dismiss="alert" type="button">×</button>
            <?= $flashdata['message'] ?>
          </div>
          <?php } ?>
          <form role="form" action="<?= base_url($url) ?>" method="post" class="validate" data-parsley-validate="" enctype="multipart/form-data">
            <div class="card">
              <div class="card-header">
                <strong><?= $pDescription ?></strong>
              </div>
              <div class="card-body card-block">
                <div class="form-group">
                  <div class="row">
                    <div class="col-md-6">
                      <label for="nf-email" class=" form-control-label">POS Name</label>
                      <select name="pos_id" id="selectSm" class="form-control required">
                        <option value="">Please select</option>    
                        <?php foreach($pos_data as $key =>$pos) { ?> 
                        <?php  if  (isset($Posparts_id)||!empty($Posparts_id)) { ?>
                        <option <?= $PospartsData->pos_id == $pos->pos_id ? "selected" : "" ; ?> value="<?= $pos->pos_id ?>"><?= $pos->name ?></option>
                        <?php }else{?> 
                        <option  value="<?= $pos->pos_id ?>"><?= $pos->name ?></option>
                        <?php }} ?> 
                      </select>
                    </div>
                    <div class="col-md-6">
                      <label for="nf-email" class=" form-control-label">Parts Name</label>
                      <select name="parts_id" id="selectSm" class="form-control required">
                        <option value="">Please select</option>    
                         <?php foreach($part_data as $key =>$part) { ?> 
                        <?php  if  (isset($Posparts_id)||!empty($Posparts_id)) { ?>
                        <option <?= $PospartsData->part_id == $part->id ? "selected" : "" ; ?> value="<?= $part->id ?>"><?= $part->part_name ?></option>
                        <?php }else{?> 
                        <option  value="<?= $part->id ?>"><?= $part->part_name ?></option>
                        <?php }} ?> 
                      </select>
                    </div>
                  </div>
               
                </div>
                
                <div class="form-group">
                  <div class="row">
                  <div class="col-md-6">
                      <label for="nf-email" class=" form-control-label">Part Number</label>
                      <input type="text" readonly="" data-parsley-trigger="change" data-parsley-trigger="change"  data-parsley-minlength="2"  data-parsley-pattern="^[a-zA-Z0-9\ . _ - ' \/]+$" id="nf-brand" name="part_number" placeholder="Part Number" class="form-control required" value="<?= (isset($PospartsData->part_number))?$PospartsData->part_number:$pospart_code ?>"  >
                    </div>
                  
                     <div class="col-md-6">
                      <label for="nf-email" class=" form-control-label">Part Unique Name</label>
                      <input type="text" id="unique_name" name="unique_name" placeholder="Enter Part Unique Name" class="form-control required" onfocusout="myFunction()" value="<?= (isset($PospartsData->unique_name))?$PospartsData->unique_name:'' ?>" >
                      <br>
                       
                    </div>
                  </div>
                </div>

                
             
               
                <div class="form-group">
                  <div class="row">
                  
                    
                    <div class="col-md-6">
                      <label for="nf-email" class=" form-control-label">Price</label>
                      <input type="text" name="price" id="price"  required class="form-control required" placeholder="Enter Price"  value="<?= (isset($PospartsData->price))?$PospartsData->price:'' ?>">
                      
                   
                   
                    </div>
                     <div class="col-md-6">
                      <label for="nf-email" class=" form-control-label">Quantity</label>
                      <input type="text" name="quantity" id="quantity"  required class="form-control required" placeholder="Enter Price" value="<?= (isset($PospartsData->quantity))?$PospartsData->quantity:'' ?>">
                      
                   
                   
                    </div>
                  </div>
                </div>
                  

 <div id="scheduleTimerCntr"></div>


              
                  <div class="form-group">
                    <div class="row">
                      <div class="col-md-12">
                          <button type="submit" class="btn btn-primary">
                                <i class="fa "></i>Submit
                          </button>
                      </div>
                    </div>
                  </div>   
                </div>
              </div>
            </form>
          </div>
         </div>
      </div>
   </div>
   <div class="clear-fix"></div>
  


                <div class="form-group" id="scheduleTimerHtml" class="hide">
                  <div class="row" id="timePicker_{:count}">
                    <div class="col-md-6">
                    <label for="nf-email" class=" form-control-label">Provide services</label>
                     <select name="services[]"   class="form-control" data-placeholder="Choose Services...">
                  
                        <?php foreach($services as $service) { ?> 
                        <?php  if  (isset($Pos_id)||!empty($Pos_id)) { ?>
                       <option <?= $PosData->service_name == $service['service_name'] ? "selected" : "" ; ?> value="<?= $services['id'] ?>"><?= $service['service_name'] ?></option> 
                        <?php }else { ?> 
                        <option  value="<?= $service->id ?>"><?= $service->service_name ?></option>
                        <?php }} ?> 
                      </select>
                    </div>

                    <div class="col-md-5">
                    <label for="nf-email" class=" form-control-label">Services Amount </label>
                    <input type="text" data-parsley-trigger="change" data-parsley-trigger="change"  data-parsley-minlength="2"  data-parsley-pattern="^[0-9\ , - + \/]+$" id="nf-brand" name="amount[]" placeholder="Enter Services Amount" class="form-control required" value="<?= (isset($PosData->working_hours))?$PosData->working_hours:'' ?>" >
                       </div>
                  
                    <div class="col-md-1">
                    <div class="row marginTop10">
                      <div class="col-md-6"></div>
                      <div class="col-md-6">
                         <i class="padTop12 fa fa-times-circle-o cpoint fav-rem-icon" onclick="remTimePicker({:count})"></i>
                      </div>
                    </div>
                  </div>
                    
                  </div>
                </div>















<script type="text/javascript">

function addTimePicker(thisObj){
  var count = thisObj.attr('count')+1,
      inputHtml = jQuery('[id="scheduleTimerHtml"]').html();

  thisObj.attr('count',count);
  jQuery('[id="scheduleTimerCntr"]').append(inputHtml.replace(/{:count}/g,count));
}



function remTimePicker(count){
  jQuery('[id="timePicker_'+count+'"]').remove();
}



</script> 
       
  
 