Ejemplo n.º 1
0
 /**
  * Returns an associative array with 4 rows of either the last 4 weeks or 4 months 
  * statistics on submitted, interviewing, and placed candidates.
  *
  * @param integer pipeline view indentifier
  * @return array pipeline graph data
  */
 public function getPipelineData($view)
 {
     $oneUnixDay = 86400;
     $calendarSettings = new CalendarSettings($this->_siteID);
     $calendarSettingsRS = $calendarSettings->getAll();
     if ($calendarSettingsRS['firstDayMonday'] == 1) {
         $firstDayMonday = true;
         $firstDayModifierPlus = ' + 1';
         $dateNowForWeeks = 'DATE_SUB(NOW(), INTERVAL 1 DAY)';
         $dateEventForWeeks = 'DATE_SUB(candidate_joborder_status_history.date, INTERVAL 1 DAY)';
     } else {
         $firstDayMonday = false;
         $firstDayModifierPlus = '';
         $firstDayModifierMinus = '';
         $dateNowForWeeks = 'NOW()';
         $dateEventForWeeks = 'candidate_joborder_status_history.date';
     }
     switch ($view) {
         case DASHBOARD_GRAPH_YEARLY:
             $select = 'YEAR(candidate_joborder_status_history.date) as unixdate';
             break;
         case DASHBOARD_GRAPH_MONTHLY:
             $select = 'UNIX_TIMESTAMP(FROM_DAYS(TO_DAYS(candidate_joborder_status_history.date) - DAYOFMONTH(candidate_joborder_status_history.date) + 1)) as unixdate';
             break;
         case DASHBOARD_GRAPH_WEEKLY:
         default:
             $select = 'UNIX_TIMESTAMP(FROM_DAYS(TO_DAYS(' . $dateEventForWeeks . ') - DAYOFWEEK(' . $dateEventForWeeks . ') + 1 ' . $firstDayModifierPlus . ')) as unixdate';
             break;
     }
     /* This SQL query either returns 1 row per week or 1 row per month for the total 
      * count of sub, int, and pla status changes in the system.
      */
     /* Limit 20 because if time was skewed, there may be events in the future that
      * the PHP function will throw out, but future events will prevent past events
      * from loading properly.  We don't need a limit at all, but limiting 20 results 
      * back should guarantee we will always at least get the relavant rows we want.
      */
     $sql = sprintf("SELECT\n                %s,\n                SUM(IF(candidate_joborder_status_history.status_to = %s, 1, 0)) AS submitted,\n                SUM(IF(candidate_joborder_status_history.status_to = %s, 1, 0)) AS interviewing,\n                SUM(IF(candidate_joborder_status_history.status_to = %s, 1, 0)) AS placed\n            FROM\n                candidate_joborder_status_history\n            WHERE\n                candidate_joborder_status_history.site_id = %s\n            GROUP BY unixdate\n            ORDER BY unixdate DESC\n            LIMIT 20\n            ", $select, PIPELINE_STATUS_SUBMITTED, PIPELINE_STATUS_INTERVIEWING, PIPELINE_STATUS_PLACED, $this->_siteID);
     $rs = $this->_db->getAllAssoc($sql);
     /* Gets some numbers as to what week and month MySQL thinks it is. */
     $sql = sprintf("SELECT \n                YEAR(NOW()) as currentYearNumber,\n                UNIX_TIMESTAMP(FROM_DAYS(TO_DAYS(%s) - DAYOFWEEK(%s) + 1 %s)) as currentWeekNumber,\n                UNIX_TIMESTAMP(FROM_DAYS(TO_DAYS(DATE_SUB(%s, INTERVAL 7 DAY)) - DAYOFWEEK(DATE_SUB(%s, INTERVAL 7 DAY)) + 1 %s)) as oneWeekAgoNumber,\n                UNIX_TIMESTAMP(FROM_DAYS(TO_DAYS(DATE_SUB(%s, INTERVAL 14 DAY)) - DAYOFWEEK(DATE_SUB(%s, INTERVAL 14 DAY)) + 1 %s)) as twoWeekAgoNumber,\n                UNIX_TIMESTAMP(FROM_DAYS(TO_DAYS(DATE_SUB(%s, INTERVAL 21 DAY)) - DAYOFWEEK(DATE_SUB(%s, INTERVAL 21 DAY)) + 1 %s)) as threeWeekAgoNumber,\n                UNIX_TIMESTAMP(FROM_DAYS(TO_DAYS(NOW()) - DAYOFMONTH(NOW()) + 1)) as currentMonthNumber,\n                UNIX_TIMESTAMP(FROM_DAYS(TO_DAYS(DATE_SUB(NOW(), INTERVAL 1 MONTH)) - DAYOFMONTH(DATE_SUB(NOW(), INTERVAL 1 MONTH)) + 1)) as oneMonthAgoNumber,\n                UNIX_TIMESTAMP(FROM_DAYS(TO_DAYS(DATE_SUB(NOW(), INTERVAL 2 MONTH)) - DAYOFMONTH(DATE_SUB(NOW(), INTERVAL 2 MONTH)) + 1)) as twoMonthAgoNumber,\n                UNIX_TIMESTAMP(FROM_DAYS(TO_DAYS(DATE_SUB(NOW(), INTERVAL 3 MONTH)) - DAYOFMONTH(DATE_SUB(NOW(), INTERVAL 3 MONTH)) + 1)) as threeMonthAgoNumber,\n                MONTHNAME(NOW()) as currentMonthName,\n                MONTHNAME(DATE_SUB(NOW(), INTERVAL 1 MONTH)) as oneMonthAgoName,\n                MONTHNAME(DATE_SUB(NOW(), INTERVAL 2 MONTH)) as twoMonthAgoName,\n                MONTHNAME(DATE_SUB(NOW(), INTERVAL 3 MONTH)) as threeMonthAgoName\n            ", $dateNowForWeeks, $dateNowForWeeks, $firstDayModifierPlus, $dateNowForWeeks, $dateNowForWeeks, $firstDayModifierPlus, $dateNowForWeeks, $dateNowForWeeks, $firstDayModifierPlus, $dateNowForWeeks, $dateNowForWeeks, $firstDayModifierPlus);
     $rsCurrentTime = $this->_db->getAssoc($sql);
     $data = array();
     switch ($view) {
         case DASHBOARD_GRAPH_YEARLY:
             $data[$rsCurrentTime['currentYearNumber']] = array('label' => $rsCurrentTime['currentYearNumber']);
             $data[$rsCurrentTime['currentYearNumber'] - 1] = array('label' => $rsCurrentTime['currentYearNumber'] - 1);
             $data[$rsCurrentTime['currentYearNumber'] - 2] = array('label' => $rsCurrentTime['currentYearNumber'] - 2);
             $data[$rsCurrentTime['currentYearNumber'] - 3] = array('label' => $rsCurrentTime['currentYearNumber'] - 3);
             break;
         case DASHBOARD_GRAPH_MONTHLY:
             $data[$rsCurrentTime['currentMonthNumber']] = array('label' => $rsCurrentTime['currentMonthName']);
             $data[$rsCurrentTime['oneMonthAgoNumber']] = array('label' => $rsCurrentTime['oneMonthAgoName']);
             $data[$rsCurrentTime['twoMonthAgoNumber']] = array('label' => $rsCurrentTime['twoMonthAgoName']);
             $data[$rsCurrentTime['threeMonthAgoNumber']] = array('label' => $rsCurrentTime['threeMonthAgoName']);
             break;
         case DASHBOARD_GRAPH_WEEKLY:
         default:
             // TODO:   Localization d/m, week starts on monday
             if ($_SESSION['CATS']->isDateDMY()) {
                 $pattern = "d/m";
             } else {
                 $pattern = "m/d";
             }
             /* * 6 at the end gives us the last day in the week (first day in week plus 6 days) */
             $data[$rsCurrentTime['currentWeekNumber']] = array('label' => date($pattern, $rsCurrentTime['currentWeekNumber']) . ' - ' . date($pattern, $rsCurrentTime['currentWeekNumber'] + $oneUnixDay * 6));
             $data[$rsCurrentTime['oneWeekAgoNumber']] = array('label' => date($pattern, $rsCurrentTime['oneWeekAgoNumber']) . ' - ' . date($pattern, $rsCurrentTime['oneWeekAgoNumber'] + $oneUnixDay * 6));
             $data[$rsCurrentTime['twoWeekAgoNumber']] = array('label' => date($pattern, $rsCurrentTime['twoWeekAgoNumber']) . ' - ' . date($pattern, $rsCurrentTime['twoWeekAgoNumber'] + $oneUnixDay * 6));
             $data[$rsCurrentTime['threeWeekAgoNumber']] = array('label' => date($pattern, $rsCurrentTime['threeWeekAgoNumber']) . ' - ' . date($pattern, $rsCurrentTime['threeWeekAgoNumber'] + $oneUnixDay * 6));
             break;
     }
     /* Fill the array with data. */
     foreach ($data as $indexData => $rowData) {
         $data[$indexData]['submitted'] = 0;
         $data[$indexData]['interviewing'] = 0;
         $data[$indexData]['placed'] = 0;
         foreach ($rs as $indexRS => $rowRS) {
             if ($rowRS['unixdate'] == $indexData) {
                 $data[$indexData]['submitted'] = $rowRS['submitted'];
                 $data[$indexData]['interviewing'] = $rowRS['interviewing'];
                 $data[$indexData]['placed'] = $rowRS['placed'];
             }
         }
     }
     ksort($data, SORT_NUMERIC);
     return $data;
 }
Ejemplo n.º 2
0
 private function onCustomizeCalendar()
 {
     if ($this->_realAccessLevel < ACCESS_LEVEL_SA) {
         CommonErrors::fatal(COMMONERROR_PERMISSION, $this);
         return;
         //$this->fatal(ERROR_NO_PERMISSION);
     }
     $calendarSettings = new CalendarSettings($this->_siteID);
     $calendarSettingsRS = $calendarSettings->getAll();
     foreach ($calendarSettingsRS as $setting => $value) {
         if ($setting == 'noAjax' || $setting == 'defaultPublic' || $setting == 'firstDayMonday') {
             if ($this->isChecked($setting, $_POST)) {
                 $calendarSettings->set($setting, '1');
             } else {
                 $calendarSettings->set($setting, '0');
             }
         } else {
             if (isset($_POST[$setting])) {
                 $calendarSettings->set($setting, $_POST[$setting]);
             }
         }
     }
     $this->_template->assign('active', $this);
     CATSUtility::transferRelativeURI('m=settings&a=administration');
 }
Ejemplo n.º 3
0
    public function showCalendar()
    {
        $currentHour     = DateUtility::getAdjustedDate('H');
        $currentDay      = DateUtility::getAdjustedDate('j');
        $currentMonth    = DateUtility::getAdjustedDate('n');
        $currentYear     = DateUtility::getAdjustedDate('Y');
        $currentUnixTime = DateUtility::getAdjustedDate();
        $currentDateMDY  = DateUtility::getAdjustedDate('m-d-y');

        $currentWeek  = DateUtility::getWeekNumber($currentUnixTime) - DateUtility::getWeekNumber(
            mktime(0, 0, 0, $currentMonth, 1, $currentYear)
        );

        /* Do we have a valid date argument? If a month was specified and
         * isn't valid, fatal() out. If none was specified, use the current
         * month.
         */
        if ($this->isRequiredIDValid('month', $_GET) &&
            $this->isRequiredIDValid('year', $_GET))
        {
            $month = $_GET['month'];
            $year  = $_GET['year'];

            if (!checkdate($month, 1, $year))
            {
                CommonErrors::fatal(COMMONERROR_BADFIELDS, $this, 'Invalid date.');
            }

            if ($month == $currentMonth && $year == $currentYear)
            {
                $isCurrentMonth = true;
            }
            else
            {
                $isCurrentMonth = false;
            }
        }
        else
        {
            $month = $currentMonth;
            $year  = $currentYear;
            $isCurrentMonth = true;
        }

        if (isset($_GET['view']))
        {
            $view = $_GET['view'];
        }
        else
        {
            $view = 'DEFAULT_VIEW';
        }

        if (isset($_GET['week']))
        {
            $week = $_GET['week'];
        }
        else
        {
            $week = $currentWeek+1;
        }

        if (isset($_GET['day']))
        {
            $day = $_GET['day'];
        }
        else
        {
            $day = $currentDay;
        }

        if (isset($_GET['showEvent']))
        {
            $showEvent = $_GET['showEvent'];
        }
        else
        {
            $showEvent = null;
        }

        $userIsSuperUser = ($this->_accessLevel < ACCESS_LEVEL_SA ? 0 : 1);
        if ($userIsSuperUser && isset($_GET['superuser']) && $_GET['superuser'] == 1)
        {
            $superUserActive = true;
        }
        else
        {
            $superUserActive = false;
        }

        $startingWeekday = DateUtility::getStartingWeekday($month, $year);
        $daysInMonth     = DateUtility::getDaysInMonth($month, $year);

        $calendar = new Calendar($this->_siteID);

        $monthBefore = $month - 1;
        $monthAfter  = $month + 1;
        $yearBefore  = $year;
        $yearAfter   = $year;

        if ($monthAfter > 12)
        {
            $monthAfter = 1;
            $yearAfter = $year + 1;
        }

        if ($monthBefore < 1)
        {
            $monthBefore = 12;
            $yearBefore = $year - 1;
        }

        $eventsStringNow = $calendar->makeEventString(
            $calendar->getEventArray($month, $year),
            $month,
            $year
        );

        $eventsStringBefore = $calendar->makeEventString(
            $calendar->getEventArray($monthBefore, $yearBefore),
            $monthBefore,
            $yearBefore
        );

        $eventsStringAfter = $calendar->makeEventString(
            $calendar->getEventArray($monthAfter, $yearAfter),
            $monthAfter,
            $yearAfter
        );

        $eventsString = implode(
            '@',
            array($eventsStringNow, $eventsStringBefore, $eventsStringAfter, $userIsSuperUser)
        );

        /* Textual representation of the month and year. */
        $dateString = date(
            'F Y',
            mktime($_SESSION['CATS']->getTimeZoneOffset(), 0, 0, $month, 1, $year)
        );

        /* The offset is the number of days after the first Sunday on a given
         * calendar page on which the 1st of the month falls. We subtract 1
         * because Sunday has a value of 1.
         */
        $startingOffset = $startingWeekday - 1;

        $userEmail = $_SESSION['CATS']->getEmail();

        $calendarEventTypes = $calendar->getAllEventTypes();

        $calendarSettings = new CalendarSettings($this->_siteID);
        $calendarSettingsRS = $calendarSettings->getAll();

        if ($view == 'DEFAULT_VIEW')
        {
            $view = $calendarSettingsRS['calendarView'];
        }

        $summaryHTML = $calendar->getUpcomingEventsHTML(12, UPCOMING_FOR_CALENDAR);

        if (!eval(Hooks::get('CALENDAR_SHOW'))) return;

        if (SystemUtility::isSchedulerEnabled() && !$_SESSION['CATS']->isDemo())
        {
            $allowEventReminders = true;
        }
        else
        {
            $allowEventReminders = false;
        }

        /* FIXME: Configurable */
        $this->_template->assign('dayHourStart', $calendarSettingsRS['dayStart']);
        $this->_template->assign('dayHourEnd', $calendarSettingsRS['dayStop']);
        $this->_template->assign('firstDayMonday', $calendarSettingsRS['firstDayMonday']);
        $this->_template->assign('allowAjax', ($calendarSettingsRS['noAjax'] == 0 ? true : false));
        $this->_template->assign('defaultPublic', ($calendarSettingsRS['defaultPublic'] == 0 ? 'false' : 'true'));
        $this->_template->assign('militaryTime', false);

        $this->_template->assign('active', $this);
        $this->_template->assign('currentDateMDY', $currentDateMDY);
        $this->_template->assign('startingWeekday', $startingWeekday);
        $this->_template->assign('daysInMonth', $daysInMonth);
        $this->_template->assign('currentHour', $currentHour);
        $this->_template->assign('currentDay', $currentDay);
        $this->_template->assign('currentMonth', $currentMonth);
        $this->_template->assign('currentYear', $currentYear);
        $this->_template->assign('startingOffset', $startingOffset);
        $this->_template->assign('userEmail', $userEmail);
        $this->_template->assign('userID', $this->_userID);
        $this->_template->assign('userEmail', $_SESSION['CATS']->getEmail());
        $this->_template->assign('summaryHTML', $summaryHTML);
        $this->_template->assign('userIsSuperUser', $userIsSuperUser);
        $this->_template->assign('superUserActive', $superUserActive);
        $this->_template->assign('calendarEventTypes', $calendarEventTypes);
        $this->_template->assign('view', $view);
        $this->_template->assign('day', $day);
        $this->_template->assign('week', $week);
        $this->_template->assign('month', $month);
        $this->_template->assign('year', $year);
        $this->_template->assign('showEvent', $showEvent);
        $this->_template->assign('dateString', $dateString);
        $this->_template->assign('isCurrentMonth', $isCurrentMonth);
        $this->_template->assign('eventsString', $eventsString);
        $this->_template->assign('allowEventReminders', $allowEventReminders);
        $this->_template->display('./modules/calendar/Calendar.php');
    }