                     <div class="row">
                        <div class="col-sm-10">
                            <div class="page-title-box">
                                    <h2 class="page-title">Stock Transfer</h2>
                            </div><!--end page-title-box-->
                        </div><!--end col-->
                        <div class="col-sm-2">
                            <div class="page-title-box">
                                    <h2 class="page-title"><a href="create_stock_tranfer"><button  class='btn btn-success' type="button" style="float:right">Create Stock Transfer</button></a></h2>
                            </div><!--end page-title-box-->
                        </div><!--end col-->
                    </div>
                    
                    <div class="row" >
                        <div class="col-sm-12">
                            <div class="card">
                                <div class="card-body">
                                    
                                    <div class="form-group row">
                                        <div class="col-sm-8">
                                            <?php echo $this->Form->create('Search', array('url'=>'stock_transfer')); 
                                                echo $this->Form->input('startdate', array('div'=>array('class'=>'form-group'), 'label'=>array('class'=>'form-label'), 'class'=>'form-control calendarmultiple', 'between'=>'<span class="desc"></span><div class="controls">', 'after'=>'</div>', 'label'=>'Select Date','id'=>'startdate','name'=>'daterange','required'=>'required'	, 'value' => $startdate )); 
                                                echo $this->Form->button('View', array('class'=>'btn btn-info', 'type'=>'submit'));
                                                //echo"&nbsp;". $this->Form->button('Export', array('class'=>'btn btn-info', 'type'=>'button','id'=>'exportdata'));
                                                echo $this->Form->end(); 
                                            ?>
                                        </div>
                                    </div>
                                    <div style="height:30px; width: 100%" class="clearfix"></div>
                                <div class="row">
                                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                                     <table id="example" class="display table table-hover table-condensed" cellspacing="0" width="100%">
                                            <thead>
                                                <tr>
                                                    <th><?php echo '#'; ?></th>
                                                    <th><?php echo 'Transfer Id'; ?></th>
                                                    <th><?php echo 'Transfer From'; ?></th>
                                                    <th><?php echo 'Transfer To'; ?></th>
                                                    <th><?php echo 'Created'; ?></th>
                                                    <th><?php echo 'Action'; ?></th>
                                                </tr>
                                            </thead>

                                            <tbody>
                                  <?php $x=1;
                                  foreach ($users as $user):
                                      
                                      $id=$user['stock_transfers']['id'];
                                      $tr_id=$user['stock_transfers']['transfer_id'];
                                       
                                      if($user['stock_transfers']['status']==0){
                                          
                                          $status='Inactive';
                                          $buttonClass = 'btn-success';
                                          $buttonText = 'Mark Active';
                                          $buttonDisabled = '';

                                      }
                                      if($user['stock_transfers']['status']==1){
                                          $status='Active';
                                          $buttonClass = 'btn-danger';
                                          $buttonText = 'Delete';
                                          $buttonDisabled = '';

                                      }
                                      
                                  ?>
    <tr>
        <td><?php print_r($x);?></td>
        <td><?php print_r($user['stock_transfers']['transfer_id']);?></td>
        <td><?php print_r($user['stock_transfers']['transfer_from']);?></td>
        <td><?php print_r($user['stock_transfers']['transfer_to']);?></td>
        <td><?php print_r($user['stock_transfers']['created']);?></td>
        <td>
            <?php
            echo '<a href="view_stock_transfer?id=' . $user['stock_transfers']['transfer_id'] . '">
                <button class="btn btn-info" type="button" >View</button>
            </a>';
            // echo '<a href="edit_po?id=' . $user['stock_transfers']['p_o_id'] . '">
            //     <button class="btn btn-info" type="button" '.$buttonDisabled.'>Edit</button>
            //   </a>';
            // echo "<button class='btn $buttonClass mark-status' data-id='$id' $buttonDisabled>$buttonText</button>";
            ?>
        
        </td>
       
    </tr>
<?php $x++;endforeach; ?>            
                                            </tbody>
                                        </table>
                                        <!-- ********************************************** -->

    
                                </div>
                                </div>
                           
                                         
                            </div>
                        </section></div>




                                </div>
                            </div>
                        </div> 
                    </div>
                                     
<script>
    
            
$(document).ready(function() {
    // Handle status toggle button click
    $(document).on('click', '.mark-status', function() {
        var id = $(this).data('id');
        var button = $(this);

        $.ajax({
            url: '<?php echo Router::url(['controller' => 'Dashboard', 'action' => 'delete_stock_transfer']); ?>',
            type: 'POST',
            data: { _id: id },
            dataType: 'json',
            success: function(response) {
                if (response.status) {
                    // alert('Status Updated');
                    location.reload();
                } else {
                    alert('Failed to update status');
                }
            },
            error: function(xhr, status, error) {
                alert('An error occurred while updating the status.');
                console.log(xhr.responseText);
            }
        });
    });

});


   
$("#btn-pdf").click(function(){
	var pdfform =document.getElementById('pdfform');
	$('#pdfform').hide();
	var form_data = new FormData(pdfform);
      
	var poid=$("#poid").val();
	
    var poidelement= document.createElement("input"); 
    poidelement.value=poid;
	poidelement.name="poid";
	pdfform.appendChild(poidelement); 
	pdfform.submit(); 

	});



</script> 
                