Skip to content

Communication

Email, SMS, push notifications and alerts.

7 functions. All require apis/main_webservices.php to be included.


On this page: alert ยท centralPushMessage ยท centralSms ยท printed ยท sendXDlgEmail ยท simple_mail ยท support_mail


alert()

Prototype

alert( $cMsg )

Description

  • Emits a JavaScript alert on the client screen with the given message.
  • Use for immediate, blocking user notices during a request.

Parameters

  • <$cMsg>: string: Message to be displayed on browser screen

Returns

  • Nothing โ€” outputs the alert script.

Return example

alert('Record saved successfully');
// browser shows alert()

Usage example

Alert('Entry Saved');

:material-file-code: Source: apis/core2_a.php


centralPushMessage()

Prototype

CentralPushMessage( $mob='', $msg='', $cFromTbl='', $nModID=0, $log=true )

Description

  • Sends a push notification to the mobile app (default app: MERCI CRM), optionally linked and logged.
  • Use for in-app alerts to users/customers.

Parameters

  • $mob โ€” Mobile no. to which to push the message
  • $msg โ€” Message to be sent in SMS
  • [$cFromTbl]: Table Name for identifying for which entry the email was sent
  • [$nModID]: Entry ID of table
  • [$log]: Create a User Log for the sms sent. This is tracable by the user in the Utility Option: SMS LOG

Returns

  • Boolean โ€” true on successful push, false otherwise.

Return example

$ok = CentralPushMessage('9825012345', 'New task assigned');
// returns: true | false

Usage example

CentralPushMessage( '9898098980', 'Hello. Have a great day' );

:material-file-code: Source: apis/core2_a.php


centralSms()

Prototype

CentralSms( $mob='', $msg='', $cFromTbl='', $nModID=0, $log=true, $sms_userid=0 )

Description

  • Queues an SMS for delivery via the central gateway, optionally linked to a source table/module and logged.
  • Use for transactional alerts (OTPs, dispatch, payment reminders).

Parameters

  • $mob โ€” Mobile no. to which to send the sms
  • $msg โ€” Message to be sent in SMS
  • [$cFromTbl]: Table Name for identifying for which entry the email was sent
  • [$nModID]: Entry ID of table
  • [$log]: Create a User Log for the sms sent. This is tracable by the user in the Utility Option: SMS LOG
  • [$sms_userid]: MERCI ID for the user. Defaults to Current Project/ Merci ID

Returns

  • Nothing โ€” submits the SMS to the delivery queue.

Return example

CentralSms('9825012345', 'Your order #1024 is dispatched');
// queued

Usage example

CentralSms( '9898098980', 'Hello. Have a great day' );
///Will send the sms from the current's user's account. Please note that the sms credits/balance should have been purchased by the user.

:material-file-code: Source: apis/core2_a.php


printed()

Prototype

printed( $cFromTbl, $nModID, $printname='-' )

Description

  • Records in the print log that an entry has been printed.
  • Use to track print counts and prevent/flag re-prints.

Parameters

  • <$cFromTbl>: Table Name
  • <$nModID>: Table ID
  • [$printname]: Print file name

Returns

  • Nothing โ€” writes a print-log entry as a side effect.

Return example

printed('trn_salesorder', 1024, 'Tax Invoice');
// logged

Usage example

printed('trn_sales', $nTableID);

:material-file-code: Source: apis/core2_a.php


sendXDlgEmail()

Prototype

SendXDlgEmail( $table, $id, $mode='ADD' )

Description

  • Automatically sends an email to the recipient configured in the utility email setup for a table/record event.
  • Use to fire the project's pre-configured document emails (add/modify).

Parameters

  • $table โ€” Table Name
  • $id โ€” Table record id
  • [$mode] : Event type ADD / EDIT

Returns

  • Nothing โ€” sends the configured email as a side effect.

Return example

SendXDlgEmail('trn_salesorder', 1024, 'ADD');
// configured email sent

:material-file-code: Source: apis/core.php


simple_mail()

Prototype

simple_mail( $to, $subject='Message', $msg='', $fattach='', $from=array('no-reply@merciglobal.com'), $fromcompany='Merciglobal', $bcc=array(), $readRecLink='', $cc='', $emailserver=[])

Description

  • Sends a straightforward email โ€” to, subject, body, optional attachment, from identity, cc/bcc and read-receipt link.
  • Use for general-purpose outbound mail without module linkage.

Parameters

  • <$to>: String containing email address. Multiple addresses may be specified separated by SPACE or COMMA
  • <$subject>: Subject Line
  • <$msg>: Message of email. Can be Html
  • [$fattach]: Array list of file names to be attached in email
  • [$fromemail]: Array list as from email
  • [$fromcompany]: Company Name to be displayed as FROM name in email
  • [$bcc]: Array list of emaila addresses to send BCC
  • [$readRecLink]: Image file name for Mail Read Tracking. Leave Blank.
  • [$cc]: String | Array list of emaila addresses to send CC
  • [$emailserver]: Associative array for Email Server Info {'server' => 'servername', 'user' => 'username', 'pwd' => 'password'}

Returns

  • Sends the email (truthy on success); dispatch is the primary effect.

Return example

simple_mail('buyer@acme.com', 'Invoice', $html, $pdfPath);
// email sent

Usage example

simple_mail( 'no-reply@merciglobal.com', $subject='Test Message', $msg='Hello.<br>How are you?' )

:material-file-code: Source: apis/core2_a.php


support_mail()

Prototype

support_mail( $to, $subject='Message', $msg='', $cFromTbl='', $nModID=0, $fattach='', $fromemail='', $fromcompany='', $log=true, $admin=true )

Description

  • Sends a support/system email with rich options โ€” source table/module linkage, attachment, custom from-identity and logging.
  • Use for module-originated notifications that should also be logged/attributed.

Parameters

  • $to โ€” String containing email address. Multiple addresses may be specified separated by SPACE or COMMA
  • $subject โ€” Subject Line
  • $msg โ€” Message of email. Can be Html
  • $cFromTbl โ€” From table to be linked (if any)
  • $nModID โ€” Table id (if any)
  • $fattach โ€” String | Array list of file names to be attached in email
  • $fromemail โ€” Pass a blank string
  • $fromcompany โ€” Company Name to be displayed as FROM name in email
  • $log โ€” True / False to log email sent info
  • $admin โ€” True / False to send email to admin as BCC

Returns

  • The composed message that was sent (and the mail is dispatched as a side effect).

Return example

support_mail('it@company.com', 'Order Posted', $html, 'trn_salesorder', 1024);
// email queued/sent

Usage example

support_mail( 'no-reply@merciglobal.com', $subject='Test Message', $msg='Hello.<br>How are you?' )

:material-file-code: Source: apis/core2_a.php