当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Report_Form::beginPostProcess方法代码示例

本文整理汇总了PHP中CRM_Report_Form::beginPostProcess方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Report_Form::beginPostProcess方法的具体用法?PHP CRM_Report_Form::beginPostProcess怎么用?PHP CRM_Report_Form::beginPostProcess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Report_Form的用法示例。


在下文中一共展示了CRM_Report_Form::beginPostProcess方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postProcess

 function postProcess()
 {
     $this->buildACLClause(array('cac'));
     parent::beginPostProcess();
     $activityStatus = array_flip($this->activityStatus);
     $statusCSSStyle = array($activityStatus['Scheduled'] => 'font-style:italic;', $activityStatus['Completed'] => 'font-weight:bold;', $activityStatus['Cancelled'] => 'text-decoration:line-through;', $activityStatus['Rejected'] => 'text-decoration:line-through;');
     $absenceCalendar = $monthDays = $statistics = $legend = array();
     $validSourceRecordIds = null;
     $viewLinks = FALSE;
     $activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'Absence', 'name');
     list($durationFromDate, $durationToDate) = $this->getFromTo(CRM_Utils_Array::value("absence_date_relative", $this->_params), CRM_Utils_Array::value("absence_date_from", $this->_params), CRM_Utils_Array::value("absence_date_to", $this->_params));
     $sql = "\nFROM civicrm_activity\nWHERE source_record_id IS NOT NULL AND\nactivity_type_id = {$activityTypeID}\n";
     if ($durationFromDate && $durationToDate) {
         $sql = "SELECT source_record_id " . $sql;
         $sql .= "\n        GROUP BY source_record_id\n        HAVING ((to_days({$durationFromDate}) <= to_days(Min(activity_date_time))) AND\n        (to_days(Max(activity_date_time))  <= to_days({$durationToDate})))\n        ";
     } else {
         $sql = "SELECT Min(activity_date_time) as fromDate, Max(activity_date_time) as toDate" . $sql;
     }
     $dao = CRM_Core_DAO::executeQuery($sql);
     while ($dao->fetch()) {
         if (property_exists($dao, 'fromDate')) {
             $durationFromDate = CRM_Utils_Date::processDate($dao->fromDate);
             $durationToDate = CRM_Utils_Date::processDate($dao->toDate);
             $validSourceRecordIds = 'all';
         } else {
             $validSourceRecordIds[] = $dao->source_record_id;
         }
     }
     $durationYearCount = date('Y', strtotime($durationToDate)) - date('Y', strtotime($durationFromDate));
     for ($i = 0; $i <= $durationYearCount; $i++) {
         $startCount = 1;
         $endCount = 12;
         $startDay = $endDay = null;
         //if the end date's year is same as that of start dates's year
         if ($durationYearCount == 0) {
             $startCount = (int) date('m', strtotime($durationFromDate));
             $endCount = (int) date('m', strtotime($durationToDate));
         } elseif ($i == 0) {
             $startCount = (int) date('m', strtotime($durationFromDate));
             $endCount = 12;
         } elseif ($i == $durationYearCount) {
             $startCount = 1;
             $endCount = (int) date('m', strtotime($durationToDate));
         }
         for ($j = $startCount; $j <= $endCount; $j++) {
             $absenceCalendar[date('Y', strtotime($durationFromDate)) + $i][$j] = array('start_day' => 1, 'end_day' => date("t", mktime(0, 0, 0, $j, 1, date('Y', strtotime($durationFromDate)) + $i)), 'month_name' => date("F", mktime(0, 0, 0, $j, 10)));
         }
     }
     //assigning the start_day and end_day to corrosponding month in our absenceCalender array
     $absenceCalendar[date('Y', strtotime($durationFromDate))][(int) date('m', strtotime($durationFromDate))]['actual_start_day'] = (int) date('d', strtotime($durationFromDate));
     $absenceCalendar[date('Y', strtotime($durationToDate))][(int) date('m', strtotime($durationToDate))]['actual_end_day'] = (int) date('d', strtotime($durationToDate));
     foreach ($absenceCalendar as $key => $val) {
         krsort($val);
         $absenceCalendar[$key] = $val;
     }
     krsort($absenceCalendar);
     if (count($validSourceRecordIds) == 0 || !$validSourceRecordIds) {
         CRM_Core_Session::setStatus(ts("There is no absence record for chosen Absence Date range"), ts('No Result Found'));
         return;
     }
     $select = "SELECT\nYEAR(request.activity_date_time) as year,\nMONTH(request.activity_date_time) as month,\nDAY(request.activity_date_time) as day,\nabsence.id as aid,\nabsence.activity_type_id as ati,\nrequest.status_id status,\ncac.contact_id as contact_id,\nrequest.source_record_id,\ncc.sort_name as contact_name";
     $this->from();
     $this->where($validSourceRecordIds);
     $sql = "{$select} {$this->_from} {$this->_where}\nORDER BY YEAR(request.activity_date_time), MONTH(request.activity_date_time), cc.sort_name\n";
     $dao = CRM_Core_DAO::executeQuery($sql);
     if (CRM_Core_Permission::check('access CiviCRM')) {
         $viewLinks = TRUE;
         $onHover = ts('View Contact Summary for this Contact');
         $onHoverAct = ts('View Absence Record');
     }
     while ($dao->fetch()) {
         if (array_key_exists($dao->year, $absenceCalendar) && array_key_exists($dao->month, $absenceCalendar[$dao->year]) && $dao->day >= $absenceCalendar[$dao->year][$dao->month]['start_day'] && $dao->day <= $absenceCalendar[$dao->year][$dao->month]['end_day']) {
             if (array_key_exists('contacts', $absenceCalendar[$dao->year][$dao->month]) && array_key_exists($dao->contact_id, $absenceCalendar[$dao->year][$dao->month]['contacts']) && array_key_exists($dao->day, $absenceCalendar[$dao->year][$dao->month]['contacts'][$dao->contact_id]) && $absenceCalendar[$dao->year][$dao->month]['contacts'][$dao->contact_id][$dao->day]['activity_type_id'] != $dao->ati) {
                 $absenceCalendar[$dao->year][$dao->month]['contacts'][$dao->contact_id][$dao->day]['activity_type_id'] = 'Mixed';
             } else {
                 $absenceCalendar[$dao->year][$dao->month]['contacts'][$dao->contact_id][$dao->day]['activity_type_id'] = $dao->ati;
             }
             if ($viewLinks) {
                 $url = CRM_Utils_System::url("civicrm/contact/view", 'reset=1&cid=' . $dao->contact_id, $this->_absoluteUrl);
                 $absenceCalendar[$dao->year][$dao->month]['contacts'][$dao->contact_id]['link'] = "<a title='" . $onHover . "' href='" . $url . "' style='font-weight:bold;'>" . $dao->contact_name . "</a>";
             }
             if ($absenceCalendar[$dao->year][$dao->month]['contacts'][$dao->contact_id][$dao->day]['activity_type_id'] != 'Mixed') {
                 $dateUrl = CRM_Utils_System::url("civicrm/absence/set", 'reset=1&action=update&aid=' . $dao->aid, $this->_absoluteUrl);
                 $day_name = "<a title='" . $this->activityStatus[$dao->status] . "' href={$dateUrl} style='" . $statusCSSStyle[$dao->status] . "'>" . substr(date("D", mktime(0, 0, 0, $dao->month, $dao->day, $dao->year)), 0, -1) . "</a>";
             } else {
                 $day_name = substr(date("D", mktime(0, 0, 0, $dao->month, $dao->day, $dao->year)), 0, -1);
             }
             $absenceCalendar[$dao->year][$dao->month]['contacts'][$dao->contact_id][$dao->day]['day_name'] = $day_name;
         }
     }
     //remove those months from calendar report which don't have any absences
     foreach ($absenceCalendar as $year => $monthlyRecord) {
         foreach ($monthlyRecord as $month => $record) {
             if (!array_key_exists('contacts', $record)) {
                 unset($absenceCalendar[$year][$month]);
             }
         }
     }
     $this->modifyColumnHeaders();
     $this->doTemplateAssignment($absenceCalendar);
//.........这里部分代码省略.........
开发者ID:JoeMurray,项目名称:civihr,代码行数:101,代码来源:HRAbsenceCalendar.php


注:本文中的CRM_Report_Form::beginPostProcess方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。