Ejemplo n.º 1
0
 public function btnSave_Click($strFormId, $strControlId, $strParameter)
 {
     $objPerson = $this->pnlPerson->Person;
     // Validate the Dates
     $dttDateArray = GroupParticipation::GetParticipationDatesArrayForPersonIdGroupIdGroupRoleId($objPerson->Id, $this->objGroup->Id, $this->lstRole->SelectedValue);
     // Add This One
     $dttDateArray[] = array($this->dtxDateStart->DateTime, $this->dtxDateEnd->DateTime);
     // If we have trouble trying to add it, let's redirect the user to the full record
     if (!GroupParticipation::IsValidDates($dttDateArray)) {
         QApplication::DisplayAlert('You are adding a participation that already exists.  Taking you to this person\'s record for more information.');
         return $this->ReturnTo('#' . $this->objGroup->Id . '/edit_participation/' . $objPerson->Id);
     }
     // Go ahead and create the record
     $this->objGroup->AddPerson($objPerson, $this->lstRole->SelectedValue, $this->dtxDateStart->DateTime, $this->dtxDateEnd->DateTime);
     return $this->ReturnTo('#' . $this->objGroup->Id);
 }
 public function btnEditOkay_Click($strFormId, $strControlId, $strParameter)
 {
     // Validate Date Range
     $dttDateRangeArray = array();
     foreach ($this->objParticipationArray as $intIndex => $objParticipation) {
         if (!($intIndex === $this->intEditParticipationIndex) && $objParticipation->GroupRoleId == $this->lstEditRole->SelectedValue) {
             $dttDateRangeArray[] = array($objParticipation->DateStart, $objParticipation->DateEnd);
         }
     }
     $dttDateRangeArray[] = array($this->dtxEditStart->DateTime, $this->dtxEditEnd->DateTime);
     usort($dttDateRangeArray, array($this, 'dttDateRangeArray_Sort'));
     if (!GroupParticipation::IsValidDates($dttDateRangeArray)) {
         $this->dtxEditStart->Warning = 'Invalid Dates';
         return;
     }
     if (!is_null($this->intEditParticipationIndex)) {
         $objParticipation = $this->objParticipationArray[$this->intEditParticipationIndex];
         $objParticipation->GroupRoleId = $this->lstEditRole->SelectedValue;
         $objParticipation->Group = $this->pnlContent->objGroup;
         $objParticipation->DateStart = $this->dtxEditStart->DateTime;
         $objParticipation->DateEnd = $this->dtxEditEnd->DateTime;
     } else {
         $objParticipation = new GroupParticipation();
         $objParticipation->Person = $this->pnlContent->objPerson;
         $objParticipation->Group = $this->pnlContent->objGroup;
         $objParticipation->GroupRoleId = $this->lstEditRole->SelectedValue;
         $objParticipation->DateStart = $this->dtxEditStart->DateTime;
         $objParticipation->DateEnd = $this->dtxEditEnd->DateTime;
         $this->objParticipationArray[] = $objParticipation;
     }
     usort($this->objParticipationArray, array($this, 'objParticipationArray_Sort'));
     $this->intEditParticipationIndex = null;
     $this->dtgParticipations->Refresh();
     $this->lblCurrentRoles_Refresh();
     $this->dlgEdit->HideDialogBox();
 }