/** * function getHTML * <pre> * This method returns the HTML data generated by this object. * </pre> * @return [STRING] HTML Display data. */ function getHTML() { // Uncomment the following line if you want to create a template // tailored for this page: //$path = $this->pathModuleRoot.'templates/'; // Otherwise use the standard Templates for the site: $path = SITE_PATH_TEMPLATES; // store the page labels in XML format... // NOTE: use this location to update any label tags ... // $name = $user->getName(); // $this->labels->setLabelTag( '[Title]', '[userName]', $name); // NOTE: this parent method prepares the $this->template with the // common Form data. $this->prepareTemplate($path); /* * Form related Template variables: */ // store the button label $this->template->set('buttonText', $this->labels->getLabel('[Update]')); // Insert the date start/end values for the following date fields: // example: //$this->template->set( 'startYear_[fieldName]', 2000); //$this->template->set( 'endYear_[fieldName]', 2010); /* * Add any additional data required by the template here */ $yearManager = new RowManager_YearInSchoolManager(); $yearManager->setSortOrder('year_desc'); $yearList = $yearManager->getListIterator(); $yearArray = $yearList->getDropListArray(); $this->template->set('list_year_id', $yearArray); // uncomment this line if you are creating a template for this page //$templateName = 'page_EditMyYearInSchool.php'; // otherwise use the generic admin box template $templateName = 'siteFormSingle.php'; return $this->template->fetch($templateName); }
/** * function __construct * <pre> * Initialize the object. * </pre> * @param $pathModuleRoot [STRING] The path to the module's root dir. * @param $viewer [OBJECT] The viewer object. * @param $sortBy [STRING] Field data to sort listManager by. * @param $managerInit [INTEGER] Initialization value for the listManager. * @return [void] */ function __construct($pathModuleRoot, $viewer, $sortBy, $year_id = "", $campus_id = "") { parent::__construct(page_ViewStudentYearInSchool::DISPLAY_FIELDS); $this->pathModuleRoot = $pathModuleRoot; $this->viewer = $viewer; $this->year_id = $year_id; $this->campus_id = $campus_id; // echo 'campusID['.$this->campus_id.']<br/>'; // $this->managerInit = $managerInit; // Now load the access Priviledge manager of this viewer $this->adminManager = new RowManager_AdminManager(); // Get the person ID $accessManager = new RowManager_AccessManager(); $accessManager->loadByViewerID($this->viewer->getViewerID()); $personID = $accessManager->getPersonID(); // Get the permissions the person has. $this->adminManager->loadByPersonID($personID); // need to filter displayed data by campus associated with campus admin $campusAdminSearchCondition = ''; if ($this->adminManager->hasSitePriv()) { $campusManager = new RowManager_CampusManager(); $campusManager->setSortOrder('campus_desc'); $this->campusList = $campusManager->getListIterator(); $this->accessibleCampuses = $this->campusList->getDropListArray(); } else { if ($this->adminManager->hasCampusPriv()) { $campusAdminManager = new RowManager_CampusAdminManager(); $adminID = $this->adminManager->getID(); // echo 'adminID['.$adminID.']<br/>'; $campusAdminManager->setAdminID($adminID); $campusList = $campusAdminManager->getListIterator(); //$multiTableManager->getListIterator(); $campusArray = $campusList->getDataList(); $campusIDsList = ""; // init the CSV of campus IDs associated with admin reset($campusArray); foreach (array_keys($campusArray) as $k) { $record = current($campusArray); $campusIDsList .= $record['campus_id'] . ','; // create list of admin campuses next($campusArray); } $campusIDsList = substr($campusIDsList, 0, -1); // remove last comma $campusAdminSearchCondition = 'cim_hrdb_assignment.campus_id in (' . $campusIDsList . ')'; } else { if ($this->adminManager->isStaff($viewer->getID())) { $staffManager = new RowManager_StaffManager(); $staffManager->setPersonID($personID); $multiTableManager = new MultiTableManager(); $multiTableManager->addRowManager($staffManager); $multiTableManager->setSortOrder('campus_desc'); $assignmentManager = new RowManager_AssignmentsManager(); $multiTableManager->addRowManager($assignmentManager, new JoinPair($assignmentManager->getJoinOnPersonID(), $staffManager->getJoinOnPersonID())); $campusManager = new RowManager_CampusManager(); $multiTableManager->addRowManager($campusManager, new JoinPair($campusManager->getJoinOnCampusID(), $assignmentManager->getJoinOnCampusID())); $this->campusList = $multiTableManager->getListIterator(); $campusIDsList = ""; // init the CSV of campus IDs associated with admin $this->campusList->setFirst(); while ($this->campusList->moveNext()) { $campusAssignObject = $this->campusList->getCurrent(new RowManager_AssignmentsManager()); $campusObject = $this->campusList->getCurrent(new RowManager_CampusManager()); $campusIDsList .= $campusAssignObject->getCampusID() . ','; // create list of admin campuses } $campusIDsList = substr($campusIDsList, 0, -1); // remove last comma $campusAdminSearchCondition = 'cim_hrdb_assignment.campus_id in (' . $campusIDsList . ')'; } } } $yearManager = new RowManager_YearInSchoolManager(); $yearManager->setSortOrder('year_id'); $this->yearValueList = $yearManager->getListIterator(); $this->yearValues = $this->yearValueList->getDropListArray(); // Add value to drop-list for showing person data for people not having person_year record $keys = array_keys($this->yearValues); $this->UNASSIGNED_IDX = $keys[count($this->yearValues) - 1] + 1; // assumes autoincrement is active on table $this->yearValues[$this->UNASSIGNED_IDX] = page_ViewStudentYearInSchool::UNASSIGNED; // echo 'values = <pre>'.print_r($this->yearValues, true).'</pre>'; // modify the year_id if necessary if ($this->year_id == page_ViewStudentYearInSchool::DISPLAY_ALL_ID) { // setting the year_id to blank will get entries from all the years $this->year_id = ''; } else { if ($this->year_id == '') { // no campus has been specified // choose a default campus if none specified // echo 'No campus specified<br/>'; // get the first element from the accessible list foreach ($this->yearValues as $key => $value) { $this->year_id = $key; break; } // assert campus_id should now be something if ($this->year_id == '') { die("ERROR - year_id not set to anything<br/>"); } } } $dataAccessObject = new MultiTableManager(); // Check if regular choice made (i.e. person has some year_in_school record) if ($this->year_id != $this->UNASSIGNED_IDX) { $personYearManager = new RowManager_PersonYearManager(); $personYearManager->setYear($this->year_id); // SOMEWHAT REDUNDANT GIVEN addSearchCondition (which is required) $dataAccessObject->addRowManager($personYearManager); $yearManager = new RowManager_YearInSchoolManager(); $joinPair = new JoinPair($personYearManager->getJoinOnYearID(), $yearManager->getJoinOnYearID()); $dataAccessObject->addRowManager($yearManager, $joinPair); $personManager = new RowManager_PersonManager(); $joinPair1 = new JoinPair($personManager->getJoinOnPersonID(), $personYearManager->getJoinOnPersonID()); $dataAccessObject->addRowManager($personManager, $joinPair1); $assignmentManager = new RowManager_AssignmentsManager(); $joinPair2 = new JoinPair($personYearManager->getJoinOnPersonID(), $assignmentManager->getJoinOnPersonID()); $dataAccessObject->addRowManager($assignmentManager, $joinPair2); $campusManager = new RowManager_CampusManager(); $joinPair3 = new JoinPair($assignmentManager->getJoinOnCampusID(), $campusManager->getJoinOnCampusID()); $dataAccessObject->addRowManager($campusManager, $joinPair3); if ($sortBy == '') { $sortBy = 'campus_shortDesc,person_lname'; } if ($this->year_id != '') { $dataAccessObject->addSearchCondition('cim_hrdb_person_year.year_id = ' . $this->year_id); } // filter by campuses assigned to this campus admin if ($campusAdminSearchCondition != '') { $dataAccessObject->addSearchCondition($campusAdminSearchCondition); } $dataAccessObject->setSortOrder($sortBy); $this->listManager = $dataAccessObject->getListIterator(); } else { // $personYearManager = new RowManager_PersonYearManager(); // $personYearManager->setYear($this->year_id); // SOMEWHAT REDUNDANT GIVEN addSearchCondition (which is required) // $dataAccessObject->addRowManager( $personYearManager ); // // $yearManager = new RowManager_YearInSchoolManager(); // $joinPair = new JoinPair($personYearManager->getJoinOnYearID(), $yearManager->getJoinOnYearID()); // $dataAccessObject->addRowManager( $yearManager, $joinPair ); $personManager = new RowManager_PersonManager(); $dataAccessObject->addRowManager($personManager); $assignmentManager = new RowManager_AssignmentsManager(); $joinPair2 = new JoinPair($personManager->getJoinOnPersonID(), $assignmentManager->getJoinOnPersonID()); $dataAccessObject->addRowManager($assignmentManager, $joinPair2); $campusManager = new RowManager_CampusManager(); $joinPair3 = new JoinPair($assignmentManager->getJoinOnCampusID(), $campusManager->getJoinOnCampusID()); $dataAccessObject->addRowManager($campusManager, $joinPair3); if ($sortBy == '') { $sortBy = 'campus_shortDesc,person_lname'; } // get sub-query data for filtering out registrants that have already been registered for event $subManager = new RowManager_PersonYearManager(); $personYearManager = new MultiTableManager(); $personYearManager->addRowManager($subManager); $personYearManager->setFieldList('person_id'); $registered_SQL = $personYearManager->createSQL(); // echo "<br>CREATED SQL 1 = ".$registered_SQL; // actually creates the sub-query ensuring that registrants listed do NOT have personyear records $negateSubQuery = true; $addSubQuery = true; $dataAccessObject->constructSubQuery('person_id', $registered_SQL, $negateSubQuery, $addSubQuery); // filter by campuses assigned to this campus admin if ($campusAdminSearchCondition != '') { $dataAccessObject->addSearchCondition($campusAdminSearchCondition); } $dataAccessObject->setSortOrder($sortBy); $this->listManager = $dataAccessObject->getListIterator(); } /** TEST **/ // $values = $this->listManager->getDataList(); // echo 'values found = <pre>'.print_r($values,true).'</pre>'; /** END TEST **/ // now initialize the labels for this page // start by loading the default field labels for this Module $languageID = $viewer->getLanguageID(); $seriesKey = modulecim_hrdb::MULTILINGUAL_SERIES_KEY; $pageKey = modulecim_hrdb::MULTILINGUAL_PAGE_FIELDS; $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey); // then load the page specific labels for this page $pageKey = page_ViewStudentYearInSchool::MULTILINGUAL_PAGE_KEY; $this->labels->loadPageLabels($pageKey); $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE); $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS); }
/** * function getHTML * <pre> * This method returns the HTML data generated by this object. * </pre> * @return [STRING] HTML Display data. */ function getHTML() { // Uncomment the following line if you want to create a template // tailored for this page: $path = $this->pathModuleRoot . 'templates/'; // Otherwise use the standard Templates for the site: // $path = SITE_PATH_TEMPLATES; $this->template = new Template($path); // store the link labels $this->linkLabels['DownloadSeniorityCSV'] = $this->labels->getLabel('[DownloadSeniorityCSV]'); // store the formAction value to the template $this->template->set('formAction', $this->formAction); // store the page labels in XML format... // NOTE: use this location to update any label tags ... // $name = $user->getName(); // $this->labels->setLabelTag( '[Title]', '[userName]', $name); $this->template->setXML('pageLabels', $this->labels->getLabelXML()); // store the rowManager to the template $this->template->setXML('rowList', $this->rowManager->getXML()); // store the label Field Name $this->template->set('labelFieldName', ''); // store all the fields to the template $this->setFormFieldsToTemplate(); /* * Add any additional data required by the template here */ // save the list of form fields $this->template->set('formFieldList', $this->formFields); // store the field types being displayed $fieldTypes = explode(',', FormProcessor_EditStudentYearInSchool::FORM_FIELD_TYPES); $this->template->set('formFieldType', $fieldTypes); // Insert the date start/end values for the following date fields: // example: //$this->template->set( 'startYear_[fieldName]', 2000); //$this->template->set( 'endYear_[fieldName]', 2010); /** Create and store download CSV link **/ $downloadLink = array(); $downloadLink['DownloadSeniorityCSV'] = $this->linkValues['DownloadSeniorityCSV']; $this->template->set('linkLabels', $this->linkLabels); $this->template->set('downloadLink', $downloadLink); // now add the data for the Campus Group JumpList $jumpLink = $this->linkValues['jumpLink']; $jumpList = array(); if ($this->adminManager->hasSitePriv()) { $jumpList[$jumpLink . page_PeoplebyCampuses::DISPLAY_ALL_ID] = 'Show All'; } foreach ($this->accessibleCampuses as $key => $value) { $jumpList[$jumpLink . $key] = $value; } $this->template->set('jumpList', $jumpList); // echo '<pre>'.print_r($jumpList,true).'</pre>'; // echo 'jumpLink['.$jumpLink.']<br/>'; $this->template->set('defaultCampus', $jumpLink . $this->campus_id); //Person list. // $personManager = new RowManager_PersonManager( ); // $personManager->setSortOrder('person_lname'); // $personManager->setLabelTemplateLastNameFirstName(); // $personList = $personManager->getListIterator( ); // $personArray = $personList->getDataList(); //DropListArray( ); // $this->template->set( 'list_person_id', $personArray ); // // for each row item ... // $this->rowManager->setFirst( ); // while( $rowItem = $this->rowManager->getNext() ) { // // // make sure rowItems have valid entries in the DB // if (!$rowItem->isLoaded()) { // $rowItem->createNewEntry(); // } // // // set the fields of interest ... // $rowItem->setFieldsOfInterest( $fieldsOfInterest ); // // // get the primaryID of this rowItem // $primaryID = $rowItem->getPrimaryKeyValue(); // // // now initialize beginning form values from rowItem object // for( $indx=0; $indx<count($this->formFields); $indx++) { // // $key = $this->formFields[$indx]; // // $this->formValues[ $key.$primaryID ] = $rowItem->getValueByFieldName( $key ); // } // next field // // } // next rowItem in rowManager //Year list. $yearManager = new RowManager_YearInSchoolManager(); $yearManager->setSortOrder('year_id'); $yearList = $yearManager->getListIterator(); $yearArray = $yearList->getDropListArray(); $this->template->set('list_year_id', $yearArray); reset($this->primaryIDs); foreach (array_keys($this->primaryIDs) as $k) { $record = current($this->primaryIDs); $this->template->set('list_year_id' . $record, $yearArray); next($this->primaryIDs); } //Person list. // $this->template->set( 'list_person_id', $personArray ); // // reset($this->primaryIDs); // foreach( array_keys($this->primaryIDs) as $k) // { // $personManager = new RowManager_PersonManager( $person_id ); // $personManager->setLabelTemplateLastNameFirstName(); // $personList = $personManager->getListIterator( ); // $personArray = $personList->getDropListArray( ); // // $record = current($this->primaryIDs); // echo 'array = <pre>'.print_r($record,true).'</pre>'; // $this->template->set( 'person_id'.$record, $person_name ); // next($this->primaryIDs); // } /* * List related Template variables : */ // Store the XML Node name for the Data Access Field List $xmlNodeName = RowManager_PersonYearManager::XML_NODE_NAME; $this->template->set('rowManagerXMLNodeName', $xmlNodeName); // store the primary key field name for the data being displayed $this->template->set('primaryKeyFieldName', 'personyear_id'); // uncomment this line if you are creating a template for this page $templateName = 'page_EditStudentYearInSchool.tpl.php'; // $templateName = 'siteFormGrid.php'; // generic form grid template return $this->template->fetch($templateName); }