                    <div class="row">
                        <div class="col-sm-11">
                            <div class="page-title-box">
                                    <h2 class="page-title">View Transfer</h2>
                            </div><!--end page-title-box-->
                        </div><!--end col-->
                        <div class="col-sm-1">
                            <div class="page-title-box">
                                    <h2 class="page-title"><a href="stock_transfer"><button  class='btn btn-danger' type="button">Back</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-3">
                                            <?php 
                                                echo $this->Form->input('transferId', array('label'=>'Transfer Id', 'class'=>'form-control','readonly'=>'readonly','value'=>$transfers[0]['stock_transfers']['transfer_id']));
                                            ?>
                                        </div>
                                        <div class="col-sm-3">
                                            <?php 
                                                echo $this->Form->input('Transfer From', array( 'class'=>'form-control','readonly'=>'readonly','value'=>$transfers[0]['stock_transfers']['transfer_from']));
                                            ?>
                                        </div>
                                        <div class="col-sm-3">
                                            <?php 
                                                echo $this->Form->input('Transfer To', array( 'class'=>'form-control','readonly'=>'readonly','value'=>$transfers[0]['stock_transfers']['transfer_to']));
                                            ?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                      <div class="row" >
                        <div class="col-sm-12">
                            <div class="card">
                                <div class="card-body">
                                    <div class="form-group row">
                                        <div class="col-md-12">
                                            <h4 class="page-title">Transfer Items</h4>
                                            <?php
                                                foreach($items as $item){
                                                    ?>
                                                    <div class="form-group  row">
                                                        <div class="col-md-3"> 
                                                            <?php
                                                                echo $this->Form->input('name', array('div'=>array('class'=>'form-group'),'readonly'=>'readonly', 'class'=>'form-control','value'=>$item['stock_transfer_items']['sku_name']));
                                                            ?>
                                                        </div>
                                                        <div class="col-md-3"> 
                                                            <?php
                                                                echo $this->Form->input('unit', array('div'=>array('class'=>'form-group'),'readonly'=>'readonly', 'class'=>'form-control','value'=>$item['stock_transfer_items']['sku_unit_name']));
                                                            ?>
                                                        </div>
                                                        <div class="col-md-3"> 
                                                            <?php
                                                                echo $this->Form->input('price', array('div'=>array('class'=>'form-group'),'readonly'=>'readonly', 'class'=>'form-control','value'=>$item['stock_transfer_items']['sku_price']));
                                                            ?>
                                                        </div>
                                                        <div class="col-md-3"> 
                                                            <?php
                                                                echo $this->Form->input('quantity', array('div'=>array('class'=>'form-group'),'readonly'=>'readonly', 'class'=>'form-control','value'=>$item['stock_transfer_items']['sku_quantity']));
                                                            ?>
                                                        </div>
                                                        
                                                    </div>
                                                    <?php
                                                }
                                                
                                                $id=$indents[0]['inventory_purchase_order']['p_o_id'];
                                     
                                                if($indents[0]['inventory_purchase_order']['status']==1){
                                                    $buttonClass = 'btn-success';
                                                    $buttonText = 'Process PO';
                                                
                                                }else{
                                                    $buttonClass = 'btn-danger hidden';
                                                    $buttonText = 'Processed';
                                               
                                                }
                                                
                                                echo "<button class='btn $buttonClass mark-status' data-id='$id' style='float:right;'>$buttonText</button>";
            
                                            ?>
                                        </div>
                                    </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' => 'process_po']); ?>',
            type: 'POST',
            data: { _id: id },
            dataType: 'json',
            success: function(response) {
                if (response.status) {
                    alert('PO Processed');
                    // location.reload();
                    window.location.href='po_list';
                } else {
                    alert('Failed to process PO');
                }
            },
            error: function(xhr, status, error) {
                alert('An error occurred while updating the status.');
                console.log(xhr.responseText);
            }
        });
    });

});

</script>     
                