Ejemplo n.º 1
0
 public static function GenerateStewardship()
 {
     $dttDate = new QDateTime('2004-01-05');
     print 'Generating Stewardship... ';
     $objFundArray = StewardshipFund::QueryArray(QQ::NotEqual(QQN::StewardshipFund()->Id, 1));
     while ($dttDate->IsEarlierThan(QDateTime::Now())) {
         print $strDate = '[' . $dttDate->ToString('YYYY-MMM-DD') . ']';
         $intCheckCount = rand(10, 55);
         $arrStack = array();
         for ($i = 0; $i < floor(($intCheckCount - 1) / 25) + 1; $i++) {
             $arrStack[] = null;
         }
         $objBatch = StewardshipBatch::Create(self::GenerateFromArray(self::$StewardshipUserArray), $arrStack, self::GenerateFromArray(array('Weekend T/O', 'Weekend Giving', 'Tithes and Offerings', 'Tithes & Offerings', null)), $dttDate, $dttDate);
         $intStackCount = $objBatch->CountStewardshipStacks();
         $dttStart = new QDateTime($dttDate);
         $dttStart->SetTime(8, 0, 0);
         $dttEnd = new QDateTime($dttDate);
         $dttEnd->SetTime(16, 0, 0);
         for ($i = 0; $i < $intStackCount; $i++) {
             if ($i == $intStackCount - 1) {
                 if ($intCheckCount % 25 == 0) {
                     $intChecksInStackCount = 25;
                 } else {
                     $intChecksInStackCount = $intCheckCount % 25;
                 }
             } else {
                 $intChecksInStackCount = 25;
             }
             $objStack = StewardshipStack::LoadByStewardshipBatchIdStackNumber($objBatch->Id, $i + 1);
             for ($j = 0; $j < $intChecksInStackCount; $j++) {
                 $objHousehold = self::GenerateFromArray(self::$HouseholdArray);
                 $objHouseholdParticipant = self::GenerateFromArray($objHousehold->GetHouseholdParticipationArray());
                 $mixAmountArray = array();
                 if (rand(0, 50)) {
                     $mixAmountArray[] = array(1, rand(1000, 150000) / 100);
                 } else {
                     $mixAmountArray[] = array(self::GenerateFromArray($objFundArray)->Id, rand(1000, 150000) / 100);
                 }
                 if (!rand(0, 20)) {
                     $mixAmountArray[] = array(self::GenerateFromArray($objFundArray)->Id, rand(1000, 150000) / 100);
                 }
                 $objContribution = StewardshipContribution::Create($objBatch->CreatedByLogin, $objHouseholdParticipant->Person, $objStack, StewardshipContributionType::Check, rand(1000, 9999), $mixAmountArray, self::GenerateDateTime($dttStart, $dttEnd), null, null, null, false);
                 if (rand(0, 5)) {
                     $objContribution->SaveImageFile(__DEVTOOLS_CLI__ . '/datagen_file_assets/check.tif');
                 }
             }
             $objStack->RefreshActualTotalAmount();
         }
         if ($intCheckCount != $objBatch->CountStewardshipContributions()) {
             print "\r\n" . 'MISCOUNT: ' . $objBatch->Id . "\r\n";
         }
         $objBatch->RefreshActualTotalAmount();
         $dttDate->Day += 7;
         print str_repeat(chr(8) . ' ' . chr(8), strlen($strDate));
     }
     print "Done.\r\n";
 }
Ejemplo n.º 2
0
Archivo: batch.php Proyecto: alcf/chms
 public function Form_ProcessHash()
 {
     // /stewardship/batch.php/X#Y/verb/Z
     // X = Batch ID
     // Y = Stack # (*NOT* Stack ID)
     // Cleanup and Tokenize UrlHash Contents
     $strUrlHash = trim(strtolower($this->strUrlHash));
     $strUrlHashTokens = explode('/', $strUrlHash);
     // Get Values
     $intStackNumber = $strUrlHashTokens[0];
     $strCommand = array_key_exists(1, $strUrlHashTokens) ? $strUrlHashTokens[1] : null;
     $strUrlHashArgument = array_key_exists(2, $strUrlHashTokens) ? $strUrlHashTokens[2] : null;
     $strUrlHashArgument2 = array_key_exists(3, $strUrlHashTokens) ? $strUrlHashTokens[3] : null;
     $strUrlHashArgument3 = array_key_exists(4, $strUrlHashTokens) ? $strUrlHashTokens[4] : null;
     // Did we switch the stack?
     if (!$this->objStack || $this->objStack->StackNumber != $intStackNumber) {
         // Save the "Old" Stack (if applicable)
         $objOldStack = null;
         if ($this->objStack) {
             $objOldStack = $this->objStack;
         }
         // Set the "New" stack (and validate!)
         if ($intStackNumber) {
             $this->objStack = StewardshipStack::LoadByStewardshipBatchIdStackNumber($this->objBatch->Id, $intStackNumber);
             if (!$this->objStack) {
                 QApplication::Redirect('/stewardship/');
             }
         } else {
             $this->objStack = null;
         }
         // Refresh teh DataGrid and Stack in the stacklist
         $this->dtgContributions_Refresh();
         if ($this->objStack) {
             $this->pnlStack_Refresh($this->objStack);
         }
         if ($objOldStack) {
             $this->pnlStack_Refresh($objOldStack);
         }
         $this->pnlContent->CssClass = $this->objStack ? 'stewardshipContent' : null;
     }
     $this->pnlContent->RemoveChildControls(true);
     // Setup the Command
     if (!$strCommand) {
         $strCommand = 'view';
     }
     $strClassName = sprintf('CpStewardship_%s', QString::ConvertToCamelCase($strCommand));
     if (class_exists($strClassName, true)) {
         new $strClassName($this->pnlContent, 'content', $this->objBatch, $this->objStack, $strUrlHashArgument, $strUrlHashArgument2, $strUrlHashArgument3);
         QApplication::ExecuteJavaScript('ScrollToBottom();');
     } else {
         QApplication::Redirect('#1');
     }
 }