Chủ Nhật, 11 tháng 10, 2015

Cách nối file PDF thành 1 file duy nhất.

Truy cập vào link website này và chọn 2 file pdf và MERGE thành 1 file duy nhất

https://foxyutils.com/mergepdf/

hoặc : https://www.pdfmerge.com/

hoặc phần mềm ghép: 
http://taimienphi.vn/download-adolix-split-merge-pdf-3860/taive

Thứ Tư, 4 tháng 3, 2015

NHẬN THIẾT KẾ và XÂY DỰNG WEBSITE


NHẬN THIẾT KẾ và XÂY DỰNG WEBSITE.


WEBSITE (GIỚI THIỆU, TIN TỨC, BÁN HÀNG.......)

LIÊN HỆ:
+ Email:hongdiepbach@gmail.com
+ Skype: hoadiepdo99

Thứ Năm, 8 tháng 1, 2015

Thêm tùy chọn số trang trong magento

Adding rows per page to Magento admin grid 




Go to app/design/adminhtml/default/default/template/widget/grid.html (line 81) and add change this:
           <select name="<?php echo $this->getVarNameLimit() ?>" onchange="<?php echo $this->getJsObjectName() ?>.loadByElement(this)">
                <option value="20"<?php if($this->getCollection()->getPageSize()==20): ?> selected="selected"<?php endif; ?>>20</option>
                <option value="30"<?php if($this->getCollection()->getPageSize()==30): ?> selected="selected"<?php endif; ?>>30</option>
                <option value="50"<?php if($this->getCollection()->getPageSize()==50): ?> selected="selected"<?php endif; ?>>50</option>
                <option value="100"<?php if($this->getCollection()->getPageSize()==100): ?> selected="selected"<?php endif; ?>>100</option>
                <option value="200"<?php if($this->getCollection()->getPageSize()==200): ?> selected="selected"<?php endif; ?>>200</option>
            </select>
To this:

            <select name="<?php echo $this->getVarNameLimit() ?>" onchange="<?php echo $this->getJsObjectName() ?>.loadByElement(this)">
                <option value="20"<?php if($this->getCollection()->getPageSize()==20): ?> selected="selected"<?php endif; ?>>20</option>
                <option value="30"<?php if($this->getCollection()->getPageSize()==30): ?> selected="selected"<?php endif; ?>>30</option>
                <option value="50"<?php if($this->getCollection()->getPageSize()==50): ?> selected="selected"<?php endif; ?>>50</option>
                <option value="100"<?php if($this->getCollection()->getPageSize()==100): ?> selected="selected"<?php endif; ?>>100</option>
                <option value="200"<?php if($this->getCollection()->getPageSize()==200): ?> selected="selected"<?php endif; ?>>200</option>
                <option value="500"<?php if($this->getCollection()->getPageSize()==500): ?> selected="selected"<?php endif; ?>>500</option>
                <option value="1000"<?php if($this->getCollection()->getPageSize()==1000): ?> selected="selected"<?php endif; ?>>1000</option>
             </select>

Thứ Ba, 21 tháng 10, 2014

Thêm text phần vào invoice pdf trong magento

Adding a title to Invoice PDF in Magento

Muốn thêm text vào phần header hay footer trong file pdf cua invoice theo hình dưới:



Tạo module tên pdf

app/code/local/Pdf/Sales/Model/Order/Pdf/Abstract.php

<?php

abstract class Pdf_Sales_Model_Order_Pdf_Abstract extends Mage_Sales_Model_Order_Pdf_Abstract
{
    public function insertTitle(Zend_Pdf_Page $page, $text)
    {
        $this->_setFontBold($page, 17);
        $docHeader = $this->getDocHeaderCoordinates();
        $page->drawText($text, 200, $docHeader[1]+13, 'UTF-8');
    }

}

app/code/local/Pdf/Sales/Model/Order/Pdf/Invoice.php

<?php



class Pdf_Sales_Model_Order_Pdf_Invoice extends Pdf_Sales_Model_Order_Pdf_Abstract
{
    /**
     * Draw header for item table
     *
     * @param Zend_Pdf_Page $page
     * @return void
     */
    protected function _drawHeader(Zend_Pdf_Page $page)
    {
        /* Add table head */

        $this->_setFontRegular($page, 11);
        $page->setFillColor(new Zend_Pdf_Color_RGB(0.93, 0.92, 0.92));
        $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
        $page->setLineWidth(0.5);
        $page->drawRectangle(25, $this->y, 570, $this->y -15);
        $this->y -= 10;
        $page->setFillColor(new Zend_Pdf_Color_RGB(0, 0, 0));


        //columns headers
        $lines[0][] = array(
            'text' => Mage::helper('sales')->__('Products'),
            'feed' => 35
        );

        $lines[0][] = array(
            'text'  => Mage::helper('sales')->__('SKU'),
            'feed'  => 290,
            'align' => 'right'
        );

        $lines[0][] = array(
            'text'  => Mage::helper('sales')->__('Qty'),
            'feed'  => 435,
            'align' => 'right'
        );

        $lines[0][] = array(
            'text'  => Mage::helper('sales')->__('Price'),
            'feed'  => 360,
            'align' => 'right'
        );

        $lines[0][] = array(
            'text'  => Mage::helper('sales')->__('Tax'),
            'feed'  => 495,
            'align' => 'right'
        );

        $lines[0][] = array(
            'text'  => Mage::helper('sales')->__('Subtotal'),
            'feed'  => 565,
            'align' => 'right'
        );

        $lineBlock = array(
            'lines'  => $lines,
            'height' => 5
        );

        $this->drawLineBlocks($page, array($lineBlock), array('table_header' => true));
        $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
        $this->y -= 20;
    }

    /**
     * Return PDF document
     *
     * @param  array $invoices
     * @return Zend_Pdf
     */
    public function getPdf($invoices = array())
    {
        $this->_beforeGetPdf();
        $this->_initRenderer('invoice');

        $pdf = new Zend_Pdf();
        $this->_setPdf($pdf);
        $style = new Zend_Pdf_Style();
        $this->_setFontBold($style, 10);

        foreach ($invoices as $invoice) {
            if ($invoice->getStoreId()) {
                Mage::app()->getLocale()->emulate($invoice->getStoreId());
                Mage::app()->setCurrentStore($invoice->getStoreId());
            }
            $page  = $this->newPage();
            $order = $invoice->getOrder();

            /* Add image */
            $this->insertLogo($page, $invoice->getStore());

            /* Add address */
            $this->insertAddress($page, $invoice->getStore());

            $page->setFillColor(new Zend_Pdf_Color_Html('#ffffff'));
            $page->setLineColor(new Zend_Pdf_Color_Html('#ffffff'));
            $page->setLineWidth(0.5);
            $page->drawRectangle(25, $this->y, 570, $this->y-145);
            $this->y -= 35;

            /* Add head */
            $this->insertOrder(
                $page,
                $order,
                Mage::getStoreConfigFlag(self::XML_PATH_SALES_PDF_INVOICE_PUT_ORDER_ID, $order->getStoreId())
            );

            /* Add Title */
            $this->insertTitle($page,Mage::helper('sales')->__('INVOICE TO BUY'));

            /* Add document text and number */
            $this->insertDocumentNumber(
                $page,
                Mage::helper('sales')->__('Invoice # ') . $invoice->getIncrementId()
            );


            /* Add table */

            $this->_drawHeader($page);
            /* Add body */
            foreach ($invoice->getAllItems() as $item){
                if ($item->getOrderItem()->getParentItem()) {
                    continue;
                }
                /* Draw item */
                $this->_drawItem($item, $page, $order);
                $page = end($pdf->pages);
            }
            /* Add totals */
            $this->insertTotals($page, $invoice);
            if ($invoice->getStoreId()) {
                Mage::app()->getLocale()->revert();
            }
        }
        $this->_afterGetPdf();
        return $pdf;
    }

    /**
     * Create new page and assign to PDF object
     *
     * @param  array $settings
     * @return Zend_Pdf_Page
     */
    public function newPage(array $settings = array())
    {
        /* Add new table head */
        $page = $this->_getPdf()->newPage(Zend_Pdf_Page::SIZE_A4);
        $this->_getPdf()->pages[] = $page;
        $this->y = 800;

        if (!empty($settings['table_header'])) {
            $this->_drawHeader($page);
//            $this->_setFontRegular($page);
//            $page->setFillColor(new Zend_Pdf_Color_RGB(0.93, 0.92, 0.92));
//            $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
//            $page->setLineWidth(0.5);
//            $page->drawRectangle(25, $this->y, 570, $this->y-15);
//            $this->y -=10;
//            $page->setFillColor(new Zend_Pdf_Color_RGB(0.4, 0.4, 0.4));
//            $page->drawText(Mage::helper('sales')->__('Product'), 35, $this->y, 'UTF-8');
//            $page->drawText(Mage::helper('sales')->__('SKU'), 255, $this->y, 'UTF-8');
//            $page->drawText(Mage::helper('sales')->__('Price'), 380, $this->y, 'UTF-8');
//            $page->drawText(Mage::helper('sales')->__('QTY'), 430, $this->y, 'UTF-8');
//            $page->drawText(Mage::helper('sales')->__('Tax'), 480, $this->y, 'UTF-8');
//            $page->drawText(Mage::helper('sales')->__('Subtotal'), 535, $this->y, 'UTF-8');
//
//            $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
//            $this->y -=20;
        }
        //This is the textline for the footer next page

        $this->_setFontBold($page, $size = 8);
        $page->drawText(Mage::helper('sales')->__('Thank you buy at sieuthithucpham.com') , 80, 30, 'UTF-8');
        return $page;
    }

}

app/code/local/Pdf/Sales/etc/config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Pdf_Sales>
            <version>1.0</version>
        </Pdf_Sales>
    </modules>
    <!-- following tells magento to override core models-->
    <global>
        <models>
            <sales>
                <rewrite>
                    <order_pdf_abstract>Pdf_Sales_Model_Order_Pdf_Abstract</order_pdf_abstract>
                    <order_pdf_invoice>Pdf_Sales_Model_Order_Pdf_Invoice</order_pdf_invoice>                    <order_pdf_creditmemo>Pdf_Sales_Model_Order_Pdf_Creditmemo</order_pdf_creditmemo>
                </rewrite>
            </sales>
        </models>
    </global>

</config>
app/etc/modules/Pdf_Sales.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Pdf_Sales>
            <active>true</active>
            <codePool>local</codePool>
        </Pdf_Sales>
    </modules>

</config>


Thứ Năm, 16 tháng 10, 2014

Lỗi không print được hóa đơn trong magento


Fatal error: Declaration of Zend_Pdf_FileParserDataSource_File::__construct() must be compatible with Zend_Pdf_FileParserDataSource::__construct() in /var/www/vhosts/website/httpdocs/includes/src/Zend_Pdf_FileParserDataSource_File.php on line 41

Tìm :
 function lib/Zend/Pdf/FileParserDataSource.php.
change
abstract public function __construct();
to

abstract public function __construct($filePath);