Reputation: 101
Now on magento when I print an Invoice as PDF, it shows "Order date".. we need to replace it with the "Invoice Creation Date".
Can you tell me how to do that?
Thanks.
Upvotes: 1
Views: 8349
Reputation: 106
I had same problem and added invoice date to app/code/core/Mage/Sales/Model/Order/invoice.php at line 132
/* Add document text and number */
$this->insertDocumentNumber(
$page,
Mage::helper('sales')->__('Invoice # ') . $invoice->getIncrementId()
.' '.
Mage::helper('sales')->__('Invoice date: ') . Mage::helper('core')->formatDate(
$invoice->getCreatedAt(), 'medium', false
),
35,
($top -= 15),
'UTF-8'
);
Upvotes: 0
Reputation: 1782
Load the invoice by
$invoice = Mage::getModel('sales/order_invoice')->loadByIncrementId($invoiceIncrementId);
and then get the invoice date using
$createdDate = $invoice->getCreatedAt();
and put $createdDate and modify the below code from
$page->drawText(
Mage::helper('sales')->__('Order Date: ') . Mage::helper('core')->formatDate(
$order->getCreatedAtStoreDate(), 'medium', false
),
35,
($top -= 15),
'UTF-8'
);
To
$page->drawText(
Mage::helper('sales')->__('Invoice Creation Date: ') . Mage::helper('core')->formatDate(
$createdDate, 'medium', false
),
35,
($top -= 15),
'UTF-8'
);
NOTE :-
If you have multiple invoices for the same order then you can get the all invoice increment id by
$_invoices = $_order->getInvoiceCollection();
foreach($_invoices as $_invoice){
$_invoice->getIncrementId() = $_invoice->getIncrementId();
}
Upvotes: 1
Reputation: 520
Since Magento is creating PDF of orders strictly via PHP code (means it doesn't use any html->pdf parser or any similar idea), you will have to extend the class that does that and modify it accordingly. So, the class that you are looking for is:
Mage_Sales_Model_Order_Pdf_Invoice
with the method
protected function insertOrder(&$page, $obj, $putOrderId = true)
then search for
$page->drawText( Mage::helper('sales')->__('Order Date: ') . Mage::helper('core')->formatDate($order->getCreatedAtStoreDate(), 'medium', false), 35, ($top -= 15), 'UTF-8');
And I would guess that you know how to extend it with your own module. If not, the process is described in How to create a simple 'Hello World' module in Magento?.
Upvotes: 0