refactor: rename CRM to ERP across plugin and package (#192)

Rename plg_system_mokowaas_crm → plg_system_mokowaas_erp to reflect
the MokoWaaS+ERP branding. Updates namespace, class names, table
prefixes, language keys, and package manifest reference.
This commit is contained in:
Jonathan Miller
2026-06-06 12:35:58 -05:00
parent 25dc6ed2cb
commit 1bd6bdba52
12 changed files with 114 additions and 114 deletions
@@ -1,28 +0,0 @@
; MokoWaaS CRM Plugin
; Copyright (C) 2026 Moko Consulting. All rights reserved.
; License: GPL-3.0-or-later
PLG_SYSTEM_MOKOWAAS_CRM="System - MokoWaaS CRM"
PLG_SYSTEM_MOKOWAAS_CRM_DESC="Extends Joomla Contacts with CRM roles (customer, vendor, prospect), deals pipeline, and activity tracking."
PLG_SYSTEM_MOKOWAAS_CRM_FIELDSET_BASIC="Contact Roles"
PLG_SYSTEM_MOKOWAAS_CRM_FIELDSET_BASIC_DESC="Configure how Joomla Contact categories map to CRM roles."
PLG_SYSTEM_MOKOWAAS_CRM_AUTO_ROLE_LABEL="Auto-assign Role from Category"
PLG_SYSTEM_MOKOWAAS_CRM_AUTO_ROLE_DESC="Automatically create a CRM role when a contact is saved in a mapped category."
PLG_SYSTEM_MOKOWAAS_CRM_CUSTOMER_CAT_LABEL="Customer Category"
PLG_SYSTEM_MOKOWAAS_CRM_CUSTOMER_CAT_DESC="Joomla Contact category name that maps to the Customer role."
PLG_SYSTEM_MOKOWAAS_CRM_VENDOR_CAT_LABEL="Vendor Category"
PLG_SYSTEM_MOKOWAAS_CRM_VENDOR_CAT_DESC="Joomla Contact category name that maps to the Vendor role."
PLG_SYSTEM_MOKOWAAS_CRM_PROSPECT_CAT_LABEL="Prospect Category"
PLG_SYSTEM_MOKOWAAS_CRM_PROSPECT_CAT_DESC="Joomla Contact category name that maps to the Prospect role."
PLG_SYSTEM_MOKOWAAS_CRM_CUST_PREFIX_LABEL="Customer Code Prefix"
PLG_SYSTEM_MOKOWAAS_CRM_CUST_PREFIX_DESC="Prefix for auto-generated customer codes (e.g. CU → CU2026-001)."
PLG_SYSTEM_MOKOWAAS_CRM_VEND_PREFIX_LABEL="Vendor Code Prefix"
PLG_SYSTEM_MOKOWAAS_CRM_VEND_PREFIX_DESC="Prefix for auto-generated vendor codes (e.g. VN → VN2026-001)."
PLG_SYSTEM_MOKOWAAS_CRM_FIELDSET_PIPELINE="Pipeline & Defaults"
PLG_SYSTEM_MOKOWAAS_CRM_FIELDSET_PIPELINE_DESC="Default settings for deals and payment terms."
PLG_SYSTEM_MOKOWAAS_CRM_CURRENCY_LABEL="Default Currency"
PLG_SYSTEM_MOKOWAAS_CRM_CURRENCY_DESC="ISO 4217 currency code for new deals (e.g. USD, EUR, GBP)."
PLG_SYSTEM_MOKOWAAS_CRM_PAYMENT_TERMS_LABEL="Default Payment Terms (days)"
PLG_SYSTEM_MOKOWAAS_CRM_PAYMENT_TERMS_DESC="Default payment terms in days for new customer/vendor roles."
@@ -1,3 +0,0 @@
; MokoWaaS CRM Plugin - System strings
PLG_SYSTEM_MOKOWAAS_CRM="System - MokoWaaS CRM"
PLG_SYSTEM_MOKOWAAS_CRM_DESC="Extends Joomla Contacts with CRM roles (customer, vendor, prospect), deals pipeline, and activity tracking."
@@ -1,4 +0,0 @@
DROP TABLE IF EXISTS `#__mokowaas_crm_activities`;
DROP TABLE IF EXISTS `#__mokowaas_crm_deals`;
DROP TABLE IF EXISTS `#__mokowaas_crm_pipeline_stages`;
DROP TABLE IF EXISTS `#__mokowaas_crm_roles`;
@@ -0,0 +1,28 @@
; MokoWaaS ERP Plugin
; Copyright (C) 2026 Moko Consulting. All rights reserved.
; License: GPL-3.0-or-later
PLG_SYSTEM_MOKOWAAS_ERP="System - MokoWaaS ERP"
PLG_SYSTEM_MOKOWAAS_ERP_DESC="Extends Joomla Contacts with ERP roles (customer, vendor, prospect), deals pipeline, and activity tracking."
PLG_SYSTEM_MOKOWAAS_ERP_FIELDSET_BASIC="Contact Roles"
PLG_SYSTEM_MOKOWAAS_ERP_FIELDSET_BASIC_DESC="Configure how Joomla Contact categories map to ERP roles."
PLG_SYSTEM_MOKOWAAS_ERP_AUTO_ROLE_LABEL="Auto-assign Role from Category"
PLG_SYSTEM_MOKOWAAS_ERP_AUTO_ROLE_DESC="Automatically create a ERP role when a contact is saved in a mapped category."
PLG_SYSTEM_MOKOWAAS_ERP_CUSTOMER_CAT_LABEL="Customer Category"
PLG_SYSTEM_MOKOWAAS_ERP_CUSTOMER_CAT_DESC="Joomla Contact category name that maps to the Customer role."
PLG_SYSTEM_MOKOWAAS_ERP_VENDOR_CAT_LABEL="Vendor Category"
PLG_SYSTEM_MOKOWAAS_ERP_VENDOR_CAT_DESC="Joomla Contact category name that maps to the Vendor role."
PLG_SYSTEM_MOKOWAAS_ERP_PROSPECT_CAT_LABEL="Prospect Category"
PLG_SYSTEM_MOKOWAAS_ERP_PROSPECT_CAT_DESC="Joomla Contact category name that maps to the Prospect role."
PLG_SYSTEM_MOKOWAAS_ERP_CUST_PREFIX_LABEL="Customer Code Prefix"
PLG_SYSTEM_MOKOWAAS_ERP_CUST_PREFIX_DESC="Prefix for auto-generated customer codes (e.g. CU → CU2026-001)."
PLG_SYSTEM_MOKOWAAS_ERP_VEND_PREFIX_LABEL="Vendor Code Prefix"
PLG_SYSTEM_MOKOWAAS_ERP_VEND_PREFIX_DESC="Prefix for auto-generated vendor codes (e.g. VN → VN2026-001)."
PLG_SYSTEM_MOKOWAAS_ERP_FIELDSET_PIPELINE="Pipeline & Defaults"
PLG_SYSTEM_MOKOWAAS_ERP_FIELDSET_PIPELINE_DESC="Default settings for deals and payment terms."
PLG_SYSTEM_MOKOWAAS_ERP_CURRENCY_LABEL="Default Currency"
PLG_SYSTEM_MOKOWAAS_ERP_CURRENCY_DESC="ISO 4217 currency code for new deals (e.g. USD, EUR, GBP)."
PLG_SYSTEM_MOKOWAAS_ERP_PAYMENT_TERMS_LABEL="Default Payment Terms (days)"
PLG_SYSTEM_MOKOWAAS_ERP_PAYMENT_TERMS_DESC="Default payment terms in days for new customer/vendor roles."
@@ -0,0 +1,3 @@
; MokoWaaS ERP Plugin - System strings
PLG_SYSTEM_MOKOWAAS_ERP="System - MokoWaaS ERP"
PLG_SYSTEM_MOKOWAAS_ERP_DESC="Extends Joomla Contacts with ERP roles (customer, vendor, prospect), deals pipeline, and activity tracking."
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" group="system" method="upgrade">
<name>System - MokoWaaS CRM</name>
<element>mokowaas_crm</element>
<name>System - MokoWaaS ERP</name>
<element>mokowaas_erp</element>
<author>Moko Consulting</author>
<creationDate>2026-06-06</creationDate>
<copyright>Copyright (C) 2026 Moko Consulting. All rights reserved.</copyright>
@@ -9,8 +9,8 @@
<authorEmail>hello@mokoconsulting.tech</authorEmail>
<authorUrl>https://mokoconsulting.tech</authorUrl>
<version>02.34.16</version>
<description>PLG_SYSTEM_MOKOWAAS_CRM_DESC</description>
<namespace path="src">Moko\Plugin\System\MokoWaaSCrm</namespace>
<description>PLG_SYSTEM_MOKOWAAS_ERP_DESC</description>
<namespace path="src">Moko\Plugin\System\MokoWaaSErp</namespace>
<files>
<folder>src</folder>
@@ -20,8 +20,8 @@
</files>
<languages folder="language">
<language tag="en-GB">en-GB/plg_system_mokowaas_crm.ini</language>
<language tag="en-GB">en-GB/plg_system_mokowaas_crm.sys.ini</language>
<language tag="en-GB">en-GB/plg_system_mokowaas_erp.ini</language>
<language tag="en-GB">en-GB/plg_system_mokowaas_erp.sys.ini</language>
</languages>
<install>
@@ -39,52 +39,52 @@
<config>
<fields name="params">
<fieldset name="basic"
label="PLG_SYSTEM_MOKOWAAS_CRM_FIELDSET_BASIC"
description="PLG_SYSTEM_MOKOWAAS_CRM_FIELDSET_BASIC_DESC">
label="PLG_SYSTEM_MOKOWAAS_ERP_FIELDSET_BASIC"
description="PLG_SYSTEM_MOKOWAAS_ERP_FIELDSET_BASIC_DESC">
<field name="auto_role_from_category" type="radio" default="1"
label="PLG_SYSTEM_MOKOWAAS_CRM_AUTO_ROLE_LABEL"
description="PLG_SYSTEM_MOKOWAAS_CRM_AUTO_ROLE_DESC"
label="PLG_SYSTEM_MOKOWAAS_ERP_AUTO_ROLE_LABEL"
description="PLG_SYSTEM_MOKOWAAS_ERP_AUTO_ROLE_DESC"
class="btn-group btn-group-yesno">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="customer_category" type="text" default="Customers"
label="PLG_SYSTEM_MOKOWAAS_CRM_CUSTOMER_CAT_LABEL"
description="PLG_SYSTEM_MOKOWAAS_CRM_CUSTOMER_CAT_DESC"
label="PLG_SYSTEM_MOKOWAAS_ERP_CUSTOMER_CAT_LABEL"
description="PLG_SYSTEM_MOKOWAAS_ERP_CUSTOMER_CAT_DESC"
showon="auto_role_from_category:1" />
<field name="vendor_category" type="text" default="Vendors"
label="PLG_SYSTEM_MOKOWAAS_CRM_VENDOR_CAT_LABEL"
description="PLG_SYSTEM_MOKOWAAS_CRM_VENDOR_CAT_DESC"
label="PLG_SYSTEM_MOKOWAAS_ERP_VENDOR_CAT_LABEL"
description="PLG_SYSTEM_MOKOWAAS_ERP_VENDOR_CAT_DESC"
showon="auto_role_from_category:1" />
<field name="prospect_category" type="text" default="Prospects"
label="PLG_SYSTEM_MOKOWAAS_CRM_PROSPECT_CAT_LABEL"
description="PLG_SYSTEM_MOKOWAAS_CRM_PROSPECT_CAT_DESC"
label="PLG_SYSTEM_MOKOWAAS_ERP_PROSPECT_CAT_LABEL"
description="PLG_SYSTEM_MOKOWAAS_ERP_PROSPECT_CAT_DESC"
showon="auto_role_from_category:1" />
<field name="customer_code_prefix" type="text" default="CU"
label="PLG_SYSTEM_MOKOWAAS_CRM_CUST_PREFIX_LABEL"
description="PLG_SYSTEM_MOKOWAAS_CRM_CUST_PREFIX_DESC" />
label="PLG_SYSTEM_MOKOWAAS_ERP_CUST_PREFIX_LABEL"
description="PLG_SYSTEM_MOKOWAAS_ERP_CUST_PREFIX_DESC" />
<field name="vendor_code_prefix" type="text" default="VN"
label="PLG_SYSTEM_MOKOWAAS_CRM_VEND_PREFIX_LABEL"
description="PLG_SYSTEM_MOKOWAAS_CRM_VEND_PREFIX_DESC" />
label="PLG_SYSTEM_MOKOWAAS_ERP_VEND_PREFIX_LABEL"
description="PLG_SYSTEM_MOKOWAAS_ERP_VEND_PREFIX_DESC" />
</fieldset>
<fieldset name="pipeline"
label="PLG_SYSTEM_MOKOWAAS_CRM_FIELDSET_PIPELINE"
description="PLG_SYSTEM_MOKOWAAS_CRM_FIELDSET_PIPELINE_DESC">
label="PLG_SYSTEM_MOKOWAAS_ERP_FIELDSET_PIPELINE"
description="PLG_SYSTEM_MOKOWAAS_ERP_FIELDSET_PIPELINE_DESC">
<field name="default_currency" type="text" default="USD"
label="PLG_SYSTEM_MOKOWAAS_CRM_CURRENCY_LABEL"
description="PLG_SYSTEM_MOKOWAAS_CRM_CURRENCY_DESC" />
label="PLG_SYSTEM_MOKOWAAS_ERP_CURRENCY_LABEL"
description="PLG_SYSTEM_MOKOWAAS_ERP_CURRENCY_DESC" />
<field name="default_payment_terms" type="number" default="30"
label="PLG_SYSTEM_MOKOWAAS_CRM_PAYMENT_TERMS_LABEL"
description="PLG_SYSTEM_MOKOWAAS_CRM_PAYMENT_TERMS_DESC" />
label="PLG_SYSTEM_MOKOWAAS_ERP_PAYMENT_TERMS_LABEL"
description="PLG_SYSTEM_MOKOWAAS_ERP_PAYMENT_TERMS_DESC" />
</fieldset>
</fields>
</config>
@@ -1,7 +1,7 @@
<?php
/**
* @package MokoWaaS
* @subpackage plg_system_mokowaas_crm
* @subpackage plg_system_mokowaas_erp
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
* @license GNU General Public License version 3 or later; see LICENSE
*/
@@ -14,7 +14,7 @@ use Joomla\CMS\Plugin\PluginHelper;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Moko\Plugin\System\MokoWaaSCrm\Extension\Crm;
use Moko\Plugin\System\MokoWaaSErp\Extension\Crm;
return new class implements ServiceProviderInterface
{
@@ -24,7 +24,7 @@ return new class implements ServiceProviderInterface
PluginInterface::class,
function (Container $container) {
$dispatcher = $container->get(DispatcherInterface::class);
$plugin = new Crm($dispatcher, (array) PluginHelper::getPlugin('system', 'mokowaas_crm'));
$plugin = new Erp($dispatcher, (array) PluginHelper::getPlugin('system', 'mokowaas_erp'));
$plugin->setApplication(Factory::getApplication());
return $plugin;
@@ -1,12 +1,12 @@
--
-- MokoWaaS CRM Tables
-- MokoWaaS ERP Tables
--
--
-- Contact CRM roles (customer, vendor, prospect)
-- Contact ERP roles (customer, vendor, prospect)
-- Links to Joomla #__contact_details via contact_id
--
CREATE TABLE IF NOT EXISTS `#__mokowaas_crm_roles` (
CREATE TABLE IF NOT EXISTS `#__mokowaas_erp_roles` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`contact_id` INT NOT NULL,
`role` ENUM('customer','vendor','prospect') NOT NULL,
@@ -28,7 +28,7 @@ CREATE TABLE IF NOT EXISTS `#__mokowaas_crm_roles` (
--
-- Configurable deal pipeline stages
--
CREATE TABLE IF NOT EXISTS `#__mokowaas_crm_pipeline_stages` (
CREATE TABLE IF NOT EXISTS `#__mokowaas_erp_pipeline_stages` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`title` VARCHAR(255) NOT NULL,
`alias` VARCHAR(255) NOT NULL DEFAULT '',
@@ -42,7 +42,7 @@ CREATE TABLE IF NOT EXISTS `#__mokowaas_crm_pipeline_stages` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Default pipeline stages
INSERT IGNORE INTO `#__mokowaas_crm_pipeline_stages`
INSERT IGNORE INTO `#__mokowaas_erp_pipeline_stages`
(`id`, `title`, `alias`, `probability`, `ordering`, `color`, `published`) VALUES
(1, 'Lead', 'lead', 10, 1, '#6c757d', 1),
(2, 'Qualified', 'qualified', 25, 2, '#0d6efd', 1),
@@ -54,7 +54,7 @@ INSERT IGNORE INTO `#__mokowaas_crm_pipeline_stages`
--
-- Sales pipeline deals
--
CREATE TABLE IF NOT EXISTS `#__mokowaas_crm_deals` (
CREATE TABLE IF NOT EXISTS `#__mokowaas_erp_deals` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`title` VARCHAR(255) NOT NULL,
`contact_id` INT NOT NULL,
@@ -83,7 +83,7 @@ CREATE TABLE IF NOT EXISTS `#__mokowaas_crm_deals` (
--
-- Activity log per contact/deal
--
CREATE TABLE IF NOT EXISTS `#__mokowaas_crm_activities` (
CREATE TABLE IF NOT EXISTS `#__mokowaas_erp_activities` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`contact_id` INT NOT NULL,
`deal_id` INT UNSIGNED DEFAULT NULL,
@@ -0,0 +1,4 @@
DROP TABLE IF EXISTS `#__mokowaas_erp_activities`;
DROP TABLE IF EXISTS `#__mokowaas_erp_deals`;
DROP TABLE IF EXISTS `#__mokowaas_erp_pipeline_stages`;
DROP TABLE IF EXISTS `#__mokowaas_erp_roles`;
@@ -1,12 +1,12 @@
<?php
/**
* @package MokoWaaS
* @subpackage plg_system_mokowaas_crm
* @subpackage plg_system_mokowaas_erp
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
* @license GNU General Public License version 3 or later; see LICENSE
*/
namespace Moko\Plugin\System\MokoWaaSCrm\Extension;
namespace Moko\Plugin\System\MokoWaaSErp\Extension;
defined('_JEXEC') or die;
@@ -14,22 +14,22 @@ use Joomla\CMS\Factory;
use Joomla\CMS\Log\Log;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\Event\SubscriberInterface;
use Moko\Plugin\System\MokoWaaSCrm\Helper\CrmHelper;
use Moko\Plugin\System\MokoWaaSErp\Helper\ErpHelper;
/**
* MokoWaaS CRM Plugin
* MokoWaaS ERP Plugin
*
* Extends Joomla Contacts with CRM roles (customer, vendor, prospect),
* Extends Joomla Contacts with ERP roles (customer, vendor, prospect),
* auto-generates role codes, and cascades cleanup on contact deletion.
*
* @since 02.34.16
*/
class Crm extends CMSPlugin implements SubscriberInterface
class Erp extends CMSPlugin implements SubscriberInterface
{
protected $autoloadLanguage = true;
/**
* Map of category title (lowercase) CRM role.
* Map of category title (lowercase) ERP role.
* Built from plugin params on first use.
*
* @var array|null
@@ -45,7 +45,7 @@ class Crm extends CMSPlugin implements SubscriberInterface
}
/**
* After a contact is saved, auto-create a CRM role based on its category.
* After a contact is saved, auto-create a ERP role based on its category.
*/
public function onContentAfterSave($event): void
{
@@ -80,7 +80,7 @@ class Crm extends CMSPlugin implements SubscriberInterface
return;
}
$categoryTitle = CrmHelper::getContactCategoryTitle($contactId);
$categoryTitle = ErpHelper::getContactCategoryTitle($contactId);
if (!$categoryTitle)
{
@@ -94,7 +94,7 @@ class Crm extends CMSPlugin implements SubscriberInterface
return;
}
if (CrmHelper::roleExists($contactId, $role))
if (ErpHelper::roleExists($contactId, $role))
{
return;
}
@@ -103,7 +103,7 @@ class Crm extends CMSPlugin implements SubscriberInterface
}
/**
* Before a contact is deleted, remove all linked CRM data.
* Before a contact is deleted, remove all linked ERP data.
*/
public function onContentBeforeDelete($event): void
{
@@ -134,11 +134,11 @@ class Crm extends CMSPlugin implements SubscriberInterface
}
/**
* Determine the CRM role for a given category title.
* Determine the ERP role for a given category title.
*
* @param string $categoryTitle The Joomla category title.
*
* @return string|null The CRM role or null if no match.
* @return string|null The ERP role or null if no match.
*/
private function mapCategoryToRole(string $categoryTitle): ?string
{
@@ -167,10 +167,10 @@ class Crm extends CMSPlugin implements SubscriberInterface
}
/**
* Create a CRM role record for a contact.
* Create a ERP role record for a contact.
*
* @param int $contactId The Joomla contact ID.
* @param string $role The CRM role (customer, vendor, prospect).
* @param string $role The ERP role (customer, vendor, prospect).
*/
private function createRole(int $contactId, string $role): void
{
@@ -184,7 +184,7 @@ class Crm extends CMSPlugin implements SubscriberInterface
try
{
$code = CrmHelper::generateCode($role, $prefix);
$code = ErpHelper::generateCode($role, $prefix);
$now = Factory::getDate()->toSql();
$user = Factory::getUser();
@@ -199,22 +199,22 @@ class Crm extends CMSPlugin implements SubscriberInterface
'created_by' => (int) $user->id,
];
$db->insertObject('#__mokowaas_crm_roles', $obj);
$db->insertObject('#__mokowaas_erp_roles', $obj);
Log::add(
sprintf('CRM role created: %s (%s) for contact %d', $role, $code, $contactId),
sprintf('ERP role created: %s (%s) for contact %d', $role, $code, $contactId),
Log::INFO,
'mokowaas.crm'
'mokowaas.erp'
);
}
catch (\Throwable $e)
{
Log::add('CRM role creation failed: ' . $e->getMessage(), Log::ERROR, 'mokowaas.crm');
Log::add('ERP role creation failed: ' . $e->getMessage(), Log::ERROR, 'mokowaas.erp');
}
}
/**
* Remove all CRM data linked to a contact being deleted.
* Remove all ERP data linked to a contact being deleted.
*
* @param int $contactId The contact ID being deleted.
*/
@@ -223,9 +223,9 @@ class Crm extends CMSPlugin implements SubscriberInterface
$db = Factory::getDbo();
$tables = [
'#__mokowaas_crm_activities',
'#__mokowaas_crm_deals',
'#__mokowaas_crm_roles',
'#__mokowaas_erp_activities',
'#__mokowaas_erp_deals',
'#__mokowaas_erp_roles',
];
foreach ($tables as $table)
@@ -242,17 +242,17 @@ class Crm extends CMSPlugin implements SubscriberInterface
catch (\Throwable $e)
{
Log::add(
sprintf('CRM cascade delete failed on %s for contact %d: %s', $table, $contactId, $e->getMessage()),
sprintf('ERP cascade delete failed on %s for contact %d: %s', $table, $contactId, $e->getMessage()),
Log::ERROR,
'mokowaas.crm'
'mokowaas.erp'
);
}
}
Log::add(
sprintf('CRM data cascade-deleted for contact %d', $contactId),
sprintf('ERP data cascade-deleted for contact %d', $contactId),
Log::INFO,
'mokowaas.crm'
'mokowaas.erp'
);
}
}
@@ -1,30 +1,30 @@
<?php
/**
* @package MokoWaaS
* @subpackage plg_system_mokowaas_crm
* @subpackage plg_system_mokowaas_erp
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
* @license GNU General Public License version 3 or later; see LICENSE
*/
namespace Moko\Plugin\System\MokoWaaSCrm\Helper;
namespace Moko\Plugin\System\MokoWaaSErp\Helper;
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
/**
* CRM Helper code generation, category lookups, and CRM statistics.
* ERP Helper code generation, category lookups, and ERP statistics.
*
* @since 02.34.16
*/
class CrmHelper
class ErpHelper
{
/**
* Generate the next sequential customer or vendor code.
*
* Format: {PREFIX}{YEAR}-{SEQ} e.g. CU2026-001, VN2026-014
*
* @param string $role The CRM role (customer, vendor, prospect).
* @param string $role The ERP role (customer, vendor, prospect).
* @param string $prefix Code prefix (e.g. "CU", "VN").
*
* @return string The generated code.
@@ -38,7 +38,7 @@ class CrmHelper
$db->setQuery(
$db->getQuery(true)
->select('MAX(' . $db->quoteName('code') . ')')
->from($db->quoteName('#__mokowaas_crm_roles'))
->from($db->quoteName('#__mokowaas_erp_roles'))
->where($db->quoteName('role') . ' = ' . $db->quote($role))
->where($db->quoteName('code') . ' LIKE ' . $like)
);
@@ -85,10 +85,10 @@ class CrmHelper
}
/**
* Check whether a CRM role already exists for a contact.
* Check whether a ERP role already exists for a contact.
*
* @param int $contactId The contact ID.
* @param string $role The CRM role.
* @param string $role The ERP role.
*
* @return bool
*/
@@ -99,7 +99,7 @@ class CrmHelper
$db->setQuery(
$db->getQuery(true)
->select('COUNT(*)')
->from($db->quoteName('#__mokowaas_crm_roles'))
->from($db->quoteName('#__mokowaas_erp_roles'))
->where($db->quoteName('contact_id') . ' = ' . (int) $contactId)
->where($db->quoteName('role') . ' = ' . $db->quote($role))
);
@@ -108,9 +108,9 @@ class CrmHelper
}
/**
* Get CRM statistics for health/heartbeat reporting.
* Get ERP statistics for health/heartbeat reporting.
*
* @return array Associative array of CRM metrics.
* @return array Associative array of ERP metrics.
*/
public static function getStats(): array
{
@@ -134,7 +134,7 @@ class CrmHelper
$db->getQuery(true)
->select($db->quoteName('role'))
->select('COUNT(*) AS ' . $db->quoteName('cnt'))
->from($db->quoteName('#__mokowaas_crm_roles'))
->from($db->quoteName('#__mokowaas_erp_roles'))
->where($db->quoteName('status') . ' = ' . $db->quote('active'))
->group($db->quoteName('role'))
);
@@ -156,7 +156,7 @@ class CrmHelper
$db->getQuery(true)
->select('COUNT(*) AS ' . $db->quoteName('cnt'))
->select('COALESCE(SUM(' . $db->quoteName('value') . '), 0) AS ' . $db->quoteName('total'))
->from($db->quoteName('#__mokowaas_crm_deals'))
->from($db->quoteName('#__mokowaas_erp_deals'))
->where($db->quoteName('status') . ' = ' . $db->quote('open'))
);
@@ -169,7 +169,7 @@ class CrmHelper
$db->getQuery(true)
->select($db->quoteName('status'))
->select('COUNT(*) AS ' . $db->quoteName('cnt'))
->from($db->quoteName('#__mokowaas_crm_deals'))
->from($db->quoteName('#__mokowaas_erp_deals'))
->where($db->quoteName('status') . ' IN (' . $db->quote('won') . ',' . $db->quote('lost') . ')')
->group($db->quoteName('status'))
);
+1 -1
View File
@@ -20,7 +20,7 @@
<file type="plugin" id="plg_system_mokowaas_tenant" group="system">plg_system_mokowaas_tenant.zip</file>
<file type="plugin" id="plg_system_mokowaas_devtools" group="system">plg_system_mokowaas_devtools.zip</file>
<file type="plugin" id="plg_system_mokowaas_offline" group="system">plg_system_mokowaas_offline.zip</file>
<file type="plugin" id="plg_system_mokowaas_crm" group="system">plg_system_mokowaas_crm.zip</file>
<file type="plugin" id="plg_system_mokowaas_erp" group="system">plg_system_mokowaas_erp.zip</file>
<file type="component" id="com_mokowaas">com_mokowaas.zip</file>
<file type="module" id="mod_mokowaas_cpanel" client="administrator">mod_mokowaas_cpanel.zip</file>
<file type="module" id="mod_mokowaas_menu" client="administrator">mod_mokowaas_menu.zip</file>