Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Bill Approve Event

The Bill Approve Event can be triggered using Custom Logic. The following parameters are Required to execute the Event.

Bill Approve
/**
* Event: Approve Bill 
* Listener Class: Application_Model_Bill_Bill
* Listener Method: eventApprove
*/  

PCR_Event::attachDb(
    "approve-bill",
    ["Application_Model_Bill_Bill" => "eventApprove"]
);
PCR_Event::trigger(
    "approve-bill",
	[
	    "BILLS_RECID" => "443",	//RecID of Bill being approved
	    "INVOICE_DATE" => "09\/30\/2022",

	    "eventBroadcastBy" => "216121",
	    "eventBroadcastTime" => "Sep 30, 2022, 10:26 am",
	    "eventBroadcastDayofWeek" => "5",
	    "eventBroadcastHourMin" => "1026",
	]	
);

Bill Coordinator E-mail

The Bill Coordinator E-mail Event can be triggered using Custom Logic. The following parameters are Required to execute the Event.

Bill Coordinator E-mail
/**
* Event: Bill coordinator email
* Listener Class: Application_Model_Bill_Bill
* Listener Method: eventGenerateEmail
*/

PCR_Event::attachDb(
    "generate-email",
    ["Application_Model_Bill_Bill" => "eventGenerateEmail"]
);
PCR_Event::trigger(
    "generate-email", 
 	[
		"billRecid" => "443", 						//RecID of Bill E-mail is about
		"role" => "5", 								//RecID of Coordinator Role
		"subject" => "Billing Transactions for August 1, 2022 - August 31, 2022", //Subject of E-mail
		"emailBody" => "Billing E-mail Test", 		//Body of E-mail
		"RECID" => "443",							//RecID of Bill E-mail is about
		"reportOptions" => [],
		"contact" => "216121", 						//RecID of Contact that initiated the E-mail process 

		"eventBroadcastBy" => "216121",
		"eventBroadcastTime" => "Sep 30, 2022, 10:31 am",
		"eventBroadcastDayofWeek" => "5",
		"eventBroadcastHourMin" => "1031",

	]
);

Bill Delete

The Bill Delete Event can be triggered using Custom Logic. The following parameters are Required to execute the Event.

BIll Delete
/**
* Event: Delete Bill
* Listener Class: Application_Model_Bill_Bill
* Listener Method: eventDeleteBill
*/

PCR_Event::attachDb(
    "delete-bill",
    ["Application_Model_Bill_Bill" => "eventDeleteBill"]
);
PCR_Event::trigger(
    "delete-bill",  	
	[
		"contact" => "216121",	//RecID of Contact that initiated the Bill Deletion
		"BILLS_RECID" => "445", //RecID of Bill being run

		"eventBroadcastBy" => "216121",
		"eventBroadcastTime" => "Sep 30, 2022, 10:20 am",
		"eventBroadcastDayofWeek" => "5",
		"eventBroadcastHourMin" => "1020",
	] 
);

Bill Generate

The Bill Generate Event can be triggered using Custom Logic. The following parameters are Required to execute the Event.

Bill Generate
/**
* Event: Generate Bill
* Listener Class: Application_Model_Bill_BillDetails
* Listener Method: eventGenerateBill
*/

PCR_Event::attachDb(
    "generate-bill",
    ["Application_Model_Bill_BillDetails" => "eventGenerateBill"]
);
PCR_Event::trigger(
    "generate-bill",
	 [
		"start_date" => "2022-11-01 00:00:00",
		"end_date" => "11/30/2022",
		"next_run_date" => null,
		"test_bill" => "0",
		"RECID" => "addNew",
		"contact" => "216121", //RecID of Contact that initiated the Event
		"LISTENER_FAIL_METHOD" => "eventBillFailed",

		"eventBroadcastBy" => "216121",
		"eventBroadcastTime" => "Oct 6, 2022, 11:44 am",
		"eventBroadcastDayofWeek" => "4",
		"eventBroadcastHourMin" => "1144",
	] 
);

Charge Catalog Status Change

The Charge Catalog Status Change Events can be triggered using Custom Logic. When a Status is changed on a Charge Catalog, a prompt gives the option to select a Specified Date or Date To Last Billed. Both options can be generated using Custom Logic. The following parameters are Required to execute each Event.

Date to Last Billed

Date to Last Billed
/**
* Event: Available Charges Bulk Update requested
* Listener Class: Application_Model_ChrgCatalog_ChrgCatalog
* Listener Method: eventStopCharges
*/

PCR_Event::attachDb(
    "stop-charges",
    ["Application_Model_ChrgCatalog_ChrgCatalog" => "eventStopCharges"]
);
PCR_Event::trigger(
    "stop-charges", 
	[ 		
		"chgCatalogRecids" => 1761,		//RecID of Charge Catalog selected
		"stopDate" => "12\/14\/2022", 	//Date selected when stopping charges
		"oldAmount" => "10.00000",
		"newAmount" => "5.00",
		"effective" => "backdate",
		"contact" => "216121",			//RecID of Contact that initiated update

		"eventBroadcastBy" => "216121",
		"eventBroadcastTime" => "Sep 29, 2022, 3:29 pm",
		"eventBroadcastDayofWeek" => "4",
		"eventBroadcastHourMin" => "1529",   
	]
);

Specified Date

Specified Date
/**
* Event: Available Charges Bulk Update requested
* Listener Class: Application_Model_ChrgCatalog_ChrgCatalog
* Listener Method: eventStopCharges
*/

PCR_Event::attachDb(
    "stop-charges",
    ["Application_Model_ChrgCatalog_ChrgCatalog" => "eventStopCharges"]
);
PCR_Event::trigger(
    "stop-charges",
	[ 		
		"chgCatalogRecids" => 1761,	 	//RecID of Charge Catalog selected
	 	"stopDate" => "12\/14\/2022",	//Date selected when stopping charges
		"oldAmount" => "15.00000",
		"newAmount" => "10.00",
		"effective" => "today", 
		"contact" => "216121",			//RecID of Contact that initiated the event 

		"eventBroadcastBy" => "216121",
		"eventBroadcastTime" => "Sep 29, 2022, 3:22 pm",
		"eventBroadcastDayofWeek" => "4",
		"eventBroadcastHourMin" => "1522",   
	]
);

Contact Replacement

The Contact Replacement Event can be triggered using Custom Logic. The following parameters are Required to execute the Event.

Contact Replacement
/**
* Event: System-wide Contact Replacement
* Listener Class: Application_Model_Contact_Contact
* Listener Method: eventReplaceContact
*/  

PCR_Event::attachDb(
    "replace-contact",
    ["Application_Model_Contact_Contact" => "eventReplaceContact"]
);

PCR_Event::trigger(
    "replace-contact",
    [      
        "contact" => "216121",     //RecID of Contact that initiated the replacement
        "contactRecid" =>
        [
            "216125"            //RecID of Contact that is replacing
        ],
        "replaceContactRecid" =>
        [
            "216121"            //RecID of Contact getting replacing
        ],
        "comment" => "This is a comment",
        "deleteContact" => true,
        "users_recid" => "1217",   //RecID of User that initiated the replacement
 
        "eventBroadcastBy" => "216121",
        "eventBroadcastTime" => "Oct 3, 2022, 2:47 pm",
        "eventBroadcastDayofWeek" => "1",
        "eventBroadcastHourMin" => "1447",        
    ]
);

Department Replacement

The Department Replacement Event can be triggered using Custom Logic. The following parameters are Required to execute the Event.

Department Replacement
/**
* Event: System-wide Department Replacement
* Listener Class: Application_Model_DeptHierarchy_DeptHierarchy
* Listener Method: eventReplaceDeptHierarchy
*/

PCR_Event::attachDb(
    'department-replacement',
    ['Application_Model_DeptHierarchy_DeptHierarchy' => 'eventReplaceDeptHierarchy']
);
PCR_Event::trigger(
    'department-replacement',
  	[ 		
		"contact" => "216121", 	//RecID of Contact that initiated the replacement
		"deptRecid" =>
		[
			"3638" 				//RecID of Department getting replaced
		],
		"replaceDeptRecid" =>
		[
			"3507" 				//RecID of Department that is replacing 
		],
		"deleteDept" => true, 
		"comment" => "This is a comment",
		"users_recid" => "1217", 	//RecID of User that initiated the replacement

		"eventBroadcastBy" => "216121",
		"eventBroadcastTime" => "Oct 3, 2022, 2:21 pm",
		"eventBroadcastDayofWeek" => "1",
		"eventBroadcastHourMin" => "1421",   
	]
);

Equipment Bulk Update

The Equipment Bulk Update Event can be triggered using Custom Logic. The following parameters are Required to execute the Event.

Equipment Bulk Update
/**
* Event: Equipment Bulk Update requested
* Listener Class: Application_Model_Equipment_Equipment
* Listener Method: eventBulkUpdate
*/

PCR_Event::attachDb(
    "bulk-update",
    ["Application_Model_Equipment_Equipment" => "eventBulkUpdate"]
);
PCR_Event::trigger(
    "bulk-update", 
	[  		
		"equipment_type_enabled" => "0",
		"assoc_service_enabled" => "0",
		"cabling_eqp_type_enabled" => "1",
		"cabling_eqp_type" => "37",
		"location_enabled" => "0",
		"status_enabled" => "0",
		"condition_enabled" => "0",
		"contact_owner_enabled"=> "0",
		"dept_hier_owner_enabled" => "0",
		"gla_enabled" => "0",
		"war_date_enabled" => "0",
		"billable_enabled" => "0",
		"private_enabled" => "0",
		"host_name_enabled" => "0",
		"lan_name_enabled" => "0",
		"dhcp_enabled" => "0",
		"RECID" => "659200", //RecID of selected Equipment
		"confirmed" => true,
		"comment" => "This is a comment",
		"effective" => null,
		"users_recid" => "1217",
		"contact" => "216121",
		"selectedEquipmentRecids" =>
		[
			"659200", //RecID of selected Equipment
			"658688" //RecID of selected Equipment
		],
		"selectedEquipmentFilters" => [],
		"isLocationRequired" => false,

		"eventBroadcastBy" => "216121",
		"eventBroadcastTime" => "Oct 3, 2022, 3:00 pm",
		"eventBroadcastDayofWeek" => "1",
		"eventBroadcastHourMin" => "1500",   	
	]
);

Equipment Details Sync

Sync Service GLA, Owner and Location to Equipment

Equipment Details Sync
<?php
/**
* Event: Custom PHP Event
* Frequency: Hourly
* Time:
* Listener Class: Core_Model_Event
* Listener Method: eventCustom
*/

PCR_Event::attachDb("equipment-bulk-update", ["Application_Model_Equipment_Equipment" => "eventBulkUpdate"]);

$records = $this->query(<<<SQL
        SELECT
          S.RECID AS SERVICES_RECID,
          E.RECID AS EQUIPMENT_RECID,
          S.OWNER_CONTACTS_RECID AS SERVICE_OWNER_CONTACTS_RECID,
          E.OWNER_CONTACTS_RECID AS EQUIPMENT_OWNER_CONTACTS_RECID,
          S.OWNER_DEPT_HIERARCHY_RECID AS SERVICE_OWNER_DEPT_HIERARCHY_RECID,
          E.OWNER_DEPT_HIERARCHY_RECID AS EQUIPMENT_OWNER_DEPT_HIERARCHY_RECID,
        CASE
          WHEN S.OWNER_CONTACTS_RECID IS NULL
            THEN SDH.BILLING_GROUPS_RECID
          WHEN SCON.BILLING_GROUPS_RECID IS NULL 
            THEN SCON_DEPT.BILLING_GROUPS_RECID
          ELSE SCON.BILLING_GROUPS_RECID
          END AS SERVICE_BILLING_GROUP,
        CASE
          WHEN E.OWNER_CONTACTS_RECID IS NULL 
            THEN EDH.BILLING_GROUPS_RECID
          WHEN ECON.BILLING_GROUPS_RECID IS NULL 
            THEN ECON_DEPT.BILLING_GROUPS_RECID
          ELSE ECON.BILLING_GROUPS_RECID
          END AS EQUIPMENT_BILLING_GROUP,
        SEG.GLA_RECID AS SERVICE_GLA,
        EEG.GLA_RECID AS EQUIPMENT_GLA,
        S.LOCATIONS_RECID AS SERVICE_LOCATION,
        E.LOCATIONS_RECID AS EQUIPMENT_LOCATION,
        S.MULTIPLE_LOCATIONS,
        COALESCE(EG.FORMAT,SG.FORMAT) AS GLA_FORMAT,
        E.BILLABLE,
        E.WARRANTY_END_DATE

        FROM SERVICES S
        JOIN SERVICES_EQUIPMENT SE ON S.RECID = SE.SERVICES_RECID
        JOIN EQUIPMENT E ON SE.EQUIPMENT_RECID = E.RECID
        LEFT JOIN DEPT_HIERARCHY EDH ON E.OWNER_DEPT_HIERARCHY_RECID = EDH.RECID
        LEFT JOIN DEPT_HIERARCHY SDH ON S.OWNER_DEPT_HIERARCHY_RECID = SDH.RECID
        LEFT JOIN CONTACTS ECON ON E.OWNER_CONTACTS_RECID = ECON.RECID
        LEFT JOIN DEPT_HIERARCHY ECON_DEPT ON ECON.DEPT_HIERARCHY_RECID = ECON_DEPT.RECID
        LEFT JOIN CONTACTS SCON ON S.OWNER_CONTACTS_RECID = SCON.RECID
        LEFT JOIN DEPT_HIERARCHY SCON_DEPT ON SCON.DEPT_HIERARCHY_RECID = SCON_DEPT.RECID
        LEFT JOIN SERVICES_EXPENSE_GLA SEG ON S.RECID = SEG.SERVICES_RECID
        LEFT JOIN EQUIPMENT_EXPENSE_GLA EEG ON E.RECID = EEG.EQUIPMENT_RECID
        LEFT JOIN LISTS SEGL ON SEG.EXPENSE_TYPE_LISTS_RECID = SEGL.RECID
        LEFT JOIN LISTS EEGL ON EEG.EXPENSE_TYPE_LISTS_RECID = EEGL.RECID
        LEFT JOIN GLA EG ON EEG.GLA_RECID = EG.RECID
        LEFT JOIN GLA SG ON SEG.GLA_RECID = SG.RECID

        WHERE
        -- GLAs are Default and 100% or are not set
        (
          ((SEGL.CODE = 'DEFAULT' AND SEG.PERCENT = 100) OR SEGL.CODE IS NULL)
          AND
          ((EEGL.CODE = 'DEFAULT' AND SEG.PERCENT = 100) OR EEGL.CODE IS NULL)
        )
        -- if the OWNER is different
        AND
        (
            (
              (S.OWNER_CONTACTS_RECID <> E.OWNER_CONTACTS_RECID AND S.OWNER_CONTACTS_RECID IS NOT NULL AND E.OWNER_CONTACTS_RECID IS NOT NULL)
              OR (S.OWNER_DEPT_HIERARCHY_RECID <> E.OWNER_DEPT_HIERARCHY_RECID AND S.OWNER_DEPT_HIERARCHY_RECID IS NOT NULL AND E.OWNER_DEPT_HIERARCHY_RECID IS NOT NULL)
              OR (S.OWNER_CONTACTS_RECID IS NULL AND E.OWNER_CONTACTS_RECID IS NOT NULL)
              OR (S.OWNER_CONTACTS_RECID IS NOT NULL AND E.OWNER_CONTACTS_RECID IS NULL)
              OR (S.OWNER_DEPT_HIERARCHY_RECID IS NULL AND E.OWNER_DEPT_HIERARCHY_RECID IS NOT NULL)
              OR (S.OWNER_DEPT_HIERARCHY_RECID IS NOT NULL AND E.OWNER_DEPT_HIERARCHY_RECID IS NULL)
            )
            -- if the location is different
            OR (NOT(S.LOCATIONS_RECID <=> E.LOCATIONS_RECID) AND S.MULTIPLE_LOCATIONS = 0)
            -- if the GLAs are different
            OR  NOT(SEG.GLA_RECID  <=>  EEG.GLA_RECID )
         );
SQL
);

foreach ($records as $rec) {
    $eventParams = [
        "contact" => 101452,  // PCR Admin contact
        "users_recid" => 485, // pcradmin user
        "selectedEquipmentRecids" => [$rec['EQUIPMENT_RECID']],
        "gla_enabled" => false,
        "condition_enabled" => false,
        "cabling_eqp_type_enabled" => false,
        "status_enabled" => false,
        "location_enabled" => false,
        "assoc_service_enabled" => false,
        "equipment_type_enabled" => false,
        "dhcp_enabled" => false,
        "lan_name_enabled" => false,
        "host_name_enabled" => false,
        "private_enabled" => false,
        "billable_enabled" => false,
        "billable" => $rec["BILLABLE"],
        "war_date_enabled" => false,
        "war_date" => $rec["WARRANTY_END_DATE"],
        "dept_hier_owner_enabled" => false,
        "contact_owner_enabled" => false,
        // other junk from the EQP Bulk UPdate
        "gla_format" => $rec["GLA_FORMAT"],
        "selectedEquipmentTypeListRecid" => null,
        "isLocationRequired" => null,
        "comment" => null,
    ];

    if (empty($rec['SERVICE_OWNER_CONTACTS_RECID'])
        && $rec['SERVICE_OWNER_DEPT_HIERARCHY_RECID'] != $rec['EQUIPMENT_OWNER_DEPT_HIERARCHY_RECID']
    ) {
        $eventParams['dept_hier_owner_enabled'] = true;
        $eventParams['dept_hier_owner'] = $rec['SERVICE_OWNER_DEPT_HIERARCHY_RECID'];
    } elseif(empty($rec['SERVICE_OWNER_DEPT_HIERARCHY_RECID'])
        && $rec['SERVICE_OWNER_CONTACTS_RECID'] != $rec['EQUIPMENT_OWNER_CONTACTS_RECID']
    ) {
        $eventParams['contact_owner_enabled'] = true;
        $eventParams['contact_owner'] = $rec['SERVICE_OWNER_CONTACTS_RECID'];
    } elseif(empty($rec['SERVICE_OWNER_DEPT_HIERARCHY_RECID'])
        && $rec['SERVICE_OWNER_CONTACTS_RECID'] == $rec['EQUIPMENT_OWNER_CONTACTS_RECID']
    ) {
        // Equipment has both Contact and Dept Owners -
        // @see https://jira.pcr.com/browse/PCR360-7612
        // updating the contact Owner even though it is already set will clear the Dept Owner
        $eventParams['contact_owner_enabled'] = true;
        $eventParams['contact_owner'] = $rec['SERVICE_OWNER_CONTACTS_RECID'];
    }

    if($rec['MULTIPLE_LOCATIONS'] == "0"
        && $rec['SERVICE_LOCATION'] != $rec['EQUIPMENT_LOCATION']
    ){
        $eventParams['location_enabled'] = true;
        $eventParams['location'] = $rec['SERVICE_LOCATION'];
    }

    if($rec['SERVICE_GLA'] != $rec['EQUIPMENT_GLA']){
        $eventParams['gla_enabled'] = true;
        $eventParams['gla'] = $rec['SERVICE_GLA'];
    }

    // Only trigger the bulk update if any of the options are enabled.  Otherwise nothing is changing, there is no
    // need to trigger a bulk update if nothing is changing.
    if($eventParams['dept_hier_owner_enabled']
        || $eventParams['location_enabled']
        || $eventParams['gla_enabled']
        || $eventParams['contact_owner_enabled']
    ){
        PCR_Event::trigger("equipment-bulk-update", $eventParams);
    }
}

Generate Service ID Range

The Generate Service ID Range Event can be triggered using Custom Logic. The following parameters are Required to execute the Event.

Generate Service ID Range
/**
* Event: Service ID range generation requested
* Listener Class: Application_Model_Service_Service
* Listener Method: generateRangeOfServices
*/

PCR_Event::attachDb(
    'service-id-generation',
    ['Application_Model_Service_Service' => 'generateRangeOfServices']
);
PCR_Event::trigger(
    'service-id-generation',
		[ 		
		"serv_cat_type" => "2", 				//RecID of selected Service Catalog
		"RECID" => "addNew",
		"serviceNumberStart" => "1000000001", 	//Start of range entered 
		"serviceNumberFinish" => "1000000010", 	//End of range entered	
		"udf" =>
		[
			"1" =>
			[
				"VALUE" => null,
				"DATATYPE" => "INTEGER"
			],
			"51" =>
			[
				"VALUE => null,
				"DATATYPE" => "INTEGER"
			],
			"148" =>
			[
				"VALUE" => null,
				"DATATYPE" => "VARCHAR"
			],
			"164" =>
			[
				"VALUE" => null,
				"DATATYPE" => "INTEGER"
			],
			"208" => 
			[
				"VALUE" => null,
				"DATATYPE" => "VARCHAR"
			],
			"209" =>
			[
				"VALUE" => null,
				"DATATYPE" => "INTEGER"
			],
			"210" =>
			[
				"VALUE" => null,
				"DATATYPE" => "INTEGER",
				"udf-210-VALUE_display" => null
			],
			"211" =>
			[
				"VALUE" => null,
				"DATATYPE" => "INTEGER"
			],
			"212" =>
			[
				"VALUE" => null,
				"DATATYPE" => "CLOB"
			],
			"225" =>
			[
				"VALUE" => null,
				"DATATYPE" => "VARCHAR"
			],
			"226" =>
			[
				"VALUE" => null,
				"DATATYPE" => "VARCHAR"
			],
			"255" =>
			[
				"VALUE" => null,
				"DATATYPE" => "VARCHAR"
			]
		],
		"serv_cat_type_display" => "1FB Business Line", 	//Service Catalog
		"pools" => [],
		"save-new" => "true",
		"serviceTypeName" => "PHONE",
		"generateNum" => 10,
		"contact" => "216121", 		//RecID of Contact that initiated the Service ID generation 
	 	"comment" => "This is a comment",

		"eventBroadcastBy" => "216121",
		"eventBroadcastTime" => "Oct 4, 2022, 10:32 am",
		"eventBroadcastDayofWeek" => "2",
		"eventBroadcastHourMin" => "1032",   
		]
);

GLA Replace

The GLA Replace Events can be triggered using Custom Logic. When a GLA is replaced a prompt gives Users the option to select Effective Today or Date To Last Billed. Both options can be generated using Custom Logic. The following parameters are Required to execute each Event.

Effective Today

Effective Today
/**
* Event: GLA Replacement requested
* Listener Class: Application_Model_Gla_Gla
* Listener Method: eventReplaceGla
*/

PCR_Event::attachDb(
	"replace-gla", 
	["Application_Model_Gla_Gla" => "eventReplaceGla"]
);
PCR_Event::trigger(
	"replace-gla", 
	[
	    "contact" => "12345",         //RecID of Contact that initiated the GLA replace
    	"users_recid" => "456",       //RecID of User associated with Contact that initiated the GLA replacement
	    "glaRecid" => [1111],         //RecID of User associated with Contact that initiated the GLA replacement
    	"replaceGlaRecid" => "2222",  //RecID of Contact that initiated the GLA replace 
	 	"effective" => "today",       //Effective Date for Charge Updates
	    "setInactiveGla" => true,
	    "comment" => "This is a comment",

 		"eventBroadcastBy" => "12345",
		"eventBroadcastTime" => "Sep 30, 2022, 11:23 am",
		"eventBroadcastDayofWeek" => "5",
		"eventBroadcastHourMin" => "1123",
	 ]
);

Date to Last Billed

Date to Last Billed
/**
* Event: GLA Replacement requested
* Listener Class: Application_Model_Gla_Gla
* Listener Method: eventReplaceGla
*/

 PCR_Event::attachDb(
	"replace-gla", 
	["Application_Model_Gla_Gla" => "eventReplaceGla"]
);
PCR_Event::trigger(
	"replace-gla",  	
	[  	
		"contact" => "216121", 	   	//RecID of Contact that initiated the GLA replace
		"glaRecid" => [3],         	//RecID of GLA getting replaced
		"replaceGlaRecid" => [22],  //RecID of the replacement GLA 					
		"effective" => "backdate",  //Button Select when saving changes made
		"comment" => "This is a comment",
		"setInactiveGla" => true,
		"users_recid" => "1217", 	//RecID of User associated with Contact that initiated the GLA replacement

	    "eventBroadcastBy" => "216121",
		"eventBroadcastTime" => "Sep 30, 2022, 11:34 am",
		"eventBroadcastDayofWeek" => "5",
		"eventBroadcastHourMin" => "1134",
	]   
);

GLA Rollover

This Custom Event relies on UDFs for 'End_Date' and "Rollover_GLA" to roll over a GLA for billing on a given date.

GLA Rollover
/**
 * Event: Custom PHP Event
 * Frequency: Daily
 * Time: 12:00am
 * Listener Class: Core_Model_Event
 * Listener Method: eventCustom
 */

$glas = $this->query(<<<SQL
    SELECT G.STATUS AS STATUS, V.GLA_FULL_CODES AS OLD_GLA, 
           G.RECID AS OLD_GLA_RECID, V1.GLA_FULL_CODES AS NEW_GLA, 
           G1.RECID AS NEW_GLA_RECID, U2.DATETIME_VALUE AS END_DATE
    FROM V_GLA_COMP_COMB_ADMIN V
    INNER JOIN GLA G ON V.RECID = G.RECID
    INNER JOIN USER_DEFINED_FIELDS_VALS U1 
        ON G.RECID = U1.TABLE_RECID AND U1.TABLE_NAME = 'GLA' AND U1.UDF_RECID = (
            SELECT RECID FROM USER_DEFINED_FIELDS WHERE LABEL = 'Rollover_GLA'
        )
    LEFT JOIN GLA G1 ON G1.RECID = U1.INTEGER_VALUE
    LEFT JOIN V_GLA_COMP_COMB_ADMIN V1 ON G1.RECID = V1.RECID
    INNER JOIN USER_DEFINED_FIELDS_VALS U2 
        ON G.RECID = U2.TABLE_RECID AND U2.TABLE_NAME = 'GLA' AND U2.UDF_RECID = (
            SELECT RECID FROM USER_DEFINED_FIELDS WHERE LABEL = 'End_Date'
        )
    WHERE
    U2.DATETIME_VALUE IS NOT NULL
    AND U2.DATETIME_VALUE <= NOW()
    AND G.STATUS = 1
    ;
SQL
);

$results = ["deactivateGla" => [], "activateGla" => [], "rolledGla" => []];
PCR_Event::attachDb("replace-gla", [
    "Application_Model_Gla_Gla" => "eventReplaceGla"
]);
foreach ($glas as $gla) {

    // deactivate anything with past end_date
    $results["deactivateGla"][] = $gla["OLD_GLA_RECID"];

    // only Roll to the new GLA if there is a new GLA
    if(!empty($gla["NEW_GLA_RECID"])) {
        $results["activateGla"][] = $gla["NEW_GLA_RECID"];
        // only rollover if the END_DATE was within the last 30 days
        if (time() - strtotime($gla["END_DATE"]) < (30 * 24 * 60 * 60)) {
            $results["rolledGla"][] = $gla["OLD_GLA_RECID"];
            PCR_Event::trigger("replace-gla", [
                "contact" => 101452,  // PCR Admin contact
                "users_recid" => 485, // pcradmin user
                "glaRecid" => [$gla["OLD_GLA_RECID"]],
                "replaceGlaRecid" => $gla["NEW_GLA_RECID"],
                "prorate" => true,
                "setInactiveGla" => true,
                "comment" => "Nightly GLA Rollover from {$gla['OLD_GLA']} to {$gla['NEW_GLA']} recid"
                             . " {$gla['OLD_GLA_RECID']} to {$gla['NEW_GLA_RECID']}",
            ]);
        }
    }
}

// if anything Rolled/Deactivated then we need to fire that event
if(!empty($results["activateGla"]) || !empty($results["rolledGla"]) || !empty($results["deactivateGla"])){
    $results["ACTIVATE_COUNT"] = count($results["activateGla"]);
    $results["DEACTIVATE_COUNT"] = count($results["deactivateGla"]);
    $results["ROLLED_COUNT"] = count($results["rolledGla"]);

    // set the gla-status event and attach for a notification too
    PCR_Event::attachDb("gla-status", [
        "Core_Model_Notification" => "eventSend",
        "Application_Model_Gla_Gla" => "eventGlaStatus"
    ]);
    PCR_Event::trigger("gla-status", $results);
} else {
    $results["ACTIVATE_COUNT"] = $results["DEACTIVATE_COUNT"] = $results["ROLLED_COUNT"] = 0;

    // set the gla-status event and attach for a notification to indicate no glas rolled over
    PCR_Event::attachDb(
        "gla-status",
        [
            "Core_Model_Notification"   => "eventSend",
            "Application_Model_Gla_Gla" => "eventGlaStatus"
        ]
    );
    PCR_Event::trigger("gla-status", $results); 
}

Inactive Service Locations Clean Up

Inactive Locations Clean Up
<?php
/**
 * IN201620553 - Created to clean up Inactive service locations and owners before aging occurs.
 * Event: Custom PHP Event
 * Frequency: Hourly
 * Time:
 * Listener Class: Core_Model_Event
 * Listener Method: eventCustom
 * Description: This event queries for Inactive services with billed charges (or no charges at all)
 * and triggers the service bulk update to remove the owner and location.
 */


PCR_Event::attachDb('services-bulk-update', ['Application_Model_Service_Service' => 'eventBulkUpdate']);

$records = $this->query(<<<SQL
    SELECT DISTINCT S.RECID AS SERVICES_RECID,
    FROM SERVICES AS S
    JOIN LISTS AS L ON L.RECID = S.SERVICE_STATUS_LISTS_RECID
    LEFT JOIN SERVICES_CHARGES AS SC ON S.RECID = SC.SERVICES_RECID
    LEFT JOIN CHARGES AS C
        ON C.ORIG_TABLE_NAME = 'SERVICES_CHARGES' AND C.ORIG_TABLE_RECID = SC.RECID
    LEFT JOIN CHARGES_BILLED AS CB_MAX 
       ON CB_MAX.CHARGES_RECID = C.RECID
    LEFT JOIN CHARGES_BILLED AS CB_MIN
       ON CB_MIN.CHARGES_RECID = C.RECID AND CB_MAX.RECID < CB_MIN.RECID
    LEFT JOIN BILLS AS B ON B.RECID = CB_MAX.BILLS_RECID
    WHERE
        L.CODE = 'INACTIVE'
        AND S.LOCATIONS_RECID IS NOT NULL
        AND ( 
           CB_MAX.BILLING_COMPLETE = 1
           OR 
           SC.RECID IS NULL 
        )
        AND CB_MIN.RECID IS NULL
    GROUP BY S.RECID, SC.RECID
    LIMIT 400;
SQL
);

$eventParams = [
    'contact'     => 101452,  // PCR Admin contact
    'users_recid' => 485, // pcradmin user
];

//$eventParams['contact_owner_enabled'] = '1';
//$eventParams['contact_owner'] = null;
//$eventParams['dept_hier_owner_enabled'] = '1';
//$eventParams['dept_hier_owner'] = null;
$eventParams['location_enabled'] = '1';
$eventParams['location'] = null;
$eventParams['comment'] = 'Cleanup event to remove Locations from Inactive Services';

if(!empty($records)){
    foreach ($records as $rec) {
        $eventParams['selectedServiceRecids'][] = $rec['SERVICES_RECID'];
    }
    PCR_Event::trigger('services-bulk-update', $eventParams);
}

IP Range Bulk Update

The IP Range Bulk Update Event can be triggered using Custom Logic. The following parameters are Required to execute the Event.

IP Range Bulk Update
/**
* Event: IP Address Bulk Update requested
* Listener Class: Core_Model_IpAddress
* Listener Method: eventBulkUpdate
*/

PCR_Event::attachDb(
    "bulk-update",
    ["Core_Model_IpAddress" => "eventBulkUpdate"]
);
PCR_Event::trigger(
    "bulk-update", 
	[ 		
		"status" => "163",
		"set_protocol" => "ipv4",
		"octet1" => "10",
		"octet2" => "126",
		"octet3" => "112",
		"octet4" => "32",
		"octet5" => null,
		"octet6" => null,
		"octet7" => null,
		"octet8" => null,
		"bulkOctet1" => "10",
		"bulkOctet2" => "126",
		"bulkOctet3" => "112",
		"bulkOctet4" => "36",
		"bulkOctet5" => null,
		"bulkOctet6" => null,
		"bulkOctet7" => null,
		"bulkOctet8" => null,
		"description" => "test",

		"RECID" => "addNew",

		"contact" => "216121", 		//RecID of Contact that initiated the update
		"confirmed" => true,
		"ipAddress" => "10.126.112.32",
		"ip4amount" => 5,

		"eventBroadcastBy" => "216121",
		"eventBroadcastTime" => "Oct 4, 2022, 1=>19 pm",
		"eventBroadcastDayofWeek" => "2",
		"eventBroadcastHourMin" => "1319",  
	]
);

Location Demolish

The Location Demolish Event can be triggered using Custom Logic. The following parameters are Required to execute the Event.

Location Demolish
/**
* Event: Location Demolish
* Listener Class: Application_Model_Location_Location
* Listener Method: eventDemolish
*/
//In this code example, a building with 10 floors is demolished and one of the floors has 10 rooms.

PCR_Event::attachDb(
    "location-demolish",
    ["Application_Model_Location_Location" => "eventDemolish"]
);
PCR_Event::trigger(
    "location-demolish", 
   [
	"recid" => 331648, //RecID of Parent location getting Demolished
	"recids" =>
	[
		"331648", 	//RecID of Parent location getting Demolished
		"331649", 	//RecID of location getting Demolished
		"331699", 	//RecID of location getting Demolished
		"331700", 	//RecID of location getting Demolished
		"331701", 	//RecID of location getting Demolished
		"331702", 	//RecID of location getting Demolished
		"331703", 	//RecID of location getting Demolished
		"331704", 	//RecID of location getting Demolished
		"331705", 	//RecID of location getting Demolished
		"331706", 	//RecID of location getting Demolished
		"331707", 	//RecID of location getting Demolished
		"331708", 	//RecID of location getting Demolished
		"331658", 	//RecID of location getting Demolished
		"331650", 	//RecID of location getting Demolished
		"331651", 	//RecID of location getting Demolished
		"331652", 	//RecID of location getting Demolished
		"331653", 	//RecID of location getting Demolished
		"331654", 	//RecID of location getting Demolished
		"331655", 	//RecID of location getting Demolished
		"331656", 	//RecID of location getting Demolished
		"331657" 	//RecID of location getting Demolished
	],
	"comment" => "This is a comment",

	"eventBroadcastBy" => "216121",
	"eventBroadcastTime" => "Oct 3, 2022, 2:04 pm",
	"eventBroadcastDayofWeek" => "1",
	"eventBroadcastHourMin" => "1404",
	]
);

Move Available Services to Parent

Move Available Services to their Parent Category

Move Available Services to Parent
<?php

// >>>> COPY START !!! <<<< //

/**
 * This looks for any Phone Services which, after aging are changed from 'Inactive' to 'Available', and which
 * are in any of the child Categories of 'Telephones & Voicemail'. It then creates a Bulk Update Event to
 * move those Services to the parent.
 *
 * Note: The child Catalog Type must be 'Phone'.
 *
 * Event:           Custom PHP Event
 * Frequency:       Daily
 * Time:
 * Listener Class:  Core_Model_Event
 * Listener Method: eventCustom
 */

PCR_Event::attachDb('services-bulk-update', ['Application_Model_Service_Service' => 'eventBulkUpdate']);

$parentCatalogRecidSql = <<<SQL
SELECT RECID
FROM   SERV_CATALOG
WHERE  SERVICE_NAME = 'Telephones & Voicemail'
SQL;

$listsRecidSql = <<<SQL
SELECT    LISTS.RECID
FROM      LISTS
LEFT JOIN LIST_TYPES
    ON LISTS.LIST_TYPES_RECID = LIST_TYPES.RECID
WHERE     LIST_TYPES.TYPE = 'SERVICE_TYPE'
AND       LISTS.CODE = 'PHONE';
SQL;

if (($parentCatalogRecid = $this->query($parentCatalogRecidSql)) &&
    ($listsRecid = $this->query($listsRecidSql))
) {
    $parentCatalogRecid = (int) $parentCatalogRecid[0]['RECID'];
    $listsRecid = (int) $listsRecid[0]['RECID'];

    $servicesToMoveSql = <<<SQL
SELECT SERVICES.RECID
FROM   SERVICES
LEFT JOIN LISTS
    ON SERVICES.SERVICE_STATUS_LISTS_RECID = LISTS.RECID
LEFT JOIN LIST_TYPES
    ON LISTS.LIST_TYPES_RECID = LIST_TYPES.RECID
WHERE  LISTS.CODE = 'AVAILABLE'
AND    LIST_TYPES.TYPE = 'SERVICE_STATUS'
AND    SERVICES.SERV_CATALOG_RECID IN (
    SELECT SERV_CATALOG_FULLPATH.SERV_CATALOG_RECID
    FROM   SERV_CATALOG_FULLPATH
    LEFT JOIN SERV_CATALOG
        ON SERV_CATALOG_FULLPATH.SERV_CATALOG_RECID = SERV_CATALOG.RECID
    LEFT JOIN LISTS
        ON SERV_CATALOG.SERVICE_TYPE_LISTS_RECID = LISTS.RECID
    LEFT JOIN LIST_TYPES
        ON LISTS.LIST_TYPES_RECID = LIST_TYPES.RECID
    WHERE  PATH_SERV_CATALOG_RECID = {$parentCatalogRecid}
    AND    SERV_CATALOG_RECID <> {$parentCatalogRecid}
    AND    LISTS.CODE = 'PHONE'
    AND    LIST_TYPES.TYPE = 'SERVICE_TYPE'
)
SQL;

    $userSql = <<<SQL
SELECT RECID, CONTACTS_RECID
FROM USERS
WHERE USERID = 'pcr'
SQL;

    if (($servicesToMove = $this->query($servicesToMoveSql)) &&
        ($user = $this->query($userSql))
    ) {
        $eventParams = [
            'service_type_enabled'    => 1,
            'location_enabled'        => 0,
            'status_enabled'          => 0,
            'service_host_enabled'    => 0,
            'sla_enabled'             => 0,
            'contact_owner_enabled'   => 0,
            'dept_hier_owner_enabled' => 0,
            'gla_enabled'             => 0,
            'pools_enabled'           => 0,
            'billable_enabled'        => 0,
            'directory_enabled'       => 0,
            'essential_enabled'       => 0,
            'report_911_enabled'      => 0,
            'isLocationRequired'      => 0,
            'isServiceHostRequired'   => 0,

            'contact'     => (int) $user[0]['CONTACTS_RECID'],
            'users_recid' => (int) $user[0]['RECID'],

            'service_type'                 => $parentCatalogRecid,
            'selectedServiceTypeListRecid' => $listsRecid,
            'comment'                      => 'Custom Event: Move all "Available" Services to parent Catalog.'
        ];

        foreach ($servicesToMove as $service) {
            $eventParams['selectedServiceRecids'][] = (int) $service['RECID'];
        }

        PCR_Event::trigger('services-bulk-update', $eventParams);
    }
}

// >>>> COPY STOP !!! <<<< //

?>

Nightly Service Location Update

Nightly Service Location Update
/**
 * Event: Custom PHP Event
 * Frequency: Daily
 * Time: 12:00am
 * Listener Class: Core_Model_Event
 * Listener Method: eventCustom
 */

$services = $this->query(
   "SELECT S.RECID AS SERVICE_RECID, L.RECID AS LOCATION_RECID 
   FROM PCR360_PROD.SERVICES S
   JOIN PCR360_PROD.PATHS P ON P.SERVICES_RECID = S.RECID
   JOIN PCR360_PROD.PATH_LEGS PL ON PL.PATHS_RECID = P.RECID
   JOIN PCR360_PROD.EQUIPMENT E ON PL.FROM_EQUIPMENT_RECID = E.RECID
   JOIN PCR360_PROD.LOCATIONS L ON E.LOCATIONS_RECID = L.RECID
   JOIN PCR360_PROD.EQP_CATALOG EC ON E.EQP_CATALOG_RECID = EC.RECID 
   WHERE S.MULTIPLE_LOCATIONS = 0
   AND EC.PART_NUMBER = 'Jacks'
   AND S.LOCATIONS_RECID != E.LOCATIONS_RECID"
);

PCR_Event::attachDb("services-bulk-update", [
    "Application_Model_Service_Service" => "eventBulkUpdate"
]);
foreach ($services as $service) {
    PCR_Event::trigger("services-bulk-update", [
        "selectedServiceRecids" => [$service["SERVICE_RECID"]],
        "location_enabled" => "1",
        "location" => $service["LOCATION_RECID"],
	"service_type_enabled" => "0",
	"status_enabled" => "0",
	"service_host_enabled" => "0",
	"sla_enabled" => "0",
	"contact_owner_enabled" => "0",
	"dept_hier_owner_enabled" => "0",
	"gla_enabled" => "0",
	"pools_enabled" => "0",
	"billable_enabled" => "0",
	"directory_enabled" => "0",
	"essential_enabled" => "0",
	"report_911_enabled" => "0",    
	"isLocationRequired" => true,
	"isServiceHostRequired" => false,
	"selectedServiceTypeListRecid" => null,
    "selectedServiceFilters" => [],
	"billable" => "0",
	"essential" => "0",
	"directory" => "0",
	"status" => "1",
	"report_911" => "0",
	"users_recid" => "2",
	"contact" => "2",
	"comment" => "nightly jack/service location update",
    ]);
}

Pairs/Strands Bulk Update

The Pairs/Strands Bulk Update Event can be triggered using Custom Logic. The following parameters are Required to execute the Event.

Pairs/Strands Bulk Update
/**
* Event: Pairs/Strands Bulk Update requested
* Listener Class: Cabling_Model_PairStrand
* Listener Method: eventBulkRange
*/

//*NOTE* Only triggered if a change affect more than 100 pair/strands

PCR_Event::attachDb(
    "ps-bulk-update",
    ["Cabling_Model_PairStrand" => "eventBulkRange"]
);
PCR_Event::trigger(
    "ps-bulk-update", 
	[
	"type" => "Pairs\/Strands",
	"method" => "savePairStrand",
	"params" =>
	[
		"from_name" => "FT-Bulk pair\/strands",
		"update_end_points" => "0",
		"low_pair" => "1",
		"high_pair" => "120",
		"multiple" => "0",
		"description" => null,
		"length" => null,
		"destEqpDesc" => "2018-b3",
		"destEqpLoc" => "Washington DC  1455 Pennsylvania Ave NW : OC604X  1125",
		"modified_by" => "Frank",
		"modified_date" => "10\/05\/2022 13:16:08",
		"origEqp_display" => "q1",
		"destEqp_display" => "q6",
		"form-action" => "save",
		"bulkType" => "update",
		"FROM_EQUIPMENT_RECID" => "698112",
		"TO_EQUIPMENT_RECID" => "698117",
		"PAIR_STATUS_LISTS_RECID" => "188",
		"CABLES_RECID" => "5516",
		"confirmed" => true
	],
	"formFieldKey" => 
	[
		"CABLES" =>
		[
			"from_name" => "NAME",
			"update_end_points" => "UPDATE_END_POINTS",
			"modified_by" => "MODIFIED_BY",
			"modified_date" => "MODIFIED_DATE",
		],
		"PAIRS_STRANDS" =>
		[
			"multiple" => "MULTIPLE",
			"description" => "DESCRIPTION",
			"length" => "LENGTH",
			"FROM_EQUIPMENT_RECID" => "FROM_EQUIPMENT_RECID",
			"PAIR_STATUS_LISTS_RECID" => "PAIR_STATUS_LISTS_RECID",
			"CABLES_RECID" => "CABLES_RECID"
		],
		"PAIRS_STRANDS_TO_EQP" => 
		[
			"destEqp" => "TO_EQUIPMENT_RECID",
			"destLow" => "TO_PORTS_PINS_LENS_RECID"
		],
		"RECID" => "RECID"
	],
	"prefixRange" =>
	[
		"1",
		"2",
		"3",
		"4",
		"5",
		"6",
		"7",
		"8",
		"9",
		"10",
		"11",
		"12",
		"13",
		"14",
		"15",
		"16",
		"17",
		"18",
		"19",
		"20",
		"21",
		"22",
		"23",
		"24",
		"25",
		"26",
		"27",
		"28",
		"29",
		"30",
		"31",
		"32",
		"33",
		"34",
		"35",
		"36",
		"37",
		"38",
		"39",
		"40",
		"41",
		"42",
		"43",
		"44",
		"45",
		"46",
		"47",
		"48",
		"49",
		"50",
		"51",
		"52",
		"53",
		"54",
		"55",
		"56",
		"57",
		"58",
		"59",
		"60",
		"61",
		"62",
		"63",
		"64",
		"65",
		"66",
		"67",
		"68",
		"69",
		"70",
		"71",
		"72",
		"73",
		"74",
		"75",
		"76",
		"77",
		"78",
		"79",
		"80",
		"81",
		"82",
		"83",
		"84",
		"85",
		"86",
		"87",
		"88",
		"89",
		"90",
		"91",
		"92",
		"93",
		"94",
		"95",
		"96",
		"97",
		"98",
		"99",
		"100",
		"101",
		"102",
		"103",
		"104",
		"105",
		"106",
		"107",
		"108",
		"109",
		"110",
		"111",
		"112",
		"113",
		"114",
		"115",
		"116",
		"117",
		"118",
		"119",
		"120"
	],
	"rangeSize" => "120",
	"comment" => "This is a comment",
	"users_recid" => "1217",
	"contact" => "216121",
	"cronEvent" => true,
	]
);

PPL Bulk Update


PPL Bulk Update Event
/**
* Event: Ports/Pins/Lens Bulk Update requested
* Listener Class: Cabling_Model_PortsPinsLens
* Listener Method: eventBulkRange
*/
 
//*NOTE* Can only be triggered on the the PPL Range form when a change affects more than 100 Pairs/Strands.
//example: Create over a hundred new PPLs on a piece of equipment using the PPL range form.
 
 
PCR_Event::attachDb(
    "ppl-bulk-update",
    ["Cabling_Model_PortsPinsLens" => "eventBulkRange"]
);
PCR_Event::trigger(
    "ppl-bulk-update",    
    [      
        [
        "type" => "Ports\/Pins\/Lens",
        "method" => "savePPL",
        "params" =>
        [
            "RECID" => "addNew",
            "status" => "188",
            "multiple" => "0",
            "side" => "207",
            "speed" => null,
            "ip4_address" => null,
            "ip4_subnet_mask" => null,
            "ip6_address" => null,
            "ip6_subnet_mask" => null,
            "udf" =>
        [
                "141" =>
                [
                    "VALUE" => null,
                    "DATATYPE" => "VARCHAR"
                ],
                "146" =>
                [
                    "VALUE" => "0",
                    "DATATYPE" => "BOOL"
                ],
                "165" =>
                [
                    "VALUE" => null,
                    "DATATYPE" => "INTEGER"
                ]      
        ],
            "vlan_display" => null,
            "backConnectEqp_display" => null,
            "bulkType" => "create",
            "confirmed" => true
        ],
        "formFieldKey" =>
            [
            "PORTS_PINS_LENS" =>
            [
                "RECID" => "RECID",
                "status" => "PAIR_STATUS_LISTS_RECID",
                "multiple" => "MULTIPLE",
                "side" => "PORT_SIDE_LISTS_RECID",
                "speed" => "PORT_SPEED_LISTS_RECID",
                "ip4_address" => "IP4_ADDRESS",
                "ip4_subnet_mask" => "IP4_SUBNET_MASK",
                "ip6_address" => "IP6_ADDRESS",
                "ip6_subnet_mask" => "IP6_SUBNET_MASK"
            ],
            "RECID" => "RECID"
            ],
        "dialogData" => null,
        "prefixRange" =>
        [
            "01",
            "02",
            "03",
            "04",
            "05",
            "06",
            "07",
            "08",
            "09",
            "10",
            "11",
            "12",
            "13",
            "14",
            "15",
            "16",
            "17",
            "18",
            "19",
            "20",
            "21",
            "22",
            "23",
            "24",
            "25",
            "26",
            "27",
            "28",
            "29",
            "30",
            "31",
            "32",
            "33",
            "34",
            "35",
            "36",
            "37",
            "38",
            "39",
            "40",
            "41",
            "42",
            "43",
            "44",
            "45",
            "46",
            "47",
            "48",
            "49",
            "50",
            "51",
            "52",
            "53",
            "54",
            "55",
            "56",
            "57",
            "58",
            "59",
            "60",
            "61",
            "62",
            "63",
            "64",
            "65",
            "66",
            "67",
            "68",
            "69",
            "70",
            "71",
            "72",
            "73",
            "74",
            "75",
            "76",
            "77",
            "78",
            "79",
            "80",
            "81",
            "82",
            "83",
            "84",
            "85",
            "86",
            "87",
            "88",
            "89",
            "90",
            "91",
            "92",
            "93",
            "94",
            "95",
            "96",
            "97",
            "98",
            "99",
            "100",
            "101",
            "102",
            "103",
            "104",
            "105",
            "106",
            "107",
            "108",
            "109",
            "110",
            "111",
            "112",
            "113",
            "114",
            "115",
            "116",
            "117",
            "118",
            "119",
            "120",
            "121",
            "122",
            "123",
            "124",
            "125",
            "126",
            "127",
            "128",
            "129",
            "130",
            "131",
            "132",
            "133",
            "134",
            "135",
            "136",
            "137",
            "138",
            "139",
            "140",
            "141",
            "142",
            "143",
            "144",
            "145",
            "146",
            "147",
            "148",
            "149",
            "150"
        ],
        "suffixRange" => [],
        "backConnectPrefixRange" => [],
        "backConnectSuffixRange" => [],
        "rangeSize" => 150,
        "comment" => "",
        "users_recid" => "1217",
        "contact" => "216121",
 
        "eventBroadcastBy" => "216121",
        "eventBroadcastTime" => "Oct 4, 2022, 2:45 pm",
        "eventBroadcastDayofWeek" => "2",
        "eventBroadcastHourMin" => "1445",
 
        ]
  ]
);

Process Payment Batch

The Process Payment Batch Event can be triggered using Custom Logic. The following parameters are Required to execute the Event.

Process Payment Batch
/**
* Event: Process Payment Batch 
* Listener Class: Application_Model_Payment_PaymentBatch
* Listener Method: eventProcessBatch
*/  

PCR_Event::attachDb(
	"process-payment-batch", 
	["Application_Model_Payment_PaymentBatch" => "eventProcessBatch"]
);
PCR_Event::trigger(
	"process-payment-batch", 
	[
		"BATCH_RECID" => "1",

		"eventBroadcastBy" => "216121",
		"eventBroadcastTime" => "Oct 4, 2022, 10:08 am",
		"eventBroadcastDayofWeek" => "2",
		"eventBroadcastHourMin" => "1008",
	]
);

Scheduled Maintenance

Scheduled Maintenance required for Equipment is a key component in using PCR-360 for Facilities Management.  Users can set up a Custom Event that will assist in scheduling regular maintenance for Equipment by automatically creating Incidents for that Equipment to be maintained. In order to create this automated behavior first there need to be three User Defined Fields (UDFs) set to track needed maintenance.


To set up the UDFs first navigate to Admin > User Defined Fields > User Defined Fields. Create the UDFs needed by following these steps:

  1. Create a Maintenance Period Type UDF
    1. Create a new UDF by clicking the 'Add' button.
    2. In the 'UDF Identifier' field set the value to "MAINTENANCE_PERIOD_TYPE".
    3. Add a 'Label' of "Maintenance Period".
    4. Set the 'Field Type' to "Dropdown".
    5. The header should look like this example:
    6. In the 'UDF Associations' click the 'Add' button to open the 'Add New Field Association' form.
      1.  Set the 'Association Table' dropdown to "Eqp Catalog"
      2. Click the 'Save New' button.
      3. Close the 'Manage Field Association' form.
    7. Click the 'Save New' button to save the UDF.
    8. When the form refreshes select the 'Dropdown Options' tab.
      1. Click the 'Add' button and add three new options:
        1. Add a 'Value' and 'Code' of "Years".
        2. Add a 'Value' and 'Code' of "Months".
        3. Add a 'Value' and 'Code' of "Days".
        4. When done the options should look like this:
    9. Close the 'Manage Field Association' form.


  2. Create a Maintenance Period Quantity UDF
    1. Create a new UDF by clicking the 'Add' button.
    2. In the 'UDF Identifier' field set the value to "MAINTENANCE_PERIOD_QTY".
    3. Add a 'Label' of "Maintenance Period Quantity".
    4. Set the 'Field Type' to "Number".
    5. The header should look like this example:
    6. In the 'UDF Associations' click the 'Add' button to open the 'Add New Field Association' form.
      1.  Set the 'Association Table' dropdown to "Eqp Catalog"
      2. Click the 'Save New' button.
      3. Close the 'Manage Field Association' form.
    7. Click the 'Save New' button to save the UDF.


  3. Create a Maintenance Date UDF
    1. Create a new UDF by clicking the 'Add' button.
    2. In the 'UDF Identifier' field set the value to "MAINTENANCE_DATE.
    3. Add a 'Label' of "Maintenance Date".
    4. Set the 'Field Type' to "Date".
    5. The header should look like this example:
    6. In the 'UDF Associations' click the 'Add' button to open the 'Add New Field Association' form.
      1.  Set the 'Association Table' dropdown to "Equipment"
      2. Select an 'Equipment Catalog' to limit the UDF to the type that should set for the regular maintenance.
      3. Click the 'Save New' button.
      4. Close the 'Manage Field Association' form.
    7. Click the 'Save New' button to save the UDF.


Once all of three of the UDFs have been created the next step is to add a Custom Event. To add the Custom Event follow these steps:

  1. Navigate to Admin > Custom Logic > Events.
  2. Click the 'Add' button to start a new Event.
  3. Set the 'Identifier' field to "Scheduled Maintenance".
  4. In the 'Logic' tab enter the logic  from the "Schedule Maintenance" expand below:
  5.  Basic Scheduled Maintenance Example
    <?php
    
    $eqp = $this->query(<<<SQL
        SELECT E.*,
           MAINT_DATE.VALUE as MAINTENANCE_DATE,
           MAINT_PERIOD_TYPE.VALUE as MAINTENANCE_PERIOD_TYPE,
           MAINT_PERIOD_QTY.VALUE as MAINTENANCE_PERIOD_QTY
           
        FROM EQUIPMENT E
        INNER JOIN EQP_CATALOG EC 
            ON EC.RECID = E.EQP_CATALOG_RECID
            
        INNER JOIN V_UDF MAINT_DATE 
            ON E.RECID = MAINT_DATE.VALUE_TABLE_RECID AND MAINT_DATE.VALUE_TABLE_NAME = 'EQUIPMENT' AND MAINT_DATE.IDENTIFIER = 'MAINTENANCE_DATE'
            
        INNER JOIN V_UDF MAINT_PERIOD_TYPE 
            ON EC.RECID = MAINT_PERIOD_TYPE.VALUE_TABLE_RECID AND MAINT_PERIOD_TYPE.VALUE_TABLE_NAME = 'EQP_CATALOG' AND MAINT_PERIOD_TYPE.IDENTIFIER = 'MAINTENANCE_PERIOD_TYPE'
    
        INNER JOIN V_UDF MAINT_PERIOD_QTY 
            ON EC.RECID = MAINT_PERIOD_QTY.VALUE_TABLE_RECID AND MAINT_PERIOD_QTY.VALUE_TABLE_NAME = 'EQP_CATALOG' AND MAINT_PERIOD_QTY.IDENTIFIER = 'MAINTENANCE_PERIOD_QTY'
    
        WHERE MAINT_DATE.VALUE = CURRENT_DATE 
        ;
    SQL
    );
    
    
    foreach($eqp as $equipment){
    
        $incident = [
            "type" => "IN",
            "csr" => "1",
            "owner" => $equipment["OWNER_CONTACTS_RECID"] ? $equipment["OWNER_CONTACTS_RECID"] : $equipment["OWNER_DEPT_HIERARCHY_RECID"],
            "owner_type" => $equipment["OWNER_CONTACTS_RECID"] ? "contact" : "department",
            "description" => "Scheduled Maintenance",
            "prob_code" => 3,
            "equipment" => $equipment["RECID"]
        ];
    
        $result = $this->call("saveServiceDesk", $incident);
    
        $maintenanceDate = new DateTime($equipment["MAINTENANCE_DATE"]);
        $intervalType = substr($equipment["MAINTENANCE_PERIOD_TYPE"], 0, 1);
        $interval = new DateInterval("P{$equipment["MAINTENANCE_PERIOD_QTY"]}{$intervalType}");
        $maintenanceDate->add($interval);
    
        $result = $this->call("saveEquipment", [
            "type" => "UDFS",
            "equipment_recid" => $equipment["RECID"],
            "udf_MAINTENANCE_DATE" => $maintenanceDate->format("Y-m-d")
        ]);
    
    }
  6.  Multiple Time frame Example

    The following example uses 10 separate UDFs to control the Custom Event and allows setting multiple different maintenance periods for the same piece of Equipment.

    <?php
    /*
     * Custom Events
     * Basic Instructions: https://confluence.pcr.com/x/WA2BAQ
     * Since adapted for multiple timeframes on the same catalog
     */
    
    $eqp = $this->query(<<<SQL
        SELECT E.*,
           MAINTENANCE_DATE_ANNUAL.VALUE as MAINTENANCE_DATE_ANNUAL,
           MAINTENANCE_DATE_SEMIANNUAL.VALUE as MAINTENANCE_DATE_SEMIANNUAL,
           MAINTENANCE_DATE_QUARTERLY.VALUE as MAINTENANCE_DATE_QUARTERLY,
           MAINTENANCE_DATE_MONTHLY.VALUE as MAINTENANCE_DATE_MONTHLY,
           MAINTENANCE_DATE_WEEKLY.VALUE as MAINTENANCE_DATE_WEEKLY,
           
           MAINTENANCE_DATE_ANNUAL.DESCRIPTION as MAINTENANCE_DATE_ANNUAL_DESC,
           MAINTENANCE_DATE_SEMIANNUAL.DESCRIPTION as MAINTENANCE_DATE_SEMIANNUAL_DESC,
           MAINTENANCE_DATE_QUARTERLY.DESCRIPTION as MAINTENANCE_DATE_QUARTERLY_DESC,
           MAINTENANCE_DATE_MONTHLY.DESCRIPTION as MAINTENANCE_DATE_MONTHLY_DESC,
           MAINTENANCE_DATE_WEEKLY.DESCRIPTION as MAINTENANCE_DATE_WEEKLY_DESC,
           
           COALESCE(MAINTENANCE_PERIOD_QTY_ANNUAL.VALUE,1) as MAINTENANCE_PERIOD_QTY_ANNUAL,
           COALESCE(MAINTENANCE_PERIOD_QTY_SEMIANNUAL.VALUE,1) as MAINTENANCE_PERIOD_QTY_SEMIANNUAL,
           COALESCE(MAINTENANCE_PERIOD_QTY_QUARTERLY.VALUE,1) as MAINTENANCE_PERIOD_QTY_QUARTERLY,
           COALESCE(MAINTENANCE_PERIOD_QTY_MONTHLY.VALUE,1) as MAINTENANCE_PERIOD_QTY_MONTHLY,
           COALESCE(MAINTENANCE_PERIOD_QTY_WEEKLY.VALUE,1) as MAINTENANCE_PERIOD_QTY_WEEKLY
           
        FROM EQUIPMENT E
        INNER JOIN EQP_CATALOG EC 
            ON EC.RECID = E.EQP_CATALOG_RECID
            
        LEFT JOIN V_UDF MAINTENANCE_DATE_ANNUAL 
            ON E.RECID = MAINTENANCE_DATE_ANNUAL.VALUE_TABLE_RECID 
            AND MAINTENANCE_DATE_ANNUAL.VALUE_TABLE_NAME = 'EQUIPMENT' AND MAINTENANCE_DATE_ANNUAL.IDENTIFIER = 'MAINTENANCE_DATE_ANNUAL'
        LEFT JOIN V_UDF MAINTENANCE_DATE_SEMIANNUAL 
            ON E.RECID = MAINTENANCE_DATE_SEMIANNUAL.VALUE_TABLE_RECID 
            AND MAINTENANCE_DATE_SEMIANNUAL.VALUE_TABLE_NAME = 'EQUIPMENT' AND MAINTENANCE_DATE_SEMIANNUAL.IDENTIFIER = 'MAINTENANCE_DATE_SEMIANNUAL'
        LEFT JOIN V_UDF MAINTENANCE_DATE_QUARTERLY 
            ON E.RECID = MAINTENANCE_DATE_QUARTERLY.VALUE_TABLE_RECID 
            AND MAINTENANCE_DATE_QUARTERLY.VALUE_TABLE_NAME = 'EQUIPMENT' AND MAINTENANCE_DATE_QUARTERLY.IDENTIFIER = 'MAINTENANCE_DATE_QUARTERLY'
        LEFT JOIN V_UDF MAINTENANCE_DATE_MONTHLY 
            ON E.RECID = MAINTENANCE_DATE_MONTHLY.VALUE_TABLE_RECID 
            AND MAINTENANCE_DATE_MONTHLY.VALUE_TABLE_NAME = 'EQUIPMENT' AND MAINTENANCE_DATE_MONTHLY.IDENTIFIER = 'MAINTENANCE_DATE_MONTHLY'
        LEFT JOIN V_UDF MAINTENANCE_DATE_WEEKLY 
            ON E.RECID = MAINTENANCE_DATE_WEEKLY.VALUE_TABLE_RECID 
            AND MAINTENANCE_DATE_WEEKLY.VALUE_TABLE_NAME = 'EQUIPMENT' AND MAINTENANCE_DATE_WEEKLY.IDENTIFIER = 'MAINTENANCE_DATE_WEEKLY'
    
        LEFT JOIN V_UDF MAINTENANCE_PERIOD_QTY_ANNUAL 
            ON EC.RECID = MAINTENANCE_PERIOD_QTY_ANNUAL.VALUE_TABLE_RECID 
            AND MAINTENANCE_PERIOD_QTY_ANNUAL.VALUE_TABLE_NAME = 'EQP_CATALOG' AND MAINTENANCE_PERIOD_QTY_ANNUAL.IDENTIFIER = 'MAINTENANCE_PERIOD_QTY_ANNUAL'
        LEFT JOIN V_UDF MAINTENANCE_PERIOD_QTY_SEMIANNUAL 
            ON EC.RECID = MAINTENANCE_PERIOD_QTY_SEMIANNUAL.VALUE_TABLE_RECID 
            AND MAINTENANCE_PERIOD_QTY_SEMIANNUAL.VALUE_TABLE_NAME = 'EQP_CATALOG' AND MAINTENANCE_PERIOD_QTY_SEMIANNUAL.IDENTIFIER = 'MAINTENANCE_PERIOD_QTY_SEMIANNUAL'
        LEFT JOIN V_UDF MAINTENANCE_PERIOD_QTY_QUARTERLY 
            ON EC.RECID = MAINTENANCE_PERIOD_QTY_QUARTERLY.VALUE_TABLE_RECID 
            AND MAINTENANCE_PERIOD_QTY_QUARTERLY.VALUE_TABLE_NAME = 'EQP_CATALOG' AND MAINTENANCE_PERIOD_QTY_QUARTERLY.IDENTIFIER = 'MAINTENANCE_PERIOD_QTY_QUARTERLY'
        LEFT JOIN V_UDF MAINTENANCE_PERIOD_QTY_MONTHLY 
            ON EC.RECID = MAINTENANCE_PERIOD_QTY_MONTHLY.VALUE_TABLE_RECID 
            AND MAINTENANCE_PERIOD_QTY_MONTHLY.VALUE_TABLE_NAME = 'EQP_CATALOG' AND MAINTENANCE_PERIOD_QTY_MONTHLY.IDENTIFIER = 'MAINTENANCE_PERIOD_QTY_MONTHLY'
        LEFT JOIN V_UDF MAINTENANCE_PERIOD_QTY_WEEKLY 
            ON EC.RECID = MAINTENANCE_PERIOD_QTY_WEEKLY.VALUE_TABLE_RECID 
            AND MAINTENANCE_PERIOD_QTY_WEEKLY.VALUE_TABLE_NAME = 'EQP_CATALOG' AND MAINTENANCE_PERIOD_QTY_WEEKLY.IDENTIFIER = 'MAINTENANCE_PERIOD_QTY_WEEKLY'
    
        WHERE 
    
        (MAINTENANCE_DATE_ANNUAL.VALUE IS NOT NULL
        OR MAINTENANCE_DATE_SEMIANNUAL.VALUE IS NOT NULL
        OR MAINTENANCE_DATE_QUARTERLY.VALUE IS NOT NULL
        OR MAINTENANCE_DATE_MONTHLY.VALUE IS NOT NULL
        OR MAINTENANCE_DATE_WEEKLY.VALUE IS NOT NULL)
        AND
        (MAINTENANCE_DATE_ANNUAL.VALUE = CURRENT_DATE
        OR MAINTENANCE_DATE_SEMIANNUAL.VALUE = CURRENT_DATE
        OR MAINTENANCE_DATE_QUARTERLY.VALUE = CURRENT_DATE
        OR MAINTENANCE_DATE_MONTHLY.VALUE = CURRENT_DATE
        OR MAINTENANCE_DATE_WEEKLY.VALUE = CURRENT_DATE)
        ;
    SQL
    );
    
    $dateTypes = [
        'ANNUAL'     => 'P1Y',
        'SEMIANNUAL' => 'P6M',
        'QUARTERLY'  => 'P3M',
        'MONTHLY'    => 'P1M',
        'WEEKLY'     => 'P1W'
    ];
    $now = new DateTime();
    $now->setTime(0,0);
    
    foreach($eqp as $equipment){
    
        $incident = [
            'type' => 'IN',
            'csr' => '1',
            'owner' => $equipment['OWNER_CONTACTS_RECID'] ? $equipment['OWNER_CONTACTS_RECID'] : $equipment['OWNER_DEPT_HIERARCHY_RECID'],
            'owner_type' => $equipment['OWNER_CONTACTS_RECID'] ? 'contact' : 'department',
            'description' => 'Scheduled Maintenance',
            'prob_code' => 3,
            'equipment' => $equipment['RECID']
        ];
    
        foreach($dateTypes as $dateType => $dateInterval){
            $maintenanceDate = new DateTime($equipment["MAINTENANCE_DATE_{$dateType}"]);
    
            if($maintenanceDate == $now) {
                $incident['description'] = $equipment["MAINTENANCE_DATE_{$dateType}_DESC"];
    
                $result = $this->call('saveServiceDesk', $incident);
                $interval = new DateInterval($dateInterval);
    
                for($qty = 1; $qty <= $equipment["MAINTENANCE_PERIOD_QTY_{$dateType}"]; $qty++){
                    $maintenanceDate->add($interval);
                }
    
                $result = $this->call('saveEquipment', [
                    'type' => 'UDFS',
                    'equipment_recid' => $equipment['RECID'],
                    "udf_MAINTENANCE_DATE_{$dateType}" => $maintenanceDate->format('Y-m-d')
                ]);
            }
        }
    }
  7. Click the 'Save New' button.


    Now that initial data set up is finished, simply find the Equipment Catalog from step 1 and enter information into the two UDFs setup in steps 1 and 2, Maintenance Period and Maintenance Period Quantity respectively. The Quantity should represent how many periods should pass before triggering the event. For example, to set a maintenance period every 3 months, set the Quantity to "3". Next, open the Equipment record and set the Maintenance Period Date UDF to the next Maintenance Date.

    The Custom Event will now automatically run in the background. When the Custom Event runs, a new Incident for each Equipment with a Maintenance Date that matches the current date will be created and then the Maintenance Date will be set to the next interval period. These Incidents can then be worked normally to accomplish the regularly scheduled maintenance tasks.

Service Alias Range

The Service Alias Range Generation Event can be triggered using Custom Logic. The following parameters are Required to execute the Event.

Service Alias Range Generation
/**
* Event: Alias range generation requested
* Listener Class: Application_Model_Service_ServicesAlias
* Listener Method: eventGenerateAliasRange
*/


PCR_Event::attachDb(
    "generate-alias",
    ["Application_Model_Service_ServicesAlias" => "eventGenerateAliasRange"]
);
PCR_Event::trigger(
    "generate-alias",    
	[ 		
		"SAVE_PARAMS" =>
		[
			"pn_start" => "5863820670", 		//Start of Alias range
			"pn_finish" => "5863820679", 		//End of Alias range 
			"RECID" => "addNew",
			"save-new" => "true",
			"generateNum" => 4,
			"contact" => "216121" 				//RecID of Contact that initiated the Alias generation 
		],
		"FORM_FIELD_KEY" =>
		[
			"SERVICES_ALIAS" =>
			[
				"TENANTS_RECID" => "TENANTS_RECID"
			],
			"RECID" => "RECID"
		]

		"eventBroadcastBy" => "216121",
		"eventBroadcastTime" => "Oct 4, 2022, 10:41 am",
		"eventBroadcastDayofWeek" => "2",
		"eventBroadcastHourMin" => "1041",
	]  
);

Service Bulk Update

The Service Desk Bulk Update Event can be triggered using Custom Logic. The following parameters are Required to execute the Event.

Service Desk Bulk Update
/**
* Event: Service Desk Bulk Update requested
* Listener Class: Servicedesk_Model_ServiceDesk
* Listener Method: eventBulkUpdate
*/  

PCR_Event::attachDb(
    "bulk-update",
    ["Servicedesk_Model_ServiceDesk" => "eventBulkUpdate"]
);
PCR_Event::trigger(
    "bulk-update", 
	[ 		
		"due_date_enabled" => "0",
		"sd_type_enabled" => "0",
		"sd_status_enabled" => "0",
		"csr_enabled" => "0",
		"contact_owner_enabled" => "0",
		"dept_hier_owner_enabled" => "0",
		"requestor_enabled" => "0",
		"sd_source_enabled" => "0",
		"assoc_proj_enabled" => "0",
		"impact_enabled" => "1",
		"impact" => "132",
		"urgency_enabled" => "1",
		"urgency" => "321",
		"RECID" => "25196",
		"dialogCallback" => true,
		"confirmed" => true,
		"comment" => "This is a comment",
		"users_recid" => "1217",
		"contact" => "216121",
		"cronEvent" => true,
		"selectedServiceDeskRecids" =>
		[
			"25196", //RecID of Service Desk record getting updated
			"25195" //RecID of Service Desk record getting updated
		],
		"selectedServiceDeskFilters" => [],

		"eventBroadcastBy" => "216121",
		"eventBroadcastTime" => "Oct 3, 2022, 3:19 pm",
		"eventBroadcastDayofWeek" => "1",
		"eventBroadcastHourMin" => "1519",  	
	]
);

Service Desk Bulk Update

The Service Desk Bulk Update Event can be triggered using Custom Logic. The following parameters are Required to execute the Event.

Service Desk Bulk Update
/**
* Event: Service Desk Bulk Update requested
* Listener Class: Servicedesk_Model_ServiceDesk
* Listener Method: eventBulkUpdate
*/  

PCR_Event::attachDb(
    "bulk-update",
    ["Servicedesk_Model_ServiceDesk" => "eventBulkUpdate"]
);
PCR_Event::trigger(
    "bulk-update", 
	[ 		
		"due_date_enabled" => "0",
		"sd_type_enabled" => "0",
		"sd_status_enabled" => "0",
		"csr_enabled" => "0",
		"contact_owner_enabled" => "0",
		"dept_hier_owner_enabled" => "0",
		"requestor_enabled" => "0",
		"sd_source_enabled" => "0",
		"assoc_proj_enabled" => "0",
		"impact_enabled" => "1",
		"impact" => "132",
		"urgency_enabled" => "1",
		"urgency" => "321",
		"RECID" => "25196",
		"dialogCallback" => true,
		"confirmed" => true,
		"comment" => "This is a comment",
		"users_recid" => "1217",
		"contact" => "216121",
		"cronEvent" => true,
		"selectedServiceDeskRecids" =>
		[
			"25196", //RecID of Service Desk record getting updated
			"25195" //RecID of Service Desk record getting updated
		],
		"selectedServiceDeskFilters" => [],

		"eventBroadcastBy" => "216121",
		"eventBroadcastTime" => "Oct 3, 2022, 3:19 pm",
		"eventBroadcastDayofWeek" => "1",
		"eventBroadcastHourMin" => "1519",  	
	]
);

Warehouse Bulk Add Equipment

Unable to render {include} The included page could not be found.

Warehouse Bulk Transfer

Unable to render {include} The included page could not be found.

Zero/Low Calls Report

The Zero/Low Calls Report Event can be triggered using Custom Logic. The following parameters are Required to execute the Event.

Zero/Low Calls Report
/**
* Event: Zero/Low Calls Report
* Listener Class: Application_Model_CallDetails_CallDetails
* Listener Method: eventZeroCallsReport
*/

PCR_Event::attachDb(
    "zero-calls-report",
    ["Application_Model_CallDetails_CallDetails" => "eventZeroCallsReport"]
);
PCR_Event::trigger(
    "zero-calls-report", 
	[ 		
		"date_range" => "Last 30 Days", 		//Value entered in Date Range
		"service_host" => "22", 				//RecID of Service Host
		"call_count" => "10",
		"duration" => "30",
	 	"email" => "test@test.com",				//Optional field
		"service_host_display" => "Avaya", 		//Name of Service Host
		"dateRange" => 
		[
			1662177600, //Not sure what these numbers represent? Hopefully a Dev will know!
			1664769600
		],

		"eventBroadcastBy" => "216121",
		"eventBroadcastTime" => "Oct 3, 2022, 2 => 50 pm",
		"eventBroadcastDayofWeek" => "1",
		"eventBroadcastHourMin" => "1450",  	
	]
);

  • No labels