<?php
/****************************************************************************************************
    *	cronUserNotificationDerivation.php
    *	Class for execute the cron of "UserNotificationDerivation"
    *
    *	Created by Ronald Nina
    *	ronald.nina@processmaker.com
****************************************************************************************************/

class cronSendNotificationDerivationClassCron
{
    public function executeCron()
    {
        try {
            G::loadClass('pmFunctions');
            if (SYS_SYS == 'workflow' || SYS_SYS == 'fassil') {
                require_once PATH_PLUGINS . 'psFassilManagement/classes/class.cronSendNotificationDerivation.php';
                $initTime = date('Y-m-d H:i:s');
                $pathCron = PATH_CORE . 'bin' . PATH_SEP . 'plugins' . PATH_SEP . 'cronSendNotificationDerivation.php';
                echo "\n";
                eprintln("--- Initiating cron 'Task 5 Fassil' " . $initTime, 'green');

                $sqlScontrol = "SELECT *
                            FROM PLUGINS_REGISTRY
                            WHERE PLUGIN_CLASS_NAME = 'psFassilManagementPlugin'
                            ";
                $resScontrol = executeQuery($sqlScontrol);
                $resScontrol = array_shift($resScontrol);
                if ($resScontrol['PLUGIN_ENABLE'] == 1) {
                    $cCronSendNotificationDerivation = new cronSendNotificationDerivation();
                    $cCronSendNotificationDerivation->searchCases();

                    $endTime = date('Y-m-d H:i:s');
                    eprintln('--- The cron file: ' . $pathCron . ' has been executed succesfully ' . $endTime, 'green');
                } else {
                    eprintln('--- The plugin psFassilManagementPlugin is disabled', 'red');
                }
            }
        } catch (Exception $e) {
            return $e->getMessage();
        }
    }
}

// $cronSendNotification = new cronSendNotificationDerivationClassCron();
// $cronSendNotification->executeCron();
