示例#1
0
文件: datagen.cli.php 项目: alcf/chms
 /**
  * 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();
 }
示例#2
0
 public function MoveDown()
 {
     $blnFound = false;
     foreach (CommentCategory::LoadAll(QQ::OrderBy(QQN::CommentCategory()->OrderNumber)) as $objObject) {
         if ($blnFound) {
             break;
         }
         if ($objObject->Id == $this->Id) {
             $blnFound = true;
         }
     }
     $this->OrderNumber++;
     $this->Save();
     if ($objObject) {
         $objObject->OrderNumber--;
         $objObject->Save();
     }
     self::RefreshOrderNumber();
 }
示例#3
0
 /**
  * Refresh this MetaControl with Data from the local Comment object.
  * @param boolean $blnReload reload Comment from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objComment->Reload();
     }
     if ($this->lblId) {
         if ($this->blnEditMode) {
             $this->lblId->Text = $this->objComment->Id;
         }
     }
     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->objComment->Person && $this->objComment->Person->Id == $objPerson->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstPerson->AddItem($objListItem);
             }
         }
     }
     if ($this->lblPersonId) {
         $this->lblPersonId->Text = $this->objComment->Person ? $this->objComment->Person->__toString() : null;
     }
     if ($this->lstPostedByLogin) {
         $this->lstPostedByLogin->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstPostedByLogin->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objPostedByLoginArray = Login::LoadAll();
         if ($objPostedByLoginArray) {
             foreach ($objPostedByLoginArray as $objPostedByLogin) {
                 $objListItem = new QListItem($objPostedByLogin->__toString(), $objPostedByLogin->Id);
                 if ($this->objComment->PostedByLogin && $this->objComment->PostedByLogin->Id == $objPostedByLogin->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstPostedByLogin->AddItem($objListItem);
             }
         }
     }
     if ($this->lblPostedByLoginId) {
         $this->lblPostedByLoginId->Text = $this->objComment->PostedByLogin ? $this->objComment->PostedByLogin->__toString() : null;
     }
     if ($this->lstCommentPrivacyType) {
         $this->lstCommentPrivacyType->SelectedValue = $this->objComment->CommentPrivacyTypeId;
     }
     if ($this->lblCommentPrivacyTypeId) {
         $this->lblCommentPrivacyTypeId->Text = $this->objComment->CommentPrivacyTypeId ? CommentPrivacyType::$NameArray[$this->objComment->CommentPrivacyTypeId] : null;
     }
     if ($this->lstCommentCategory) {
         $this->lstCommentCategory->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstCommentCategory->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objCommentCategoryArray = CommentCategory::LoadAll();
         if ($objCommentCategoryArray) {
             foreach ($objCommentCategoryArray as $objCommentCategory) {
                 $objListItem = new QListItem($objCommentCategory->__toString(), $objCommentCategory->Id);
                 if ($this->objComment->CommentCategory && $this->objComment->CommentCategory->Id == $objCommentCategory->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstCommentCategory->AddItem($objListItem);
             }
         }
     }
     if ($this->lblCommentCategoryId) {
         $this->lblCommentCategoryId->Text = $this->objComment->CommentCategory ? $this->objComment->CommentCategory->__toString() : null;
     }
     if ($this->txtComment) {
         $this->txtComment->Text = $this->objComment->Comment;
     }
     if ($this->lblComment) {
         $this->lblComment->Text = $this->objComment->Comment;
     }
     if ($this->calDatePosted) {
         $this->calDatePosted->DateTime = $this->objComment->DatePosted;
     }
     if ($this->lblDatePosted) {
         $this->lblDatePosted->Text = sprintf($this->objComment->DatePosted) ? $this->objComment->__toString($this->strDatePostedDateTimeFormat) : null;
     }
     if ($this->calDateAction) {
         $this->calDateAction->DateTime = $this->objComment->DateAction;
     }
     if ($this->lblDateAction) {
         $this->lblDateAction->Text = sprintf($this->objComment->DateAction) ? $this->objComment->__toString($this->strDateActionDateTimeFormat) : null;
     }
 }