Wednesday, 13 January 2016

Magento admin order details Next and Previous order

/*************************************************************************/
        $conn = Mage::getSingleton('core/resource')->getConnection('core_read');
        $sql="SELECT sum(total_qty) as shipqty FROM sales_flat_shipment WHERE order_id=".$_order->getentity_id()." GROUP BY order_id  ";
        $results = $conn->fetchOne($sql);
        $per=($results/$total)*100;
        $orderAdminDate = $this->formatDate($_order->getCreatedAtDate(), 'medium', true);
        $orderStoreDate = $this->formatDate($_order->getCreatedAtStoreDate(), 'medium', true);
      
        $preOrderId=0;
        $nextOrderId=0;
        $curOrderId=0;
        $curOrderId=$_order->getId();
      
        $resource = Mage::getSingleton('core/resource');
        $tableName = $resource->getTableName('sales_flat_order');
        $readConnection = $resource->getConnection('core_read');
        $query = 'SELECT entity_id FROM ' . $tableName . ' WHERE entity_id < '.$curOrderId.' ORDER BY entity_id DESC LIMIT 0,1';
        $preOrderId = $readConnection->fetchOne($query);
      
        $query = 'SELECT entity_id FROM ' . $tableName . ' WHERE entity_id > '.$curOrderId.' ORDER BY entity_id ASC LIMIT 0,1';
        $nextOrderId = $readConnection->fetchOne($query);







?>
<?php //* ?>
<div style="width:300px;">
<?php if($preOrderId>0) { ?>
<div style="float:left" ><a href="<?php echo $this->getViewUrl($preOrderId) ?>" style="font-weight:bold">&laquo; Previous Order &nbsp;    </a></div>
<?php } else { ?>
<div style="float:left" >&laquo; Previous Order &nbsp;  </div>
<?php } if($nextOrderId>0) { ?>
<div style="float:right" ><a href="<?php echo $this->getViewUrl($nextOrderId) ?>" style="font-weight:bold">&nbsp;Next Order &raquo;</a></div>
<?php } else { ?>
<div style="float:right" >&nbsp;Next Order &raquo;</div>
<?php } ?>
</div>
<?php //*/ ?>

No comments:

Post a Comment