<?php $this->load->view("common/header"); ?>
<!-- end: HEAD -->


<!-- end: CSS REQUIRED FOR THIS PAGE ONLY -->
<!-- end: HEAD -->
<!-- start: BODY -->
<body>

<!-- start: HEADER -->
<div class="navbar navbar-inverse navbar-fixed-top"> 
  <!-- start: TOP NAVIGATION CONTAINER -->
  <div class="container">
    <div class="navbar-header"> 
      <!-- start: RESPONSIVE MENU TOGGLER -->
      <button data-target=".navbar-collapse" data-toggle="collapse" class="navbar-toggle" type="button"> <span class="clip-list-2"></span> </button>
      <!-- end: RESPONSIVE MENU TOGGLER --> 
      <!-- start: LOGO -->
      <?php $this->load->view("common/logo"); ?>
      <!-- end: LOGO --> 
    </div>
    <div class="navbar-tools"> 
      <!-- start: TOP NAVIGATION MENU -->
      <?php $this->load->view("common/notifications.php"); ?>
      <!-- end: TOP NAVIGATION MENU --> 
    </div>
  </div>
  <!-- end: TOP NAVIGATION CONTAINER --> 
</div>
<!-- end: HEADER --> 
<!-- start: MAIN CONTAINER -->
<div class="main-container">
<div class="navbar-content"> 
  <!-- start: SIDEBAR -->
  <?php $this->load->view("common/navigation"); ?>
  <!-- end: SIDEBAR --> 
</div>
<!-- start: PAGE -->
<div class="main-content">
<!-- end: SPANEL CONFIGURATION MODAL FORM -->
<div class="container">
<!-- start: PAGE HEADER -->
<div class="row">
  <div class="col-sm-12"> 
    <!-- start: PAGE TITLE & BREADCRUMB -->
    <ol class="breadcrumb">
      <li> <a href="#"> Dashboard </a> </li>
      <li> <a href="<?php echo base_url('marketing_delivery_process/add_new_delivery'); ?>">Loading</a> </li>
      <li class="active">Arange Sample </li>
      <li class="search-box">
        <form class="sidebar-search">
          <div class="form-group">
            <input type="text" placeholder="Start Searching...">
            <button class="submit"> <i class="clip-search-3"></i> </button>
          </div>
        </form>
      </li>
    </ol>
    <div class="page-header">
      <h3>Arange Sample </h3>
    </div>
    <p>Please fill in the information below. The field labels marked with * are required input fields.</p>
  </div>
</div>
<!-- end: PAGE HEADER --> 
<!-- start: PAGE CONTENT 
                    <!-- start grid -->

<div class="row">
  <div class="col-md-12"> 
    <!-- start: DYNAMIC TABLE PANEL -->
    <div class="panel panel-default">
      <div class="panel-heading"> <i class="fa fa-plus"></i> Arange Sample</div>
      <div class="panel-body">
        <div class="alert alert-danger" style="display:none;">
          <button class="close" data-dismiss="alert"> × </button>
          <i class="fa fa-times-circle"></i> <strong></strong> <span class="errortxt"></span> </div>
        <div class="alert alert-success" style="display:none;">
          <button class="close" data-dismiss="alert"> × </button>
          <i class="fa fa-check-circle"></i> <strong></strong><span class="succetxt"></span> </div>
        <form role="form" class="form-horizontal" id="create_sales_form" action="#" method="post">
          <div class="col-md-12"></div>
          <!--col-md-12-->
          <div class="col-md-12">
            <div class="col-md-12">
              <div class="panel panel-default">
                <div class="panel-heading" style="font-weight: 700;">
                
                 <div class="col-md-3">Date Time -
                  <?php echo $delivary_details['loading_date_time']?>
                  </div> Area -
                  <?php echo $delivary_details['area_name']?>
                   <div class="col-md-3"> Vehicle -
                  <?php echo $delivary_details['vehicle_code']?>
                  </div> <div class="col-md-3"> Sales Rep -
                  <?php echo $delivary_details['user_first_name']?></div>
                </div>
                <div class="panel-body">
                  <input id="status" name="status" type="hidden" value="<?php //echo $status;?>">
                  <input id="delivary_id" name="delivary_id" type="hidden" value="<?php echo $delivary_id;?>">
                  <div class="col-md-12">
                    <div class="form-group">
                      <table class="table items table-striped table-bordered table-condensed table-hover" id="term_table">
                        <thead>
                          <tr>
                            <th> <input id="checkAll"  type="checkbox" align="center" value="" > Select All </th>
                            <th class="col-md-1">Referance code</th>
                            <th  class="col-sm-1" >Sales Rep.</th>
                            <th  class="col-sm-1" >Route</th>
                            <th class="col-sm-1" >Order Date</th>
                            <th class="col-sm-6">Product</th>
                            <th class="col-sm-1">Order qty</th>
                            
                          </tr>
                        </thead>
                        <tbody>
                          <?php
$totqty=0;
$count=1;
 foreach($sample_pending_list as $row2){  
?>
                          <tr data-item-id="144680019784" id="row_1446800197032">
                            <td align="center"><input name="check[<?php echo $count; ?>]" type="checkbox" align="center" value="<?php echo $row2['sample_order_item_id']?>" ></td>
                             
                            <td><?php echo $row2['sample_ref_no']?></td>
                             <td><?php echo $row2['user_first_name']?></td>
                             <td><?php echo $row2['route_code']?></td>
                             
                            <td><?php echo $row2['sample_order_date']?></td>
                           
                            <td><?php echo "[".$row2['product_code']."] ". $row2['product_name']?></td>
                            <td><?php echo $row2['order_qty']; ?> </td>
                          </tr>
                          <?php
						  $count++;
						   }?>
                        </tbody>
                        <tfoot>
                          <tr class="tfoot active" id="tfoot">
                          <th> </th>
                            <th >Referance code</th>
                            <th   >Sales Rep.</th>
                            <th  >Route</th>
                            <th >Order Date</th>
                            <th >Total Value</th>
                            <th >Details</th>
                          </tr>
                        </tfoot>
                      </table>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <!--col-md-8-->
          
          <div class="col-md-12">
            <div class="modal-footer" style="margin-bottom:10px;">
              <input type="submit" class="btn btn-primary" value="Next" name="add_sale" id="add_sale">
               <a class="btn btn-danger "  href="<?php echo base_url('marketing_delivery_process/settu_customer_order_load/'.$delivary_details['id']); ?>"> Skip This Step </a>
       
            </div>
          </div>
        </form>
        
        <!-- end: DYNAMIC TABLE PANEL --> 
        
      </div>
    </div>
    
    <!-- end grid --> 
    
  </div>
  <!-- end: PAGE --> 
</div>
<!-- end: MAIN CONTAINER --> 
<!-- start: FOOTER -->
<div class="footer clearfix">
  <div class="footer-inner"> 2014 &copy; clip-one by cliptheme. </div>
  <div class="footer-items"> <span class="go-top"><i class="clip-chevron-up"></i></span> </div>
</div>
<!-- end: FOOTER --> 
<!-- start: RIGHT SIDEBAR --> 
<!-- end: RIGHT SIDEBAR -->
<div id="event-management" class="modal fade" tabindex="-1" data-width="760" style="display: none;">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> &times; </button>
        <h4 class="modal-title">Event Management</h4>
      </div>
      <div class="modal-body"></div>
      <div class="modal-footer">
        <button type="button" data-dismiss="modal" class="btn btn-light-grey"> Close </button>
        <button type="button" class="btn btn-danger remove-event no-display"> <i class='fa fa-trash-o'></i> Delete Event </button>
        <button type='submit' class='btn btn-success save-event'> <i class='fa fa-check'></i> Save </button>
      </div>
    </div>
  </div>
</div>
<input name="tmpVal" type="hidden" id="tmpVal" value="0">
<input name="" id="type_sale" type="hidden" value="22">
<!-- start ajax model -->
<div id="ajax-modal" class="modal fade" data-backdrop="static" data-keyboard="false" tabindex="-1" style="display: none;"></div>
<!-- end ajax model --> 

<!-- start: MAIN JAVASCRIPTS -->
<?php $this->load->view("common/footer"); ?>
<script src="<?php echo asset_url(); ?>js/jquery-ui.js" ></script> 
<script src="<?php echo asset_url(); ?>js/moment-with-locales.js"></script> 
<script type="text/javascript" src="<?php echo asset_url(); ?>js/bootstrap-datetimepicker.js"></script> 
<script type="text/javascript" src="<?php echo asset_url(); ?>js/bootbox.min.js"></script> 
<script type="text/javascript" src="<?php echo asset_url(); ?>js/accounting.js"></script> 
<script type="text/javascript" src="<?php echo asset_url(); ?>js/accounting.min.js"></script> 

<!-- end: MAIN JAVASCRIPTS --> 

<!-- start: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY VALIDATION--> 
<script src="<?php echo asset_url(); ?>js/form-validation-create_chit.js"></script> 
<script src="<?php echo asset_url(); ?>js/chit_invoice.js"></script> 
<!-- end: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY  VALIDATION--> 
<script>

function insertSalesData() {
    var type = 'A';
    var sale_reference_no = $('#sale_reference_no').val();
    var fields = $("#create_sales_form").serialize();
    var rowCount = $('#rowCount').val();
    if (rowCount != 0) {
        $("#add_sale").prop("disabled", true);
        $("#add_sale").val('Please wait...');
        $.post("<?php echo base_url();?>marketing_delivery_process/save_arrangend_order", fields).success(function(data) {
            //window.alert(fields);
            var obj = jQuery.parseJSON(data);
            if (obj.error == 1) {
                $('.alert-success').hide();
                $('.alert-danger').show();
                $(".errortxt").text(obj.disMsg);
                window.scrollTo(500, 0);
                //empty item table
				
            }
            if (obj.error == 0) {
                window.scrollTo(500, 0);
                displayNotice('page', 'Seettu successfully added!');
                //window.location.href = "marketing_order_arrange_manage_cus_issue";
                clearForm();
				bootbox.alert(obj.validation, function(){           		 
       			});
                //window.location.reload();
                //empty footer details
				location.href = "<?php echo base_url('marketing_delivery_process/pending_delivery_details');?>/" +obj.delivery_id;
            }
        }).fail(function(jqXHR, textStatus, error) {
            // Handle error here
            alert("Errror : All Data required. You miss some data - " + error);
            //location.reload();
        });
    } else {
        bootbox.alert('Please add terms.', function() {
            $('#add_item').focus();
        });
    }
}

//function to initiate bootstrap-datepicker
$(function() {
    //showKeys();
    var currentDate = new Date();
    $('#open_datetime').datetimepicker({
        defaultDate: new Date()
    });   
});

$(document).ready(function() {
	clearForm();
    $('#in_type').focus();
    $(".noEnterSubmit").on('keyup', function(e) {});
    $('#add_sale').keypress(function(event) {});
    $(window).keydown(function(event) {
        $(":focus").each(function() {
            //alert("Focused Elem_id = "+ this.id );
            focus_id = this.id;
            //	alert(focus_id);
            //	alert(event.keyCode);
            var rowCount = $('#rowCount').val();
            var fld = 'quantity_' + rowCount;
            if (focus_id == fld) {
                if (event.keyCode == 16) {
                    $('#add_item').focus();
                }
            }
            if (event.keyCode == 18) {
                setTimeout(function() {
                    //alert();
                    $("#create_sales_form").submit() //do something special
                }, 1000);
                //	alert(114);
                //$('#create_sales_form').submit(function(){return true;});
                // event.preventDefault();
                // return false;
            }
            if (event.keyCode == 13) {
                event.preventDefault();
                return false;
            }
        });
    });
});


$("#checkAll").click(function(){
    $('input:checkbox').not(this).prop('checked', this.checked);
});

</script>
</body>
<!-- end: BODY -->
</html>