Permalink
Browse files

Implemented parentpager view linking and unlinking as well as hide-ma…

…nagement

Also removed view of child history from non-SK management folks
  • Loading branch information...
1 parent 0846939 commit 3b2c428a0a06de54e9595679cfaa89372ab6d244 Mike Ho committed Mar 15, 2012
View
14 includes/data_classes/ParentPagerIndividual.class.php
@@ -27,6 +27,20 @@ public function __toString() {
return sprintf('ParentPagerIndividual Object %s', $this->intId);
}
+ public function __get($strName) {
+ switch ($strName) {
+ case 'Name': return $this->strFirstName . ' ' . $this->strMiddleName . ' ' . $this->strLastName;
+
+ default:
+ try {
+ return parent::__get($strName);
+ } catch (QCallerException $objExc) {
+ $objExc->IncrementOffset();
+ throw $objExc;
+ }
+ }
+ }
+
/**
* This will create a new record or update an existing record given the MS SQL Data Row
* @param string[] $objRow the mssql_fetch_assoc row result from MS SQL Server
View
10 includes/view_individuals_content_panels/SafariKids/Vicp_SafariKids.class.php
@@ -2,7 +2,6 @@
class Vicp_SafariKids extends Vicp_Base {
public $dtgAttendantHistory;
public $dtgChildHistory;
- public $dtgParentHistory;
public $dtgParentPagerIndividuals;
public $pxyUnassociate;
@@ -21,10 +20,11 @@ protected function SetupPanel() {
$this->dtgAttendantHistory->SortDirection = 1;
$this->dtgAttendantHistory->FontSize = '11px';
}
-
- if (ParentPagerChildHistory::QueryCount(QQ::Equal(QQN::ParentPagerChildHistory()->ParentPagerIndividual->PersonId, $this->objPerson->Id)) ||
- ParentPagerChildHistory::QueryCount(QQ::Equal(QQN::ParentPagerChildHistory()->PickupByParentPagerIndividual->PersonId, $this->objPerson->Id)) ||
- ParentPagerChildHistory::QueryCount(QQ::Equal(QQN::ParentPagerChildHistory()->DropoffByParentPagerIndividual->PersonId, $this->objPerson->Id))) {
+
+ if (QApplication::$Login->IsPermissionAllowed(PermissionType::ManageSafariKids) &&
+ (ParentPagerChildHistory::QueryCount(QQ::Equal(QQN::ParentPagerChildHistory()->ParentPagerIndividual->PersonId, $this->objPerson->Id)) ||
+ ParentPagerChildHistory::QueryCount(QQ::Equal(QQN::ParentPagerChildHistory()->PickupByParentPagerIndividual->PersonId, $this->objPerson->Id)) ||
+ ParentPagerChildHistory::QueryCount(QQ::Equal(QQN::ParentPagerChildHistory()->DropoffByParentPagerIndividual->PersonId, $this->objPerson->Id)))) {
$this->dtgChildHistory = new ParentPagerChildHistoryDataGrid($this);
$this->dtgChildHistory->MetaAddColumn('DateIn', 'Width=125px', 'FontSize=10px');
$this->dtgChildHistory->MetaAddColumn('DateOut', 'Width=125px', 'FontSize=10px');
View
27 www/sk/index.php
@@ -31,15 +31,18 @@ protected function Form_Create() {
$this->txtServerIdentifier = new QTextBox($this);
$this->txtServerIdentifier->Text = QApplication::QueryString('id');
- $this->txtServerIdentifier->AddAction(new QChangeEvent(), new QAjaxAction('Filter_Change'));
-
+ $this->txtServerIdentifier->AddAction(new QEnterKeyEvent(), new QAjaxAction('Filter_Change'));
+ $this->txtServerIdentifier->AddAction(new QEnterKeyEvent(), new QTerminateAction());
+
$this->txtFirstName = new QTextBox($this);
$this->txtFirstName->Text = QApplication::QueryString('fn');
- $this->txtFirstName->AddAction(new QChangeEvent(), new QAjaxAction('Filter_Change'));
+ $this->txtFirstName->AddAction(new QEnterKeyEvent(), new QAjaxAction('Filter_Change'));
+ $this->txtFirstName->AddAction(new QEnterKeyEvent(), new QTerminateAction());
$this->txtLastName = new QTextBox($this);
$this->txtLastName->Text = QApplication::QueryString('ln');
- $this->txtLastName->AddAction(new QChangeEvent(), new QAjaxAction('Filter_Change'));
+ $this->txtLastName->AddAction(new QEnterKeyEvent(), new QAjaxAction('Filter_Change'));
+ $this->txtLastName->AddAction(new QEnterKeyEvent(), new QTerminateAction());
$this->lstParentPagerSyncStatusTypeId = new QListBox($this);
$this->lstParentPagerSyncStatusTypeId->AddItem('- View All -');
@@ -58,6 +61,8 @@ protected function Form_Create() {
$this->txtGraduationYear = new QTextBox($this);
$this->txtGraduationYear->Text = QApplication::QueryString('year');
$this->txtGraduationYear->AddAction(new QChangeEvent(), new QAjaxAction('Filter_Change'));
+ $this->txtGraduationYear->AddAction(new QEnterKeyEvent(), new QAjaxAction('Filter_Change'));
+ $this->txtGraduationYear->AddAction(new QEnterKeyEvent(), new QTerminateAction());
}
public function Filter_Change() {
@@ -139,7 +144,19 @@ public function RenderLinkedPerson(ParentPagerIndividual $objIndividual) {
}
public function RenderIdentifier(ParentPagerIndividual $objIndividual) {
- return sprintf('<a href="/sk/link.php/%s" onclick="alert(&quot;Not Yet Implemented&quot;); return false;">%s</a>', $objIndividual->Id, $objIndividual->ServerIdentifier);
+ if ($objIndividual->HiddenFlag) {
+ $objStyle = new QDataGridRowStyle();
+ $objStyle->ForeColor = '#666';
+ $objStyle->BackColor = '#ccc';
+ $this->dtgParentPagerIndividuals->OverrideRowStyle($this->dtgParentPagerIndividuals->CurrentRowIndex, $objStyle);
+
+ } else {
+ $this->dtgParentPagerIndividuals->OverrideRowStyle($this->dtgParentPagerIndividuals->CurrentRowIndex, null);
+ }
+ if ($objIndividual->PersonId)
+ return sprintf('<a href="/sk/link.php/%s" onclick="return confirm(&quot;Are you SURE you want to make changes to this already-linked to NOAH record?&quot;);">%s</a>', $objIndividual->Id, $objIndividual->ServerIdentifier);
+ else
+ return sprintf('<a href="/sk/link.php/%s">%s</a>', $objIndividual->Id, $objIndividual->ServerIdentifier);
}
public function RenderAddresses(ParentPagerIndividual $objIndividual) {
View
134 www/sk/link.php
@@ -0,0 +1,134 @@
+<?php
+ require(dirname(__FILE__) . '/../../includes/prepend.inc.php');
+ QApplication::Authenticate(null, array(PermissionType::ManageSafariKids));
+
+ class SkForm extends ChmsForm {
+ protected $strPageTitle = 'Safari Kids - Link a ParentPager Record';
+ protected $intNavSectionId = ChmsForm::NavSectionSafariKids;
+
+ protected $dtgAttendantHistory;
+ protected $dtgChildHistory;
+
+ protected $objParentPagerIndividual;
+ protected $pnlSelectPerson;
+
+ protected $btnSave;
+ protected $btnCancel;
+ protected $btnHideToggle;
+
+ protected function Form_Create() {
+ $this->objParentPagerIndividual = ParentPagerIndividual::Load(QApplication::PathInfo(0));
+ if (!$this->objParentPagerIndividual) QApplication::Redirect('/sk/');
+ $this->pnlSelectPerson = new SelectPersonPanel($this);
+ $this->pnlSelectPerson->Required = true;
+ $this->pnlSelectPerson->Name = 'Search NOAH';
+ $this->pnlSelectPerson->txtName->Text = $this->objParentPagerIndividual->FirstName . ' ' . $this->objParentPagerIndividual->LastName;
+ $this->pnlSelectPerson->txtName_Change();
+ $this->pnlSelectPerson->AllowCreate = true;
+
+ switch (strtoupper($this->objParentPagerIndividual->Gender)) {
+ case 'M':
+ $this->pnlSelectPerson->lstGender->SelectedValue = 'M';
+ break;
+ case 'F':
+ $this->pnlSelectPerson->lstGender->SelectedValue = 'F';
+ break;
+ }
+
+ if ($this->objParentPagerIndividual->DateOfBirth)
+ $this->pnlSelectPerson->dtxDateOfBirth->Text = $this->objParentPagerIndividual->DateOfBirth->ToString('MMM D YYYY');
+
+ // Report DataGrids
+ if ($this->objParentPagerIndividual->CountParentPagerAttendantHistories()) {
+ $this->dtgAttendantHistory = new ParentPagerAttendantHistoryDataGrid($this);
+ $this->dtgAttendantHistory->MetaAddColumn('DateIn', 'Width=125px', 'FontSize=10px');
+ $this->dtgAttendantHistory->MetaAddColumn('DateOut', 'Width=125px', 'FontSize=10px');
+ $this->dtgAttendantHistory->MetaAddColumn(QQN::ParentPagerAttendantHistory()->ParentPagerStation->Name, 'Name=Station', 'Width=160px');
+ $this->dtgAttendantHistory->MetaAddColumn(QQN::ParentPagerAttendantHistory()->ParentPagerPeriod->Name, 'Name=Period', 'Width=150px');
+ $this->dtgAttendantHistory->MetaAddColumn(QQN::ParentPagerAttendantHistory()->ParentPagerProgram->Name, 'Name=Program', 'Width=150px');
+ $this->dtgAttendantHistory->SetDataBinder('dtgAttendantHistory_Bind');
+ $this->dtgAttendantHistory->Paginator = new QPaginator($this->dtgAttendantHistory);
+ $this->dtgAttendantHistory->SortColumnIndex = 0;
+ $this->dtgAttendantHistory->SortDirection = 1;
+ $this->dtgAttendantHistory->FontSize = '11px';
+ }
+
+ if ($this->objParentPagerIndividual->CountParentPagerChildHistories() ||
+ $this->objParentPagerIndividual->CountParentPagerChildHistoriesAsPickupBy() ||
+ $this->objParentPagerIndividual->CountParentPagerChildHistoriesAsDropoffBy()) {
+ $this->dtgChildHistory = new ParentPagerChildHistoryDataGrid($this);
+ $this->dtgChildHistory->MetaAddColumn('DateIn', 'Width=125px', 'FontSize=10px');
+ $this->dtgChildHistory->MetaAddColumn('DateOut', 'Width=125px', 'FontSize=10px');
+ $this->dtgChildHistory->MetaAddColumn(QQN::ParentPagerChildHistory()->ParentPagerIndividual->FirstName, 'Name=Child', 'Width=80px');
+ $this->dtgChildHistory->MetaAddColumn(QQN::ParentPagerChildHistory()->PickupByParentPagerIndividual->FirstName, 'Name=Pick Up', 'Width=70px');
+ $this->dtgChildHistory->MetaAddColumn(QQN::ParentPagerChildHistory()->DropoffByParentPagerIndividual->FirstName, 'Name=Drop Off', 'Width=70px');
+ $this->dtgChildHistory->MetaAddColumn(QQN::ParentPagerChildHistory()->ParentPagerStation->Name, 'Name=Station', 'Width=150px');
+ $this->dtgChildHistory->MetaAddColumn(QQN::ParentPagerChildHistory()->ParentPagerPeriod->Name, 'Name=Period', 'Width=70px');
+ $this->dtgChildHistory->SetDataBinder('dtgChildHistory_Bind');
+ $this->dtgChildHistory->Paginator = new QPaginator($this->dtgChildHistory);
+ $this->dtgChildHistory->SortColumnIndex = 0;
+ $this->dtgChildHistory->SortDirection = 1;
+ $this->dtgChildHistory->FontSize = '11px';
+ }
+
+
+ // Buttons
+ $this->btnSave = new QButton($this);
+ $this->btnSave->Text = 'Link to NOAH';
+ $this->btnSave->AddAction(new QClickEvent(), new QAjaxAction('btnSave_Click'));
+ $this->btnSave->CausesValidation = true;
+ $this->btnSave->CssClass = 'primary';
+
+ $this->btnCancel= new QLinkButton($this);
+ $this->btnCancel->Text = 'Cancel';
+ $this->btnCancel->AddAction(new QClickEvent(), new QAjaxAction('btnCancel_Click'));
+ $this->btnCancel->AddAction(new QClickEvent(), new QTerminateAction());
+ $this->btnCancel->CssClass = 'cancel';
+
+ $this->btnHideToggle= new QLinkButton($this);
+ $this->btnHideToggle->Text = ($this->objParentPagerIndividual->HiddenFlag) ? 'Unhide This Unlinked Record' : 'Hide This Unlinked Record';
+ $this->btnHideToggle->AddAction(new QClickEvent(), new QAjaxAction('btnHideToggle_Click'));
+ $this->btnHideToggle->AddAction(new QClickEvent(), new QTerminateAction());
+ $this->btnHideToggle->CssClass = 'delete';
+ $this->btnHideToggle->SetCustomStyle('margin-left', 0);
+ if ($this->objParentPagerIndividual->ParentPagerSyncStatusTypeId != ParentPagerSyncStatusType::NotYetSynced)
+ $this->btnHideToggle->Visible = false;
+ }
+
+ public function dtgAttendantHistory_Bind() {
+ $this->dtgAttendantHistory->MetaDataBinder(QQ::Equal(QQN::ParentPagerAttendantHistory()->ParentPagerIndividualId, $this->objParentPagerIndividual->Id));
+ }
+
+ public function dtgChildHistory_Bind() {
+ $this->dtgChildHistory->MetaDataBinder(QQ::OrCondition(
+ QQ::Equal(QQN::ParentPagerChildHistory()->ParentPagerIndividualId, $this->objParentPagerIndividual->Id),
+ QQ::Equal(QQN::ParentPagerChildHistory()->PickupByParentPagerIndividualId, $this->objParentPagerIndividual->Id),
+ QQ::Equal(QQN::ParentPagerChildHistory()->DropoffByParentPagerIndividualId, $this->objParentPagerIndividual->Id)
+ ));
+ }
+
+ public function btnHideToggle_Click() {
+ if ($this->objParentPagerIndividual->ParentPagerSyncStatusTypeId != ParentPagerSyncStatusType::NotYetSynced) {
+ QApplication::Redirect('/sk/');
+ return;
+ }
+
+ $this->objParentPagerIndividual->HiddenFlag = $this->objParentPagerIndividual->HiddenFlag ? false : true;
+ $this->objParentPagerIndividual->Save();
+ QApplication::Redirect('/sk/');
+ }
+
+ public function btnSave_Click() {
+ $this->objParentPagerIndividual->Person = $this->pnlSelectPerson->Person;
+ $this->objParentPagerIndividual->Save();
+ $this->objParentPagerIndividual->RefreshParentPagerSyncStatusType();
+ QApplication::Redirect('/sk/');
+ }
+
+ public function btnCancel_Click() {
+ QApplication::Redirect('/sk/');
+ }
+ }
+
+ SkForm::Run('SkForm');
+?>
View
33 www/sk/link.tpl.php
@@ -0,0 +1,33 @@
+<?php require(__INCLUDES__ . '/header.inc.php'); ?>
+ <h1 style="margin-bottom: 0;">Safari Kids</h1>
+ <h3>NOAH / ParentPager Integration For: <?php _p($this->objParentPagerIndividual->Name); ?> (Parent Pager ID #<?php _p($this->objParentPagerIndividual->ServerIdentifier); ?>)</h3>
+
+ <?php if ($this->dtgAttendantHistory) { ?>
+ <div class="section">
+ <h3>History as an Attendant</h3>
+ <?php $this->dtgAttendantHistory->Render(); ?>
+ </div>
+ <?php } ?>
+ <?php if ($this->dtgChildHistory) { ?>
+ <div class="section">
+ <h3>History as a Parent or Child</h3>
+ <?php $this->dtgChildHistory->Render(); ?>
+ </div>
+ <?php } ?>
+
+ <div class="section">
+ <?php $this->pnlSelectPerson->Render(); ?>
+ </div>
+
+ <div class="buttonBar">
+ <div style="float: left;">
+ <?php $this->btnHideToggle->Render(); ?>
+ </div>
+ <div style="float: right;">
+ <?php $this->btnSave->Render(); ?>
+ &nbsp;or&nbsp;
+ <?php $this->btnCancel->Render(); ?>
+ </div>
+ </div>
+
+<?php require(__INCLUDES__ . '/footer.inc.php'); ?>

0 comments on commit 3b2c428

Please sign in to comment.