Example #1
0
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objSignupEntry) {
         $objObject->objSignupEntry = SignupEntry::GetSoapObjectFromObject($objObject->objSignupEntry, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intSignupEntryId = null;
         }
     }
     if ($objObject->objClassMeeting) {
         $objObject->objClassMeeting = ClassMeeting::GetSoapObjectFromObject($objObject->objClassMeeting, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intClassMeetingId = null;
         }
     }
     if ($objObject->objPerson) {
         $objObject->objPerson = Person::GetSoapObjectFromObject($objObject->objPerson, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intPersonId = null;
         }
     }
     if ($objObject->objClassGrade) {
         $objObject->objClassGrade = ClassGrade::GetSoapObjectFromObject($objObject->objClassGrade, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intClassGradeId = null;
         }
     }
     return $objObject;
 }
 /**
  * Main utility method to aid with data binding.  It is used by the default BindAllRows() databinder but
  * could and should be used by any custom databind methods that would be used for instances of this
  * MetaDataGrid, by simply passing in a custom QQCondition and/or QQClause. 
  *
  * If a paginator is set on this DataBinder, it will use it.  If not, then no pagination will be used.
  * It will also perform any sorting (if applicable).
  *
  * @param QQCondition $objConditions override the default condition of QQ::All() to the query, itself
  * @param QQClause[] $objOptionalClauses additional optional QQClause object or array of QQClause objects for the query		 
  * @return void
  */
 public function MetaDataBinder(QQCondition $objCondition = null, $objOptionalClauses = null)
 {
     // Setup input parameters to default values if none passed in
     if (!$objCondition) {
         $objCondition = QQ::All();
     }
     $objClauses = $objOptionalClauses ? $objOptionalClauses : array();
     // We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below
     if ($this->Paginator) {
         $this->TotalItemCount = ClassMeeting::QueryCount($objCondition, $objClauses);
     }
     // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add
     // the OrderByClause to the $objClauses array
     if ($objClause = $this->OrderByClause) {
         array_push($objClauses, $objClause);
     }
     // Add the LimitClause information, as well
     if ($objClause = $this->LimitClause) {
         array_push($objClauses, $objClause);
     }
     // Set the DataSource to be a Query result from ClassMeeting, given the clauses above
     $this->DataSource = ClassMeeting::QueryArray($objCondition, $objClauses);
 }
 /**
  * This will save this object's SignupForm instance,
  * updating only the fields which have had a control created for it.
  */
 public function SaveSignupForm()
 {
     try {
         // Update any fields for controls that have been created
         if ($this->lstSignupFormType) {
             $this->objSignupForm->SignupFormTypeId = $this->lstSignupFormType->SelectedValue;
         }
         if ($this->lstMinistry) {
             $this->objSignupForm->MinistryId = $this->lstMinistry->SelectedValue;
         }
         if ($this->txtName) {
             $this->objSignupForm->Name = $this->txtName->Text;
         }
         if ($this->txtToken) {
             $this->objSignupForm->Token = $this->txtToken->Text;
         }
         if ($this->chkActiveFlag) {
             $this->objSignupForm->ActiveFlag = $this->chkActiveFlag->Checked;
         }
         if ($this->chkConfidentialFlag) {
             $this->objSignupForm->ConfidentialFlag = $this->chkConfidentialFlag->Checked;
         }
         if ($this->txtDescription) {
             $this->objSignupForm->Description = $this->txtDescription->Text;
         }
         if ($this->txtInformationUrl) {
             $this->objSignupForm->InformationUrl = $this->txtInformationUrl->Text;
         }
         if ($this->txtSupportEmail) {
             $this->objSignupForm->SupportEmail = $this->txtSupportEmail->Text;
         }
         if ($this->txtEmailNotification) {
             $this->objSignupForm->EmailNotification = $this->txtEmailNotification->Text;
         }
         if ($this->chkAllowOtherFlag) {
             $this->objSignupForm->AllowOtherFlag = $this->chkAllowOtherFlag->Checked;
         }
         if ($this->chkAllowMultipleFlag) {
             $this->objSignupForm->AllowMultipleFlag = $this->chkAllowMultipleFlag->Checked;
         }
         if ($this->txtSignupLimit) {
             $this->objSignupForm->SignupLimit = $this->txtSignupLimit->Text;
         }
         if ($this->txtSignupMaleLimit) {
             $this->objSignupForm->SignupMaleLimit = $this->txtSignupMaleLimit->Text;
         }
         if ($this->txtSignupFemaleLimit) {
             $this->objSignupForm->SignupFemaleLimit = $this->txtSignupFemaleLimit->Text;
         }
         if ($this->txtFundingAccount) {
             $this->objSignupForm->FundingAccount = $this->txtFundingAccount->Text;
         }
         if ($this->lstDonationStewardshipFund) {
             $this->objSignupForm->DonationStewardshipFundId = $this->lstDonationStewardshipFund->SelectedValue;
         }
         if ($this->calDateCreated) {
             $this->objSignupForm->DateCreated = $this->calDateCreated->DateTime;
         }
         if ($this->chkLoginNotRequiredFlag) {
             $this->objSignupForm->LoginNotRequiredFlag = $this->chkLoginNotRequiredFlag->Checked;
         }
         // Update any UniqueReverseReferences (if any) for controls that have been created for it
         if ($this->lstClassMeeting) {
             $this->objSignupForm->ClassMeeting = ClassMeeting::Load($this->lstClassMeeting->SelectedValue);
         }
         if ($this->lstEventSignupForm) {
             $this->objSignupForm->EventSignupForm = EventSignupForm::Load($this->lstEventSignupForm->SelectedValue);
         }
         // Save the SignupForm object
         $this->objSignupForm->Save();
         // Finally, update any ManyToManyReferences (if any)
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
 }
 /**
  * Refresh this MetaControl with Data from the local ClassRegistration object.
  * @param boolean $blnReload reload ClassRegistration from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objClassRegistration->Reload();
     }
     if ($this->lstSignupEntry) {
         $this->lstSignupEntry->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstSignupEntry->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objSignupEntryArray = SignupEntry::LoadAll();
         if ($objSignupEntryArray) {
             foreach ($objSignupEntryArray as $objSignupEntry) {
                 $objListItem = new QListItem($objSignupEntry->__toString(), $objSignupEntry->Id);
                 if ($this->objClassRegistration->SignupEntry && $this->objClassRegistration->SignupEntry->Id == $objSignupEntry->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstSignupEntry->AddItem($objListItem);
             }
         }
     }
     if ($this->lblSignupEntryId) {
         $this->lblSignupEntryId->Text = $this->objClassRegistration->SignupEntry ? $this->objClassRegistration->SignupEntry->__toString() : null;
     }
     if ($this->lstClassMeeting) {
         $this->lstClassMeeting->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstClassMeeting->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objClassMeetingArray = ClassMeeting::LoadAll();
         if ($objClassMeetingArray) {
             foreach ($objClassMeetingArray as $objClassMeeting) {
                 $objListItem = new QListItem($objClassMeeting->__toString(), $objClassMeeting->SignupFormId);
                 if ($this->objClassRegistration->ClassMeeting && $this->objClassRegistration->ClassMeeting->SignupFormId == $objClassMeeting->SignupFormId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstClassMeeting->AddItem($objListItem);
             }
         }
     }
     if ($this->lblClassMeetingId) {
         $this->lblClassMeetingId->Text = $this->objClassRegistration->ClassMeeting ? $this->objClassRegistration->ClassMeeting->__toString() : null;
     }
     if ($this->lstPerson) {
         $this->lstPerson->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstPerson->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objPersonArray = Person::LoadAll();
         if ($objPersonArray) {
             foreach ($objPersonArray as $objPerson) {
                 $objListItem = new QListItem($objPerson->__toString(), $objPerson->Id);
                 if ($this->objClassRegistration->Person && $this->objClassRegistration->Person->Id == $objPerson->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstPerson->AddItem($objListItem);
             }
         }
     }
     if ($this->lblPersonId) {
         $this->lblPersonId->Text = $this->objClassRegistration->Person ? $this->objClassRegistration->Person->__toString() : null;
     }
     if ($this->lstClassGrade) {
         $this->lstClassGrade->RemoveAllItems();
         $this->lstClassGrade->AddItem(QApplication::Translate('- Select One -'), null);
         $objClassGradeArray = ClassGrade::LoadAll();
         if ($objClassGradeArray) {
             foreach ($objClassGradeArray as $objClassGrade) {
                 $objListItem = new QListItem($objClassGrade->__toString(), $objClassGrade->Id);
                 if ($this->objClassRegistration->ClassGrade && $this->objClassRegistration->ClassGrade->Id == $objClassGrade->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstClassGrade->AddItem($objListItem);
             }
         }
     }
     if ($this->lblClassGradeId) {
         $this->lblClassGradeId->Text = $this->objClassRegistration->ClassGrade ? $this->objClassRegistration->ClassGrade->__toString() : null;
     }
     if ($this->txtChildcareNotes) {
         $this->txtChildcareNotes->Text = $this->objClassRegistration->ChildcareNotes;
     }
     if ($this->lblChildcareNotes) {
         $this->lblChildcareNotes->Text = $this->objClassRegistration->ChildcareNotes;
     }
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  */
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['id'])) {
             $this->_model = ClassMeeting::model()->findbyPk($_GET['id']);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
     return $this->_model;
 }
Example #6
0
 public function populate_meetings($count)
 {
     $model = $this;
     ///XXX hack! have to inject the count directly since it won't substitute!
     $c = Yii::app()->db->createCommand("select school_day from school_calendar where day_off < 1 and minimum < 1 and dayofweek(school_day) = :dayofweek and school_day >= :startdate  and school_day <= :enddate limit {$count}");
     $r = $c->queryAll(true, array('dayofweek' => $model->day_of_week, 'startdate' => $model->session->start_date, 'enddate' => $model->session->end_date));
     foreach ($r as $i => $d) {
         $sc = new ClassMeeting();
         $sc->meeting_date = $d['school_day'];
         $sc->class_id = $model->id;
         // TODO: trap errors here somehow
         $sc->save();
     }
 }
Example #7
0
    /**
     * Deletes all associated ClassMeetings
     * @return void
     */
    public function DeleteAllClassMeetings()
    {
        if (is_null($this->intId)) {
            throw new QUndefinedPrimaryKeyException('Unable to call UnassociateClassMeeting on this unsaved ClassCourse.');
        }
        // Get the Database Object for this Class
        $objDatabase = ClassCourse::GetDatabase();
        // Journaling
        if ($objDatabase->JournalingDatabase) {
            foreach (ClassMeeting::LoadArrayByClassCourseId($this->intId) as $objClassMeeting) {
                $objClassMeeting->Journal('DELETE');
            }
        }
        // Perform the SQL Query
        $objDatabase->NonQuery('
				DELETE FROM
					`class_meeting`
				WHERE
					`class_course_id` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
    }
Example #8
0
 /**
  * Override method to perform a property "Get"
  * This will get the value of $strName
  *
  * @param string $strName Name of the property to get
  * @return mixed
  */
 public function __get($strName)
 {
     switch ($strName) {
         ///////////////////
         // Member Variables
         ///////////////////
         case 'Id':
             // Gets the value for intId (Read-Only PK)
             // @return integer
             return $this->intId;
         case 'SignupFormTypeId':
             // Gets the value for intSignupFormTypeId (Not Null)
             // @return integer
             return $this->intSignupFormTypeId;
         case 'MinistryId':
             // Gets the value for intMinistryId (Not Null)
             // @return integer
             return $this->intMinistryId;
         case 'Name':
             // Gets the value for strName
             // @return string
             return $this->strName;
         case 'Token':
             // Gets the value for strToken (Unique)
             // @return string
             return $this->strToken;
         case 'ActiveFlag':
             // Gets the value for blnActiveFlag
             // @return boolean
             return $this->blnActiveFlag;
         case 'ConfidentialFlag':
             // Gets the value for blnConfidentialFlag
             // @return boolean
             return $this->blnConfidentialFlag;
         case 'Description':
             // Gets the value for strDescription
             // @return string
             return $this->strDescription;
         case 'InformationUrl':
             // Gets the value for strInformationUrl
             // @return string
             return $this->strInformationUrl;
         case 'SupportEmail':
             // Gets the value for strSupportEmail (Not Null)
             // @return string
             return $this->strSupportEmail;
         case 'EmailNotification':
             // Gets the value for strEmailNotification
             // @return string
             return $this->strEmailNotification;
         case 'AllowOtherFlag':
             // Gets the value for blnAllowOtherFlag
             // @return boolean
             return $this->blnAllowOtherFlag;
         case 'AllowMultipleFlag':
             // Gets the value for blnAllowMultipleFlag
             // @return boolean
             return $this->blnAllowMultipleFlag;
         case 'SignupLimit':
             // Gets the value for intSignupLimit
             // @return integer
             return $this->intSignupLimit;
         case 'SignupMaleLimit':
             // Gets the value for intSignupMaleLimit
             // @return integer
             return $this->intSignupMaleLimit;
         case 'SignupFemaleLimit':
             // Gets the value for intSignupFemaleLimit
             // @return integer
             return $this->intSignupFemaleLimit;
         case 'FundingAccount':
             // Gets the value for strFundingAccount
             // @return string
             return $this->strFundingAccount;
         case 'DonationStewardshipFundId':
             // Gets the value for intDonationStewardshipFundId
             // @return integer
             return $this->intDonationStewardshipFundId;
         case 'DateCreated':
             // Gets the value for dttDateCreated (Not Null)
             // @return QDateTime
             return $this->dttDateCreated;
         case 'LoginNotRequiredFlag':
             // Gets the value for blnLoginNotRequiredFlag
             // @return boolean
             return $this->blnLoginNotRequiredFlag;
             ///////////////////
             // Member Objects
             ///////////////////
         ///////////////////
         // Member Objects
         ///////////////////
         case 'Ministry':
             // Gets the value for the Ministry object referenced by intMinistryId (Not Null)
             // @return Ministry
             try {
                 if (!$this->objMinistry && !is_null($this->intMinistryId)) {
                     $this->objMinistry = Ministry::Load($this->intMinistryId);
                 }
                 return $this->objMinistry;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'DonationStewardshipFund':
             // Gets the value for the StewardshipFund object referenced by intDonationStewardshipFundId
             // @return StewardshipFund
             try {
                 if (!$this->objDonationStewardshipFund && !is_null($this->intDonationStewardshipFundId)) {
                     $this->objDonationStewardshipFund = StewardshipFund::Load($this->intDonationStewardshipFundId);
                 }
                 return $this->objDonationStewardshipFund;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'ClassMeeting':
             // Gets the value for the ClassMeeting object that uniquely references this SignupForm
             // by objClassMeeting (Unique)
             // @return ClassMeeting
             try {
                 if ($this->objClassMeeting === false) {
                     // We've attempted early binding -- and the reverse reference object does not exist
                     return null;
                 }
                 if (!$this->objClassMeeting) {
                     $this->objClassMeeting = ClassMeeting::LoadBySignupFormId($this->intId);
                 }
                 return $this->objClassMeeting;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'EventSignupForm':
             // Gets the value for the EventSignupForm object that uniquely references this SignupForm
             // by objEventSignupForm (Unique)
             // @return EventSignupForm
             try {
                 if ($this->objEventSignupForm === false) {
                     // We've attempted early binding -- and the reverse reference object does not exist
                     return null;
                 }
                 if (!$this->objEventSignupForm) {
                     $this->objEventSignupForm = EventSignupForm::LoadBySignupFormId($this->intId);
                 }
                 return $this->objEventSignupForm;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
             ////////////////////////////
             // Virtual Object References (Many to Many and Reverse References)
             // (If restored via a "Many-to" expansion)
             ////////////////////////////
         ////////////////////////////
         // Virtual Object References (Many to Many and Reverse References)
         // (If restored via a "Many-to" expansion)
         ////////////////////////////
         case '_FormProduct':
             // Gets the value for the private _objFormProduct (Read-Only)
             // if set due to an expansion on the form_product.signup_form_id reverse relationship
             // @return FormProduct
             return $this->_objFormProduct;
         case '_FormProductArray':
             // Gets the value for the private _objFormProductArray (Read-Only)
             // if set due to an ExpandAsArray on the form_product.signup_form_id reverse relationship
             // @return FormProduct[]
             return (array) $this->_objFormProductArray;
         case '_FormQuestion':
             // Gets the value for the private _objFormQuestion (Read-Only)
             // if set due to an expansion on the form_question.signup_form_id reverse relationship
             // @return FormQuestion
             return $this->_objFormQuestion;
         case '_FormQuestionArray':
             // Gets the value for the private _objFormQuestionArray (Read-Only)
             // if set due to an ExpandAsArray on the form_question.signup_form_id reverse relationship
             // @return FormQuestion[]
             return (array) $this->_objFormQuestionArray;
         case '_SignupEntry':
             // Gets the value for the private _objSignupEntry (Read-Only)
             // if set due to an expansion on the signup_entry.signup_form_id reverse relationship
             // @return SignupEntry
             return $this->_objSignupEntry;
         case '_SignupEntryArray':
             // Gets the value for the private _objSignupEntryArray (Read-Only)
             // if set due to an ExpandAsArray on the signup_entry.signup_form_id reverse relationship
             // @return SignupEntry[]
             return (array) $this->_objSignupEntryArray;
         case '__Restored':
             return $this->__blnRestored;
         default:
             try {
                 return parent::__get($strName);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
     }
 }
 /**
  * Static Helper Method to Create using PK arguments
  * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
  * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
  * static helper methods.  Finally, specify a CreateType to define whether or not we are only allowed to 
  * edit, or if we are also allowed to create a new one, etc.
  * 
  * @param mixed $objParentObject QForm or QPanel which will be using this ClassMeetingMetaControl
  * @param integer $intSignupFormId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing ClassMeeting object creation - defaults to CreateOrEdit
  * @return ClassMeetingMetaControl
  */
 public static function Create($objParentObject, $intSignupFormId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intSignupFormId)) {
         $objClassMeeting = ClassMeeting::Load($intSignupFormId);
         // ClassMeeting was found -- return it!
         if ($objClassMeeting) {
             return new ClassMeetingMetaControl($objParentObject, $objClassMeeting);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a ClassMeeting object with PK arguments: ' . $intSignupFormId);
             }
         }
         // If EditOnly is specified, throw an exception
     } else {
         if ($intCreateType == QMetaControlCreateType::EditOnly) {
             throw new QCallerException('No PK arguments specified');
         }
     }
     // If we are here, then we need to create a new record
     return new ClassMeetingMetaControl($objParentObject, new ClassMeeting());
 }
Example #10
0
 public static function GetSoapArrayFromArray($objArray)
 {
     if (!$objArray) {
         return null;
     }
     $objArrayToReturn = array();
     foreach ($objArray as $objObject) {
         array_push($objArrayToReturn, ClassMeeting::GetSoapObjectFromObject($objObject, true));
     }
     return unserialize(serialize($objArrayToReturn));
 }