Deactivate Invalid GLAs
PHP
/**
* Event: Custom PHP Event
* Frequency: Daily
* Time: 12:00am
* Listener Class: Core_Model_Event
* Listener Method: eventCustom
*/
// query for active GLAs containing any inactive components
$glas = $this->query(<<<SQL
SELECT
g.RECID
FROM GLA g
INNER JOIN GLA_COMBINATION gc ON g.RECID = gc.RECID
INNER JOIN GLA_COMPONENTS C on gc.ITEM_1 = C.RECID
INNER JOIN GLA_COMPONENTS C2 on gc.ITEM_2 = C2.RECID
LEFT JOIN GLA_COMPONENTS C3 on gc.ITEM_3 = C3.RECID
WHERE
g.STATUS = 1
AND (
C.STATUS = 0
OR C2.STATUS = 0
OR (
C3.STATUS = 0
AND C3.RECID IS NOT NULL
)
);
SQL
);
foreach ($glas as $gla) {
$results["deactivateGla"][] = $gla['RECID'];
}
$results["activateGla"] = [];
// RECID for PCR user USCS
$results["users_recid"] = 55;
// create an event to update the GLA status and trigger it with the prepared query results
if (!empty($results["deactivateGla"])) {
PCR_Event::attachDb("gla-status", [
"Application_Model_Gla_Gla" => "eventGlaStatus"
]);
PCR_Event::trigger("gla-status", $results);
}