/** * Main DataGen Runner * @return void */ public static function Run() { // Run "Fake Data" SQL Script $strFakeDataSql = file_get_contents(__DOCROOT__ . '/../database/fake_data.sql'); foreach (explode("\n", $strFakeDataSql) as $strSql) { $strSql = trim($strSql); if (strlen($strSql) && substr($strSql, 0, 1) != '#') { Person::GetDatabase()->NonQuery($strSql); } } self::$SystemStartDate = new QDateTime('1990-01-01'); self::$LifeStartDate = new QDateTime('1930-01-01'); self::$OldestChildBirthDate = QDateTime::Now(false); self::$OldestChildBirthDate->Year -= 18; // Get Cached Data self::$CommentCategoryArray = CommentCategory::LoadAll(); // Erase Directories exec('rm -r -f ' . __DOCROOT__ . '/../file_assets/head_shots'); exec('rm -r -f ' . __DOCROOT__ . '/../file_assets/contribution_images'); // Generate Stuff ChmsDataGen::GenerateMinistries(); ChmsDataGen::GenerateUsers(); ChmsDataGen::GenerateHouseholds(); ChmsDataGen::GenerateStewardship(); self::$MaxPersonId = Person::CountAll(); ChmsDataGen::GenerateCommunicationLists(); ChmsDataGen::GenerateGroups(); }
protected function dtgPersons_Bind() { // We must first let the datagrid know how many total items there are $this->dtgPersons->TotalItemCount = Person::CountAll(); // Next, we must be sure to load the data source, passing in the datagrid's // limit info into our loadall method. $this->dtgPersons->DataSource = Person::LoadAll(QQ::Clause($this->dtgPersons->OrderByClause, $this->dtgPersons->LimitClause)); }
protected function dtgPersons_Bind() { // We must first let the datagrid know how many total items there are // IMPORTANT: Do not pass a limit clause here to CountAll $this->dtgPersons->TotalItemCount = Person::CountAll(); // Ask the datagrid for the sorting information for the currently active sort column $clauses[] = $this->dtgPersons->OrderByClause; // Ask the datagrid for the Limit clause that will limit what portion of the data we will get from the database $clauses[] = $this->dtgPersons->LimitClause; // Next, we must be sure to load the data source, passing in the datagrid's // limit info into our loadall method. $this->dtgPersons->DataSource = Person::LoadAll($clauses); }
protected function Form_Create() { $count = 10000; Project::ClearCache(); Person::ClearCache(); // Create test persons in database. // Tiny objects if (Person::CountAll() < $count) { for ($i = 0; $i < $count; $i++) { $objPerson = new Person(); $objPerson->FirstName = 'FirstName' . $i; $objPerson->LastName = 'LastName' . $i; $objPerson->Save(); } } // Bigger objects with expansion if (Project::CountAll() < $count) { for ($i = 0; $i < $count; $i++) { $objProject = new Project(); $objProject->Name = 'Project' . $i; $objProject->ProjectStatusTypeId = ProjectStatusType::Open; $objProject->ManagerPersonId = $i % 1000 + 1000; $objProject->Description = 'Description' . $i; $objProject->StartDate = QDateTime::Now(); $objProject->EndDate = QDateTime::Now(); $objProject->Budget = $i; $objProject->Spent = 1; $objProject->Save(); } } $this->pnlTiny = new QPanel($this); $this->pnlTiny->Name = '10,000 Person Objects'; $this->pnlBig = new QPanel($this); $this->pnlBig->Name = '10,000 Project Objects With Expansion'; $this->btnGo = new QButton($this); $this->btnGo->Text = 'Go'; $this->btnGo->AddAction(new QClickEvent(), new QAjaxAction('Go_Click')); }
<br/> Project End Date: <?php _p($objProject->EndDate); ?> <br/> Project Budget: <?php _p($objProject->Budget); ?> <br/> <h3>Using LoadAll to get an Array of Person Objects</h3> <?php // We'll load all the persons into an array $objPersonArray = Person::LoadAll(); // Use foreach to iterate through that array and output the first and last // name of each person foreach ($objPersonArray as $objPerson) { printf('• ' . $objPerson->FirstName . ' ' . $objPerson->LastName . '<br/>'); } ?> <h3>Using CountAll to get a Count of All Persons in the Database</h3> There are <?php _p(Person::CountAll()); ?> person(s) in the system. <?php require __INCLUDES__ . '/examples/footer.inc.php';
protected function dtrPersons_Bind() { // This function defines how we load the data source into the Data Repeater $this->dtrPersons->TotalItemCount = Person::CountAll(); $this->dtrPersons->DataSource = Person::LoadAll(QQ::Clause($this->dtrPersons->LimitClause)); }
/** * Default / simple DataBinder for this Meta DataGrid. This can easily be overridden * by calling SetDataBinder() on this DataGrid with another DataBinder of your choice. * * 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). */ public function MetaDataBinder() { // Remember! We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below if ($this->Paginator) { $this->TotalItemCount = Person::CountAll(); } // Setup the $objClauses Array $objClauses = array(); // 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 Person, given the clauses above $this->DataSource = Person::LoadAll($objClauses); }
protected function dtgPersons_Bind() { // Let the datagrid know how many total items and then get the data source $this->dtgPersons->TotalItemCount = Person::CountAll(); $this->dtgPersons->DataSource = Person::LoadAll(QQ::Clause($this->dtgPersons->OrderByClause, $this->dtgPersons->LimitClause)); }
protected function dtgPersons_Bind() { // Specify the Total Item Count and Load in the Data Source $this->dtgPersons->TotalItemCount = Person::CountAll(); $this->dtgPersons->DataSource = Person::LoadAll(QQ::Clause($this->dtgPersons->OrderByClause, $this->dtgPersons->LimitClause)); }
<?php $objParameters = new QCliParameterProcessor('zipcode-locater', 'Zipcode locater Script'); $objParameters->AddDefaultParameter('zipcode', QCliParameterType::String, 'Zipcode to search for'); $objParameters->Run(); $zipcode = $objParameters->GetDefaultValue('zipcode'); $objPersonCursor = Person::QueryCursor(QQ::All()); QDataGen::DisplayForEachTaskStart('Checking for Persons in zipcode', Person::CountAll()); print "\n"; while ($objPerson = Person::InstantiateCursor($objPersonCursor)) { QDataGen::DisplayForEachTaskNext('Checking for Persons in zipcode'); if ($objPerson->MembershipStatusTypeId == MembershipStatusType::Member) { $objAddressArray = $objPerson->GetAllAssociatedAddressArray(); foreach ($objAddressArray as $objAddress) { if (strstr($objAddress->ZipCode, $zipcode) != false) { print $objPerson->FirstName . " " . $objPerson->LastName . ": " . $objAddress->Address1 . ", " . $objAddress->City . ", " . $objAddress->ZipCode . "\n"; } } } } //$test = new Address(); //$test->City QDataGen::DisplayForEachTaskEnd('Checking for Persons in zipcode');
protected function Form_Create() { $this->iTotalPersonCount = Person::CountAll(); $this->ethnicityArray = AttributeValue::LoadEthnicityArray(); $objEthnicityArray = array(); foreach ($this->ethnicityArray as $key => $val) { $objEthnicityItem = new ethnicityItem($key, $val); $objEthnicityArray[] = $objEthnicityItem; } $this->dtgEthnicity = new QDataGrid($this); $this->dtgEthnicity->AddColumn(new QDataGridColumn('Ethnicity', '<?= $_ITEM->key; ?>', 'Width=270px')); $this->dtgEthnicity->AddColumn(new QDataGridColumn('Count', '<?= $_ITEM->value; ?>', 'Width=270px')); $this->dtgEthnicity->DataSource = $objEthnicityArray; $this->dtgAfricanAmericanGroup = new QDataGrid($this); $this->dtgAfricanAmericanGroup->AddColumn(new QDataGridColumn('Ethnicity', '<?= $_ITEM->key; ?>', 'Width=270px')); $this->dtgAfricanAmericanGroup->AddColumn(new QDataGridColumn('Count', '<?= $_ITEM->value; ?>', 'Width=270px')); $this->dtgAsianGroup = new QDataGrid($this); $this->dtgAsianGroup->AddColumn(new QDataGridColumn('Ethnicity', '<?= $_ITEM->key; ?>', 'Width=270px')); $this->dtgAsianGroup->AddColumn(new QDataGridColumn('Count', '<?= $_ITEM->value; ?>', 'Width=270px')); $this->dtgHispanicGroup = new QDataGrid($this); $this->dtgHispanicGroup->AddColumn(new QDataGridColumn('Ethnicity', '<?= $_ITEM->key; ?>', 'Width=270px')); $this->dtgHispanicGroup->AddColumn(new QDataGridColumn('Count', '<?= $_ITEM->value; ?>', 'Width=270px')); $this->dtgEuropeanGroup = new QDataGrid($this); $this->dtgEuropeanGroup->AddColumn(new QDataGridColumn('Ethnicity', '<?= $_ITEM->key; ?>', 'Width=270px')); $this->dtgEuropeanGroup->AddColumn(new QDataGridColumn('Count', '<?= $_ITEM->value; ?>', 'Width=270px')); $this->dtgPacificIslanderGroup = new QDataGrid($this); $this->dtgPacificIslanderGroup->AddColumn(new QDataGridColumn('Ethnicity', '<?= $_ITEM->key; ?>', 'Width=270px')); $this->dtgPacificIslanderGroup->AddColumn(new QDataGridColumn('Count', '<?= $_ITEM->value; ?>', 'Width=270px')); $this->dtgIndianGroup = new QDataGrid($this); $this->dtgIndianGroup->AddColumn(new QDataGridColumn('Ethnicity', '<?= $_ITEM->key; ?>', 'Width=270px')); $this->dtgIndianGroup->AddColumn(new QDataGridColumn('Count', '<?= $_ITEM->value; ?>', 'Width=270px')); $this->dtgOtherGroup = new QDataGrid($this); $this->dtgOtherGroup->AddColumn(new QDataGridColumn('Ethnicity', '<?= $_ITEM->key; ?>', 'Width=270px')); $this->dtgOtherGroup->AddColumn(new QDataGridColumn('Count', '<?= $_ITEM->value; ?>', 'Width=270px')); // African American Group $this->africanAmericanGroup = $this->ethnicityArray["africanAmerican"] + $this->ethnicityArray["africanAmericanNative"] + $this->ethnicityArray["africanAmericanItalian"] + $this->ethnicityArray["africanAmericanCaucasian"]; $objAfricanAmericanArray = array(); $objEthnicityItem = new ethnicityItem("African American", $this->ethnicityArray["africanAmerican"]); $objAfricanAmericanArray[] = $objEthnicityItem; $objEthnicityItem = new ethnicityItem("African American Native", $this->ethnicityArray["africanAmericanNative"]); $objAfricanAmericanArray[] = $objEthnicityItem; $objEthnicityItem = new ethnicityItem("African American Italian", $this->ethnicityArray["africanAmericanItalian"]); $objAfricanAmericanArray[] = $objEthnicityItem; $objEthnicityItem = new ethnicityItem("African American Caucasian", $this->ethnicityArray["africanAmericanCaucasian"]); $objAfricanAmericanArray[] = $objEthnicityItem; $this->dtgAfricanAmericanGroup->DataSource = $objAfricanAmericanArray; // Asian Group $this->asianGroup = $this->ethnicityArray["asian"] + $this->ethnicityArray["chinese"] + $this->ethnicityArray["chineseAmerican"] + $this->ethnicityArray["filipino"] + $this->ethnicityArray["filipinoPuertoRican"] + $this->ethnicityArray["japanese"] + $this->ethnicityArray["japaneseCaucasian"] + $this->ethnicityArray["koreanAmerican"] + $this->ethnicityArray["vietnamese"]; $objAsianArray = array(); $objEthnicityItem = new ethnicityItem("Asian", $this->ethnicityArray["asian"]); $objAsianArray[] = $objEthnicityItem; $objEthnicityItem = new ethnicityItem("Chinese", $this->ethnicityArray["chinese"]); $objAsianArray[] = $objEthnicityItem; $objEthnicityItem = new ethnicityItem("Chinese American", $this->ethnicityArray["chineseAmerican"]); $objAsianArray[] = $objEthnicityItem; $objEthnicityItem = new ethnicityItem("Filipino", $this->ethnicityArray["filipino"]); $objAsianArray[] = $objEthnicityItem; $objEthnicityItem = new ethnicityItem("Filipino/Puerto Rican", $this->ethnicityArray["filipinoPuertoRican"]); $objAsianArray[] = $objEthnicityItem; $objEthnicityItem = new ethnicityItem("Japanese", $this->ethnicityArray["japanese"]); $objAsianArray[] = $objEthnicityItem; $objEthnicityItem = new ethnicityItem("Japanese Caucasian", $this->ethnicityArray["japaneseCaucasian"]); $objAsianArray[] = $objEthnicityItem; $objEthnicityItem = new ethnicityItem("Korean/American", $this->ethnicityArray["koreanAmerican"]); $objAsianArray[] = $objEthnicityItem; $objEthnicityItem = new ethnicityItem("Vietnamese", $this->ethnicityArray["vietnamese"]); $objAsianArray[] = $objEthnicityItem; $this->dtgAsianGroup->DataSource = $objAsianArray; // Hispanic/Latino Group $this->hispanicGroup = $this->ethnicityArray["hispanic"] + $this->ethnicityArray["hispanicBrazilian"] + $this->ethnicityArray["hispanicLatino"] + $this->ethnicityArray["latino"]; $objHispanicArray = array(); $objEthnicityItem = new ethnicityItem("Hispanic", $this->ethnicityArray["hispanic"]); $objHispanicArray[] = $objEthnicityItem; $objEthnicityItem = new ethnicityItem("Hispanic/Brazilian", $this->ethnicityArray["hispanicBrazilian"]); $objHispanicArray[] = $objEthnicityItem; $objEthnicityItem = new ethnicityItem("Hispanic/Latino", $this->ethnicityArray["hispanicLatino"]); $objHispanicArray[] = $objEthnicityItem; $objEthnicityItem = new ethnicityItem("Latino", $this->ethnicityArray["latino"]); $objHispanicArray[] = $objEthnicityItem; $this->dtgHispanicGroup->DataSource = $objHispanicArray; // European Group $this->europeanGroup = $this->ethnicityArray["british"] + $this->ethnicityArray["greek"] + $this->ethnicityArray["spanish"] + $this->ethnicityArray["swiss"]; $objEuropeanArray = array(); $objEthnicityItem = new ethnicityItem("British", $this->ethnicityArray["british"]); $objEuropeanArray[] = $objEthnicityItem; $objEthnicityItem = new ethnicityItem("Greek", $this->ethnicityArray["greek"]); $objEuropeanArray[] = $objEthnicityItem; $objEthnicityItem = new ethnicityItem("Spanish", $this->ethnicityArray["spanish"]); $objEuropeanArray[] = $objEthnicityItem; $objEthnicityItem = new ethnicityItem("Swiss", $this->ethnicityArray["swiss"]); $objEuropeanArray[] = $objEthnicityItem; $this->dtgEuropeanGroup->DataSource = $objEuropeanArray; // Pacific Islander Group $this->pacificIslanderGroup = $this->ethnicityArray["hawaiian"] + $this->ethnicityArray["polynesian"] + $this->ethnicityArray["samoan"] + $this->ethnicityArray["tongan"]; $objIslanderArray = array(); $objEthnicityItem = new ethnicityItem("Hawaiian", $this->ethnicityArray["hawaiian"]); $objIslanderArray[] = $objEthnicityItem; $objEthnicityItem = new ethnicityItem("Polynesian", $this->ethnicityArray["polynesian"]); $objIslanderArray[] = $objEthnicityItem; $objEthnicityItem = new ethnicityItem("Samoan", $this->ethnicityArray["samoan"]); $objIslanderArray[] = $objEthnicityItem; $objEthnicityItem = new ethnicityItem("Tongan", $this->ethnicityArray["tongan"]); $objIslanderArray[] = $objEthnicityItem; $this->dtgPacificIslanderGroup->DataSource = $objIslanderArray; // Indian Group $this->indianGroup = $this->ethnicityArray["indian"] + $this->ethnicityArray["sriLankan"]; $objIndianArray = array(); $objEthnicityItem = new ethnicityItem("Indian", $this->ethnicityArray["indian"]); $objIndianArray[] = $objEthnicityItem; $objEthnicityItem = new ethnicityItem("Sri Lankan", $this->ethnicityArray["sriLankan"]); $objIndianArray[] = $objEthnicityItem; $this->dtgIndianGroup->DataSource = $objIndianArray; // Others Group $this->otherGroup = $this->ethnicityArray["caucasian"] + $this->ethnicityArray["brazilian"] + $this->ethnicityArray["middleEastern"] + $this->ethnicityArray["ethiopian"] + $this->ethnicityArray["other"]; $objOtherArray = array(); $objEthnicityItem = new ethnicityItem("Caucasian", $this->ethnicityArray["caucasian"]); $objOtherArray[] = $objEthnicityItem; $objEthnicityItem = new ethnicityItem("Brazilian", $this->ethnicityArray["brazilian"]); $objOtherArray[] = $objEthnicityItem; $objEthnicityItem = new ethnicityItem("Middle Eastern", $this->ethnicityArray["middleEastern"]); $objOtherArray[] = $objEthnicityItem; $objEthnicityItem = new ethnicityItem("Ethiopian", $this->ethnicityArray["ethiopian"]); $objOtherArray[] = $objEthnicityItem; $objEthnicityItem = new ethnicityItem("Other", $this->ethnicityArray["other"]); $objOtherArray[] = $objEthnicityItem; $this->dtgOtherGroup->DataSource = $objOtherArray; }
protected function lg_Bind() { $this->lg->TotalItemCount = Person::CountAll(); $clauses[] = $this->lg->LimitClause; $this->lg->DataSource = Person::LoadAll($clauses); }
protected function dtgPerson_Bind() { // Get Total Count b/c of Pagination $this->dtgPerson->TotalItemCount = Person::CountAll(); $objClauses = array(); if ($objClause = $this->dtgPerson->OrderByClause) { array_push($objClauses, $objClause); } if ($objClause = $this->dtgPerson->LimitClause) { array_push($objClauses, $objClause); } $this->dtgPerson->DataSource = Person::LoadAll($objClauses); }
<?php $objPersonCursor = Person::QueryCursor(QQ::All()); QDataGen::DisplayForEachTaskStart('Refreshing Person data', Person::CountAll()); while ($objPerson = Person::InstantiateCursor($objPersonCursor)) { QDataGen::DisplayForEachTaskNext('Refreshing Person data'); $objPerson->RefreshAge(false); $objPerson->RefreshMaritalStatusTypeId(false); $objPerson->RefreshMembershipStatusTypeId(false); $objPerson->RefreshPrimaryContactInfo(true); $objPerson->RefreshNameItemAssociations(); } QDataGen::DisplayForEachTaskEnd('Refreshing Person data'); $objHouseholdCursor = Household::QueryCursor(QQ::All()); QDataGen::DisplayForEachTaskStart('Refreshing Household data', Household::CountAll()); while ($objHousehold = Household::InstantiateCursor($objHouseholdCursor)) { QDataGen::DisplayForEachTaskNext('Refreshing Household data'); $objHousehold->RefreshMembers(false); $objMarriedPersonArray = array(); foreach ($objHousehold->GetHouseholdParticipationArray() as $objParticipation) { if ($objParticipation->Person->MaritalStatusTypeId == MaritalStatusType::Married && $objParticipation->Person->CountMarriages() == 1) { $objMarriedPersonArray[] = $objParticipation->Person; } } if (count($objMarriedPersonArray) == 2) { $objMarriedPersonArray[0]->DeleteAllMarriages(); $objMarriedPersonArray[1]->DeleteAllMarriages(); $objMarriedPersonArray[0]->CreateMarriageWith($objMarriedPersonArray[1]); } else { if (count($objMarriedPersonArray)) { print "\r\nWhat!? Household " . $objHousehold->Id . " has a marriage count of " . count($objMarriedPersonArray) . "!\r\n";
<?php $objPersonCursor = Person::QueryCursor(QQ::All()); QDataGen::DisplayForEachTaskStart('Removing Duplicate Addresses from Person', Person::CountAll()); while ($objPerson = Person::InstantiateCursor($objPersonCursor)) { QDataGen::DisplayForEachTaskNext('Removing Duplicate Addresses from Person'); $objPerson->RemoveDuplicateAddresses(); } QDataGen::DisplayForEachTaskEnd('Removing Duplicate Addresses from Person');
<?php $objPersonCursor = Person::QueryCursor(QQ::All()); QDataGen::DisplayForEachTaskStart('Checking for Multiple First Names in Person', Person::CountAll()); print "\n"; while ($objPerson = Person::InstantiateCursor($objPersonCursor)) { QDataGen::DisplayForEachTaskNext('Checking for Multiple First Names in Person'); $pos = strpos($objPerson->FirstName, " and "); if ($pos !== false) { print "Found Multiple First Name: " . $objPerson->FirstName . "\n"; } $pos = strpos($objPerson->FirstName, "&"); if ($pos !== false) { print "Found Multiple First Name: " . $objPerson->FirstName . "\n"; } } QDataGen::DisplayForEachTaskEnd('Checking for Multiple First Names in Person');