Skip to content

Commit

Permalink
fixed code style issues according to MEQP1
Browse files Browse the repository at this point in the history
  • Loading branch information
sprankhub committed Oct 14, 2017
1 parent dbd51a2 commit 8842d86
Show file tree
Hide file tree
Showing 35 changed files with 120 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ protected function _addListItems($items)
$item['label']
);
}

return $this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class FireGento_Pdf_Block_Adminhtml_System_Config_Form_Field_Notes
*/
protected function _getCountryRenderer()
{
if ( ! $this->_countryRenderer) {
if (!$this->_countryRenderer) {
$this->_countryRenderer = $this->getLayout()->createBlock(
'firegento_pdf/adminhtml_system_config_form_field_notes_country', '',
array('is_render_to_js_template' => true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function setInputName($value)
*/
public function _toHtml()
{
if ( ! $this->getOptions()) {
if (!$this->getOptions()) {
$countryModel = Mage::getModel('adminhtml/system_config_source_country');
foreach ($countryModel->toOptionArray() as $country) {
$this->addOption($country['value'], $country['label']);
Expand Down
42 changes: 27 additions & 15 deletions src/app/code/community/FireGento/Pdf/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function isLogoFullWidth($store)
*
* @return bool whether the customer number should be shown
*/
public function showCustomerNumber($mode = 'invoice', $store)
public function showCustomerNumber($mode = 'invoice', $store = null)
{
switch ($mode) {
case 'invoice':
Expand Down Expand Up @@ -158,7 +158,7 @@ public function showCustomerNumber($mode = 'invoice', $store)
*
* @return bool whether the customer number should be shown
*/
public function showCustomerVATNumber($mode = 'invoice', $store)
public function showCustomerVATNumber($mode = 'invoice', $store = null)
{
switch ($mode) {
case 'invoice':
Expand Down Expand Up @@ -189,25 +189,32 @@ public function showCustomerVATNumber($mode = 'invoice', $store)
*
* @return string customer number for guest orders
*/
public function getGuestorderCustomerNo($mode = 'invoice', $store)
public function getGuestorderCustomerNo($mode = 'invoice', $store = null)
{
switch ($mode) {
case 'invoice':
return trim(Mage::getStoreConfigFlag(
self::XML_PATH_SALES_PDF_INVOICE_GUEST_ORDER_CUSTOMER_NUMBER,
$store
));
return trim(
Mage::getStoreConfigFlag(
self::XML_PATH_SALES_PDF_INVOICE_GUEST_ORDER_CUSTOMER_NUMBER,
$store
)
);
case 'shipment':
return trim(Mage::getStoreConfigFlag(
self::XML_PATH_SALES_PDF_SHIPMENT_GUEST_ORDER_CUSTOMER_NUMBER,
$store
));
return trim(
Mage::getStoreConfigFlag(
self::XML_PATH_SALES_PDF_SHIPMENT_GUEST_ORDER_CUSTOMER_NUMBER,
$store
)
);
case 'creditmemo':
return trim(Mage::getStoreConfigFlag(
self::XML_PATH_SALES_PDF_CREDITMEMO_GUEST_ORDER_CUSTOMER_NUMBER,
$store
));
return trim(
Mage::getStoreConfigFlag(
self::XML_PATH_SALES_PDF_CREDITMEMO_GUEST_ORDER_CUSTOMER_NUMBER,
$store
)
);
}

return true; // backwards compatibility
}

Expand Down Expand Up @@ -324,6 +331,7 @@ public function getModelVars($model)
'{{creditmemo_id}}' => $model->getIncrementId()
);
}

$order = $model->getOrder();
$commonVars = array(
'{{order_id}}' => $order->getIncrementId(),
Expand Down Expand Up @@ -363,9 +371,11 @@ public function getExportFilename($type, $model)
} else {
$pattern = $type;
}

$date = Mage::getSingleton('core/date');
$pattern .= $date->date('Y-m-d_H-i-s');
}

if (substr($pattern, -4) != '.pdf') {
$pattern = $pattern . '.pdf';
}
Expand Down Expand Up @@ -393,9 +403,11 @@ public function getExportFilenameForMultipleDocuments($type)
} else {
$pattern = $type;
}

$date = Mage::getSingleton('core/date');
$pattern .= $date->date('Y-m-d_H-i-s');
}

if (substr($pattern, -4) != '.pdf') {
$pattern = $pattern . '.pdf';
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/code/community/FireGento/Pdf/Helper/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function getShippingCountryNotes(Mage_Sales_Model_Order $order)
if (!$order->getIsVirtual()) {
$shippingCountryId = $order->getShippingAddress()->getCountryId();
$countryNotes = unserialize(Mage::getStoreConfig('sales_pdf/invoice/shipping_country_notes'));
if($countryNotes) {
if ($countryNotes) {
$shippingCountryNotes = array();
foreach ($countryNotes as $countryNote) {
if ($countryNote['country'] == $shippingCountryId) {
Expand Down
4 changes: 2 additions & 2 deletions src/app/code/community/FireGento/Pdf/Model/Creditmemo.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class FireGento_Pdf_Model_Creditmemo
* The actual PDF engine responsible for rendering the file.
* @var Mage_Sales_Model_Order_Pdf_Abstract
*/
private $_engine;
protected $_engine;

/**
* get pdf renderer engine
Expand All @@ -47,7 +47,7 @@ protected function getEngine()

if (!$engine || $engine instanceof FireGento_Pdf_Model_Creditmemo) {
// Fallback to Magento standard creditmemo layout.
$engine = new Mage_Sales_Model_Order_Pdf_Creditmemo();
$engine = Mage::getModel('sales/order_pdf_creditmemo');
}

$this->_engine = $engine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public function getPdf($creditmemos = array())
Mage::app()->getLocale()->emulate($creditmemo->getStoreId());
Mage::app()->setCurrentStore($creditmemo->getStoreId());
}

$order = $creditmemo->getOrder();
$this->setOrder($order);

Expand All @@ -78,6 +79,7 @@ public function getPdf($creditmemos = array())
if ($item->getOrderItem()->getParentItem()) {
continue;
}

/* Draw item */
$position++;
$this->_drawItem($item, $page, $order, $position);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public function getPdf($invoices = array())
Mage::app()->getLocale()->emulate($invoice->getStoreId());
Mage::app()->setCurrentStore($invoice->getStoreId());
}

$order = $invoice->getOrder();
$this->setOrder($order);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function getPdf($shipments = array())
Mage::app()->getLocale()->emulate($shipment->getStoreId());
Mage::app()->setCurrentStore($shipment->getStoreId());
}

$order = $shipment->getOrder();
$this->setOrder($order);

Expand Down Expand Up @@ -125,11 +126,9 @@ public function getPdf($shipments = array())
protected function _insertCustomerAddress($page, $order)
{
$this->_setFontRegular($page, 9);
$shipping = $this->_formatAddress($order->getShippingAddress()
->format('pdf'));
$shipping = $this->_formatAddress($order->getShippingAddress()->format('pdf'));
foreach ($shipping as $line) {
$page->drawText(trim(strip_tags($line)), $this->margin['left'],
$this->y, $this->encoding);
$page->drawText(trim(strip_tags($line)), $this->margin['left'], $this->y, $this->encoding);
$this->Ln(12);
}
}
Expand All @@ -144,8 +143,7 @@ protected function insertTableHeader($page)
$page->setFillColor($this->colors['header']);
$page->setLineColor($this->colors['header']);
$page->setLineWidth(1);
$page->drawRectangle($this->margin['left'], $this->y,
$this->margin['right'] - 10, $this->y - 15);
$page->drawRectangle($this->margin['left'], $this->y, $this->margin['right'] - 10, $this->y - 15);

$page->setFillColor($this->colors['black']);
$this->_setFontRegular($page, 9);
Expand Down Expand Up @@ -182,12 +180,10 @@ protected function insertShippingAddress($page, $order)
{
$this->_setFontRegular($page, 9);

$billing = $this->_formatAddress($order->getShippingAddress()
->format('pdf'));
$billing = $this->_formatAddress($order->getShippingAddress()->format('pdf'));

foreach ($billing as $line) {
$page->drawText(trim(strip_tags($line)), $this->margin['left'],
$this->y, $this->encoding);
$page->drawText(trim(strip_tags($line)), $this->margin['left'], $this->y, $this->encoding);
$this->Ln(12);
}
}
Expand All @@ -203,16 +199,19 @@ protected function insertShippingAddress($page, $order)
*/
protected function _printShipmentTracks($page, $order, $shipment)
{
if ( ! Mage::getStoreConfigFlag('sales_pdf/shipment/show_tracking_numbers') || $order->getIsVirtual()) {
if (!Mage::getStoreConfigFlag('sales_pdf/shipment/show_tracking_numbers') || $order->getIsVirtual()) {
return $page;
}

$tracks = array();
if ($shipment) {
$tracks = $shipment->getAllTracks();
}

if (empty($tracks)) {
return $page;
}

$this->y -= 20;
$page->setFillColor($this->colors['header']);
$page->setLineColor($this->colors['header']);
Expand Down
4 changes: 2 additions & 2 deletions src/app/code/community/FireGento/Pdf/Model/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class FireGento_Pdf_Model_Invoice
*
* @var Mage_Sales_Model_Order_Pdf_Abstract
*/
private $_engine;
protected $_engine;

/**
* get pdf rendering engine
Expand All @@ -51,7 +51,7 @@ protected function getEngine()

if (!$engine || $engine instanceof FireGento_Pdf_Model_Invoice) {
// Fallback to Magento standard invoice layout.
$engine = new Mage_Sales_Model_Order_Pdf_Invoice();
$engine = Mage::getModel('sales/order_pdf_invoice');
}

$this->_engine = $engine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public function draw($position = 1)
} else {
$name = $_item->getName();
}

$line[] = array(
'text' => Mage::helper('core/string')->str_split($name, 35, true, true),
'feed' => $pdf->margin['left'] + 130,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public function draw($position = 1)
if (isset($option['value'])) {
$optionTxt .= isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']);
}

$optionArray = $pdf->_prepareText($optionTxt, $page, $pdf->getFontRegular(), $fontSize, 215);
$lines[][] = array(
'text' => $optionArray,
Expand Down
22 changes: 8 additions & 14 deletions src/app/code/community/FireGento/Pdf/Model/Items/Downloadable.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,10 @@ public function draw($position = 1)
$optionTxt = $option['label'] . ': ';
// append option value
if (isset($option['value'])) {
$optionTxt .= isset($option['print_value'])
? $option['print_value'] : strip_tags($option['value']);
$optionTxt .= isset($option['print_value'])? $option['print_value'] : strip_tags($option['value']);
}
$optionArray = $pdf->_prepareText($optionTxt, $page,
$pdf->getFontRegular(), $fontSize, 215);

$optionArray = $pdf->_prepareText($optionTxt, $page, $pdf->getFontRegular(), $fontSize, 215);
$lines[][] = array(
'text' => $optionArray,
'feed' => $pdf->margin['left'] + 135,
Expand Down Expand Up @@ -147,34 +146,30 @@ public function draw($position = 1)

// prepare tax_rate
$columns['tax_rate'] = array(
'text' => round($item->getOrderItem()->getTaxPercent(), 2)
. '%',
'text' => round($item->getOrderItem()->getTaxPercent(), 2) . '%',
'align' => 'right',
'font_size' => $fontSize,
'_width' => 50
);

// prepare subtotal
$columns['subtotal'] = array(
'text' => $order->formatPriceTxt($item->getPrice()
* $item->getQty() * 1),
'text' => $order->formatPriceTxt($item->getPrice() * $item->getQty() * 1),
'align' => 'right',
'font_size' => $fontSize,
'_width' => 50
);

// prepare subtotal_incl_tax
$columns['subtotal_incl_tax'] = array(
'text' => $order->formatPriceTxt(($item->getPrice()
* $item->getQty() * 1) + $item->getTaxAmount()),
'text' => $order->formatPriceTxt(($item->getPrice() * $item->getQty() * 1) + $item->getTaxAmount()),
'align' => 'right',
'font_size' => $fontSize,
'_width' => 70
);

// draw columns in specified order
$columnsOrder = explode(',',
Mage::getStoreConfig('sales_pdf/invoice/item_price_column_order'));
$columnsOrder = explode(',', Mage::getStoreConfig('sales_pdf/invoice/item_price_column_order'));
// draw starting from right
$columnsOrder = array_reverse($columnsOrder);
$columnOffset = 0;
Expand Down Expand Up @@ -209,8 +204,7 @@ public function draw($position = 1)
'height' => 15
);

$page = $pdf->drawLineBlocks($page, array($lineBlock),
array('table_header' => true));
$page = $pdf->drawLineBlocks($page, array($lineBlock), array('table_header' => true));
$this->setPage($page);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public function draw()
foreach (Mage::helper('core/string')->str_split($_item->getSku(), 20) as $part) {
$text[] = $part;
}

$line[] = array(
'text' => $text,
'feed' => 45,
Expand All @@ -99,10 +100,12 @@ public function draw()
} else {
$name = $_item->getName();
}

$text = array();
foreach (Mage::helper('core/string')->str_split($name, 60, true, true) as $part) {
$text[] = $part;
}

$line[] = array(
'text' => $text,
'feed' => 150,
Expand Down
Loading

0 comments on commit 8842d86

Please sign in to comment.