/**
  * @param string $data The job data set for this particular Scheduled Job instance
  * @return boolean true if the run succeeded; false otherwise
  */
 public function run($data)
 {
     /* @var $admin Administration */
     $admin = BeanFactory::getBean('Administration');
     $settings = $admin->getConfigForModule('Forecasts');
     if ($settings['is_setup'] == false) {
         $GLOBALS['log']->fatal("Forecast Module is not setup. " . __CLASS__ . " should not be running");
         return false;
     }
     $args = json_decode(html_entity_decode($data), true);
     $this->job->runnable_ran = true;
     // use the processWorksheetDataChunk to run the code.
     ForecastWorksheet::processWorksheetDataChunk($args['forecast_by'], $args['data']);
     $this->job->succeedJob();
     return true;
 }
 /**
  * @param ForecastWorksheet $bean
  * @param string $event
  * @param array $args
  * @return bool
  */
 public static function managerNotifyCommitStage($bean, $event, $args)
 {
     /**
      * Always Return false for now as notifications are not setup.
      */
     return false;
     /**
      * Only run this logic hook when the following conditions are met
      *  - Bean is not a Draft Record
      *  - Bean is not a new Record
      *  - Forecast is Setup
      */
     if ($bean->draft === 0 && !empty($bean->fetched_row) && static::isForecastSetup()) {
         $forecast_by = self::$settings['forecast_by'];
         // make sure we have a bean of the one that we are forecasting by
         // and it's fetched_row commit_stage is equal to `include`
         // and it's updated commit_stage does not equal `include`
         if ($bean->parent_type === $forecast_by && $bean->fetched_row['commit_stage'] === 'include' && $bean->commit_stage !== 'include') {
             // send a notification to their manager if they have a manager
             /* @var $user User */
             $bean->load_relationship('assigned_user_link');
             $user = array_shift($bean->assigned_user_link->getBeans());
             if (!empty($user->reports_to_id)) {
                 $worksheet_strings = static::getLanguageStrings($bean->module_name);
                 $mod_strings = static::getLanguageStrings($bean->parent_type);
                 $notifyBean = static::getNotificationBean();
                 $notifyBean->assigned_user_id = $user->reports_to_id;
                 $notifyBean->type = 'information';
                 $notifyBean->created_by = $user->id;
                 $notifyBean->name = string_format($worksheet_strings['LBL_MANAGER_NOTIFY'], array($mod_strings['LBL_MODULE_NAME_SINGULAR'], $bean->name));
                 $notifyBean->save();
                 return true;
             }
         }
     }
     return false;
 }
 $fromuser = $_SESSION['reassignRecords']['fromuser'];
 $touser = $_SESSION['reassignRecords']['touser'];
 $fromusername = $_SESSION['reassignRecords']['fromusername'];
 $tousername = $_SESSION['reassignRecords']['tousername'];
 $toteam = $_SESSION['reassignRecords']['toteam'];
 $toteamsetid = $_SESSION['reassignRecords']['toteamsetid'];
 $toteamname = $_SESSION['reassignRecords']['toteamname'];
 //$beanListFlip = array_flip($_SESSION['reassignRecords']['assignedModuleListCache']);
 foreach ($_SESSION['reassignRecords']['modules'] as $module => $queries) {
     $moduleLabel = isset($app_list_strings['moduleList'][$module]) ? $app_list_strings['moduleList'][$module] : $module;
     $workflow = isset($_POST[$module . "_workflow"]) && ($_POST[$module . "_workflow"] = "on");
     $query = $workflow ? $queries['query'] : $queries['update'];
     echo "<h5>{$mod_strings_users['LBL_PROCESSING']} {$moduleLabel}</h5>";
     // nutmeg sfa-219 : Fix reassignment of records when user set to Inactive
     if ($module == 'ForecastWorksheets') {
         $affected_rows = ForecastWorksheet::reassignForecast($fromuser, $touser);
         echo "{$mod_strings_users['LBL_UPDATE_FINISH']}: {$affected_rows} {$mod_strings_users['LBL_AFFECTED']}<BR>\n";
         continue;
     } else {
         $res = $db->query($query, true);
         $affected_rows = $db->getAffectedRowCount($res);
     }
     //echo "<i>Workflow and Notifications <b>".($workflow ? "enabled" : "disabled")."</b> for this module record reassignment</i>\n<BR>\n";
     echo "<table border='0' cellspacing='0' cellpadding='0'  class='detail view'>\n";
     echo "<tr>\n";
     echo "<td>\n";
     if (!$workflow) {
         echo "{$mod_strings_users['LBL_UPDATE_FINISH']}: {$affected_rows} {$mod_strings_users['LBL_AFFECTED']}<BR>\n";
     } else {
         $successarr = array();
         $failarr = array();