Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
daim2k5 committed Jun 1, 2013
2 parents 0092477 + 1594474 commit d77f739
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 159 deletions.
57 changes: 51 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,55 @@
# FireGento Pdf
FireGento PDF
=============
FireGento PDF overwrites standard PDF layouts for invoices, shipments and creditmemos.

## Branches
Facts
-----
- version: 0.1.0
- extension key: FireGento_Pdf
- [extension on GitHub](https://github.com/firegento/firegento-pdf)
- [direct download link](https://github.com/firegento/firegento-pdf/archive/master.zip)

* master => stable branch
* development => development branch (bugs are fixed in this branch and new features are integrated here)
Description
-----------
FireGento PDF overwrites standard PDF layouts for invoices, shipments and creditmemos. Anyway, you can still use the standard Magento layout, because the extension is highly configurable.

## About this extension
Requirements
------------
- PHP >= 5.2.0
- Mage_Core
- Mage_Pdf
- Mage_Sales

FireGento Pdf overwrites standard PDF layouts for invoices, shipments and creditmemos.
Compatibility
-------------
- Magento >= 1.6

Installation Instructions
-------------------------
1. Install the extension via Magento Connect with the key shown above or copy all the files into your document root.
2. Clear the cache, logout from the admin panel and then login again.
3. Configure the extension under System - Configuration - PDF Print-outs.

Uninstallation
--------------
1. Remove all extension files from your Magento installation.

Support
-------
If you have any issues with this extension, open an issue on [GitHub](https://github.com/firegento/firegento-pdf/issues).

Contribution
------------
Any contribution is highly appreciated. The best way to contribute code is to open a [pull request on GitHub](https://help.github.com/articles/using-pull-requests).

Developer
---------
FireGento team and all other [contributors](https://github.com/firegento/firegento-pdf/contributors)

License
-------
[OSL - Open Software Licence 3.0](http://opensource.org/licenses/osl-3.0.php)

Copyright
---------
(c) 2013 FireGento Team
60 changes: 29 additions & 31 deletions app/code/community/FireGento/Pdf/Model/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,6 @@ public function drawLineBlocks(Zend_Pdf_Page $page, array $draw, array $pageSett
return $page;
}

/**
* Return status of the engine.
*
* @return bool
*/
abstract public function test();

/**
* Set pdf mode.
*
Expand Down Expand Up @@ -364,6 +357,9 @@ protected function insertHeader(&$page, $order, $document)

$page->drawText($customerid, ($this->margin['right'] - $rightoffset - $this->widthForStringUsingFontSize($customerid, $font, 10)), $this->y, $this->encoding);
$this->Ln();
}else{
$page->drawText('-', ($this->margin['right'] - $rightoffset - $this->widthForStringUsingFontSize('-', $font, 10)), $this->y, $this->encoding);
$this->Ln();
}

if (!Mage::getStoreConfigFlag('sales/general/hide_customer_ip', $order->getStoreId())) {
Expand Down Expand Up @@ -582,30 +578,32 @@ protected function insertTotals($page, $source)
$amount = $source->getDataUsingMethod($total['source_field']);
$displayZero = (isset($total['display_zero']) ? $total['display_zero'] : 0);

$amount = $order->formatPriceTxt($amount);
if ($amount != 0 || $displayZero) {
$amount = $order->formatPriceTxt($amount);

if (isset($total['amount_prefix']) && $total['amount_prefix']) {
$amount = "{$total['amount_prefix']}{$amount}";
}
if (isset($total['amount_prefix']) && $total['amount_prefix']) {
$amount = "{$total['amount_prefix']}{$amount}";
}

$label = Mage::helper('sales')->__($total['title']) . ':';

$label = Mage::helper('sales')->__($total['title']) . ':';

$lineBlock['lines'][] = array(
array(
'text' => Mage::helper('firegento_pdf')->__('Shipping:'),
'feed' => $this->margin['left'] + 320,
'align' => 'left',
'font_size' => $fontSize,
'font' => $fontWeight
),
array(
'text' => $amount,
'feed' => $this->margin['right'] - 10,
'align' => 'right',
'font_size' => $fontSize,
'font' => $fontWeight
),
);
$lineBlock['lines'][] = array(
array(
'text' => Mage::helper('firegento_pdf')->__('Shipping:'),
'feed' => $this->margin['left'] + 320,
'align' => 'left',
'font_size' => $fontSize,
'font' => $fontWeight
),
array(
'text' => $amount,
'feed' => $this->margin['right'] - 10,
'align' => 'right',
'font_size' => $fontSize,
'font' => $fontWeight
),
);
}
break;

case 'grand_total':
Expand Down Expand Up @@ -656,8 +654,8 @@ protected function insertTotals($page, $source)
$lineBlock['lines'][] = array(
array(
'text' => $label,
'feed' => $this->margin['right'] - 100,
'align' => 'right',
'feed' => $this->margin['left'] + 320,
'align' => 'left',
'font_size' => $fontSize,
'font' => $fontWeight
),
Expand Down
10 changes: 0 additions & 10 deletions app/code/community/FireGento/Pdf/Model/Creditmemo.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,5 @@ protected function _initRenderer($type)
);
}

/**
* Return status of the engine.
*
* @return bool
*/
public function test()
{
return true;
}

}

10 changes: 0 additions & 10 deletions app/code/community/FireGento/Pdf/Model/Engine/Invoice/Default.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,6 @@ protected function insertTableHeader(&$page)
$page->drawText($totalLabel, $this->margin['right'] - 10 - $this->widthForStringUsingFontSize($totalLabel, $font, 10), $this->y, $this->encoding);
}

/**
* Return status of the engine.
*
* @return bool
*/
public function test()
{
return true;
}

/**
* Initialize renderer process.
*
Expand Down
2 changes: 1 addition & 1 deletion app/code/community/FireGento/Pdf/Model/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected function getEngine()
$modelClass = Mage::getStoreConfig('sales_pdf/firegento_pdf/engine');
$engine = Mage::getModel($modelClass);

if (!$engine || ($engine instanceof FireGento_Pdf_Model_Abstract && !$engine->test())) {
if (!$engine) {
// Fallback to Magento standard invoice layout.
$engine = new Mage_Sales_Model_Order_Pdf_Invoice();
}
Expand Down
102 changes: 1 addition & 101 deletions app/code/community/FireGento/Pdf/Model/Shipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function getPdf($shipments = array())
}

/* add note */
$page = $this->_insertNote($page, $order, $creditmemo);
$page = $this->_insertNote($page, $order, $shipment);
}

$this->_afterGetPdf();
Expand All @@ -135,96 +135,6 @@ protected function insertTableHeader(&$page)
$page->drawText(Mage::helper('firegento_pdf')->__('Qty'), $this->margin['left'] + 450, $this->y, $this->encoding);
}

protected function insertHeader(&$page, $order, $shipment)
{
$page->setFillColor($this->colors['black']);

$mode = $this->getMode();

$this->_setFontBold($page, 15);

$page->drawText(Mage::helper('firegento_pdf')->__( ($mode == 'shipment') ? 'Shipment' : 'Creditmemo' ), $this->margin['left'], $this->y, $this->encoding);

$this->_setFontRegular($page);

$this->y += 60;
$rightoffset = 180;

$page->drawText(($mode == 'shipment') ? Mage::helper('firegento_pdf')->__('Shipment number:') : Mage::helper('firegento_pdf')->__('Creditmemo number:'), ($this->margin['right'] - $rightoffset), $this->y, $this->encoding);
$this->Ln();
$yPlus = 15;

$putOrderId = $this->_putOrderId($order);
if ($putOrderId) {
$page->drawText(Mage::helper('firegento_pdf')->__('Order number:'), ($this->margin['right'] - $rightoffset), $this->y, $this->encoding);
$this->Ln();
$yPlus += 15;
}

if ($order->getCustomerId() != '') {
$page->drawText(Mage::helper('firegento_pdf')->__('Customer number:'), ($this->margin['right'] - $rightoffset), $this->y, $this->encoding);
$this->Ln();
$yPlus += 15;
}

if (!Mage::getStoreConfigFlag('sales/general/hide_customer_ip', $order->getStoreId())) {
$page->drawText(Mage::helper('firegento_pdf')->__('Customer IP:'), ($this->margin['right'] - $rightoffset), $this->y, $this->encoding);
$this->Ln();
$yPlus += 15;
}

$page->drawText(Mage::helper('firegento_pdf')->__('Shipping date:'), ($this->margin['right'] - $rightoffset), $this->y, $this->encoding);
$this->Ln();
$yPlus += 15;

$this->y += $yPlus;

$rightoffset = 10;
$font = $this->_setFontRegular($page, 10);

$incrementId = $shipment->getIncrementId();
$page->drawText($shipment->getIncrementId(), ($this->margin['right'] - $rightoffset - $this->widthForStringUsingFontSize($incrementId, $font, 10)), $this->y, $this->encoding);
$this->Ln();

if ($putOrderId) {
$page->drawText($putOrderId, ($this->margin['right'] - $rightoffset - $this->widthForStringUsingFontSize($putOrderId, $font, 10)), $this->y, $this->encoding);
$this->Ln();
}

$prefix = Mage::getStoreConfig('sales_pdf/invoice/customeridprefix');

if (!empty($prefix)) {
if (($order->getCustomerId())) {
$customerid = $prefix . $order->getCustomerId();
} else {
$customerid = Mage::helper('firegento_pdf')->__('Guestorder');
}

} else {
if ($order->getCustomerId()) {
$customerid = $order->getCustomerId();
} else {
$customerid = Mage::helper('firegento_pdf')->__('Guestorder');
}
}

$rightoffset = 10;

$font = $this->_setFontRegular($page, 10);
$page->drawText($customerid, ($this->margin['right'] - $rightoffset - $this->widthForStringUsingFontSize($customerid, $font, 10)), $this->y, $this->encoding);
$this->Ln();
if (!Mage::getStoreConfigFlag('sales/general/hide_customer_ip', $order->getStoreId())) {
$customerIP = $order->getData('remote_ip');
$font = $this->_setFontRegular($page, 10);
$page->drawText($customerIP, ($this->margin['right'] - $rightoffset - $this->widthForStringUsingFontSize($customerIP, $font, 10)), $this->y, $this->encoding);
$this->Ln();
}

$shipmentDate = Mage::helper('core')->formatDate($shipment->getCreatedAtDate(), 'medium', false);
$page->drawText($shipmentDate, ($this->margin['right'] - $rightoffset - $this->widthForStringUsingFontSize($shipmentDate, $font, 10)), $this->y, $this->encoding);

}

protected function insertShippingAddress(&$page, $order)
{
$this->_setFontRegular($page, 9);
Expand Down Expand Up @@ -257,15 +167,5 @@ protected function _initRenderer($type)
);
}

/**
* Return status of the engine.
*
* @return bool
*/
public function test()
{
return true;
}

}

0 comments on commit d77f739

Please sign in to comment.