Example #1
0
 function getTemplateFileName()
 {
     $profID = CRM_Utils_Request::retrieve('gid', 'String', $this);
     $this->_params['contact_type'] = 'Individual';
     $selector = new CRM_Profile_Selector_Listings($this->_params, $this->_customFields, $profID, $this->_map, FALSE, 0);
     $extraWhereClause = NULL;
     $grpParams = array('name' => 'HRJobContract_Summary');
     CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomGroup', $grpParams, $cGrp);
     $fdParams = array('name' => 'Final_Termination_Date', 'custom_group_id' => $cGrp['id']);
     CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $fdParams, $fdField);
     $idParams = array('name' => 'Initial_Join_Date', 'custom_group_id' => $cGrp['id']);
     CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $idParams, $idField);
     $extraWhereClause = " (({$cGrp['table_name']}.{$fdField['column_name']} >= CURDATE() OR {$cGrp['table_name']}.{$fdField['column_name']} IS NULL) AND\n      ({$cGrp['table_name']}.{$idField['column_name']} IS NOT NULL AND {$cGrp['table_name']}.{$idField['column_name']} <= CURDATE()))";
     $column = $columnHeaders = $selector->getColumnHeaders();
     $rows = $selector->getRows(4, 0, 0, NULL, NULL, $extraWhereClause);
     CRM_Utils_Hook::searchColumns('profile', $columnHeaders, $rows, $this);
     $this->assign('aaData', json_encode($rows));
     /* to bring column names in [
     			{ "sTitle": "Engine" },
     			{ "sTitle": "Browser" },] format*/
     $colunmH = "[";
     foreach ($column as $k => $v) {
         if (!empty($v['name'])) {
             $name = '{"sTitle":"' . $v['name'] . '"}';
         } else {
             $name = '{"bSortable": false}';
         }
         $colunmH .= $name . ",";
     }
     $colunmH .= "]";
     $this->assign('aaColumn', $colunmH);
     return 'CRM/HRProfile/Page/HRProfile.tpl';
 }
 /**
  * Heart of the Controller. This is where all the action takes place
  *
  *   - The rows are fetched and stored depending on the type of output needed
  *
  *   - For export/printing all rows are selected.
  *
  *   - for displaying on screen paging parameters are used to display the
  *     required rows.
  *
  *   - also depending on output type of session or template rows are appropriately stored in session
  *     or template variables are updated.
  *
  *
  * @return void
  *
  */
 function run()
 {
     // get the column headers
     $columnHeaders =& $this->_object->getColumnHeaders($this->_action, $this->_output);
     $contextArray = explode('_', get_class($this->_object));
     $contextName = strtolower($contextArray[1]);
     // fix contribute and member
     if ($contextName == 'contribute') {
         $contextName = 'contribution';
     } elseif ($contextName == 'member') {
         $contextName = 'membership';
     }
     // we need to get the rows if we are exporting or printing them
     if ($this->_output == self::EXPORT || $this->_output == self::SCREEN) {
         // get rows (without paging criteria)
         $rows = self::getRows($this);
         CRM_Utils_Hook::searchColumns($contextName, $columnHeaders, $rows, $this);
         if ($this->_output == self::EXPORT) {
             // export the rows.
             CRM_Core_Report_Excel::writeCSVFile($this->_object->getExportFileName(), $columnHeaders, $rows);
             CRM_Utils_System::civiExit();
         } else {
             // assign to template and display them.
             self::$_template->assign_by_ref('rows', $rows);
             self::$_template->assign_by_ref('columnHeaders', $columnHeaders);
         }
     } else {
         // output requires paging/sorting capability
         $rows = self::getRows($this);
         CRM_Utils_Hook::searchColumns($contextName, $columnHeaders, $rows, $this);
         $rowsEmpty = count($rows) ? FALSE : TRUE;
         $qill = $this->getQill();
         $summary = $this->getSummary();
         // if we need to store in session, lets update session
         if ($this->_output & self::SESSION) {
             $this->_store->set("{$this->_prefix}columnHeaders", $columnHeaders);
             if ($this->_dynamicAction) {
                 $this->_object->removeActions($rows);
             }
             $this->_store->set("{$this->_prefix}rows", $rows);
             $this->_store->set("{$this->_prefix}rowCount", $this->_total);
             $this->_store->set("{$this->_prefix}rowsEmpty", $rowsEmpty);
             $this->_store->set("{$this->_prefix}qill", $qill);
             $this->_store->set("{$this->_prefix}summary", $summary);
         } else {
             self::$_template->assign_by_ref("{$this->_prefix}pager", $this->_pager);
             self::$_template->assign_by_ref("{$this->_prefix}sort", $this->_sort);
             self::$_template->assign_by_ref("{$this->_prefix}columnHeaders", $columnHeaders);
             self::$_template->assign_by_ref("{$this->_prefix}rows", $rows);
             self::$_template->assign("{$this->_prefix}rowsEmpty", $rowsEmpty);
             self::$_template->assign("{$this->_prefix}qill", $qill);
             self::$_template->assign("{$this->_prefix}summary", $summary);
         }
         // always store the current pageID and sortID
         $this->_store->set($this->_prefix . CRM_Utils_Pager::PAGE_ID, $this->_pager->getCurrentPageID());
         $this->_store->set($this->_prefix . CRM_Utils_Sort::SORT_ID, $this->_sort->getCurrentSortID());
         $this->_store->set($this->_prefix . CRM_Utils_Sort::SORT_DIRECTION, $this->_sort->getCurrentSortDirection());
         $this->_store->set($this->_prefix . CRM_Utils_Sort::SORT_ORDER, $this->_sort->orderBy());
         $this->_store->set($this->_prefix . CRM_Utils_Pager::PAGE_ROWCOUNT, $this->_pager->_perPage);
     }
 }