Skip to content

Creating Custom Print Formats in PHP for Merciglobal Cloud ERP

Developers working with Merciglobal Cloud ERP can leverage PHP to create customized print formats. These formats enable the printing and emailing of documents such as invoices, order forms, delivery challans, and moreβ€”with branding and detailed formatting.


🧾 Naming Convention

  • Use the following naming pattern for your PHP file:
Invoice_Printing_{tablename}.php
  • {tablename} is dynamically replaced at runtime with the relevant table name.
  • Files must be placed in the /system/ folder.

βš™οΈ Core Workflow

Here’s a breakdown of how a PHP-based print format works:

1. Initialization

  • Start a PHP session.
  • Include essential functions:
require "funcs.php";
  • Set working directory:
chdir('..');
  • Initialize PDF generator:
merciPDF();

2. Fetch Data

  • Retrieve runtime parameters like mode (PRINT/EMAIL) and id.
  • Query the database for company and transaction data.
  • Format address, contact, and other transaction-specific details.

3. PDF Generation

  • Set up PDF styles: font, font size, boldness, colors, etc.
  • Add structured elements:
  • Company name, address, and logo
  • Customer information
  • Product/service details
  • Terms and conditions

4. Final Actions

  • If mode = PRINT, invoke:
$pdf->end();

and mark the record as printed. - If mode = EMAIL, generate the PDF and send via:

doDocEmail();

πŸ› οΈ Key PDF Methods

Method Purpose
say(x, y, text) Prints text at position (x, y)
sayImage(url, x, y, width, height) Inserts an image
box(x, y, height, width) Draws a rectangular box
skip(n) Skips n lines vertically
line(row, x, height, width) Draws a horizontal line
saveas(filepath) Saves the PDF file to the server
end() Finalizes and outputs the PDF

βœ… Use Cases

PHP-based print formats are ideal for:

  • Customer Invoices
  • Software Order Forms
  • Delivery Challans
  • Quotation Approvals

πŸ“§ Email Functionality

Use the doDocEmail() function to email the generated document. It auto-generates a subject line like Order Confirmation... and sends the PDF attachment to validated recipient addresses.


πŸ’» Sample Code

Below is a basic scaffold of the PHP code used for generating print formats from a table like trn_orderform. All comments are included to assist developers with understanding and further customization:

// Your PHP implementation goes here

For more advanced customization and automation in Merciglobal Cloud ERP, consult the development team or visit the Merciglobal ERP Documentation.

Keep your documents elegant, professional, and seamlessly automated with PHP-powered print formats.