public function Validate() { if (!parent::Validate()) { return false; } if ($this->strText != '') { $dttDateTime = new QDateTime($this->strText); if ($dttDateTime->IsDateNull()) { $this->strValidationError = QApplication::Translate("invalid date"); return false; } if (!is_null($this->Minimum)) { if ($dttDateTime->IsEarlierThan($this->Minimum)) { $this->strValidationError = QApplication::Translate("date is earlier than minimum allowed"); return false; } } if (!is_null($this->Maximum)) { if ($dttDateTime->IsLaterThan($this->Maximum)) { $this->strValidationError = QApplication::Translate("date is later than maximum allowed"); return false; } } } $this->strValidationError = ''; return true; }
/** * Validate the control. * @return bool */ public function Validate() { if (!parent::Validate()) { return false; } if ($this->strText != '') { $dttDateTime = new QDateTime($this->strText, null, QDateTime::DateOnlyType); if ($dttDateTime->IsDateNull()) { $this->ValidationError = QApplication::Translate("Invalid date"); return false; } if (!is_null($this->Minimum)) { if ($dttDateTime->IsEarlierThan($this->Minimum)) { if ($this->strMinDateErrorMsg) { $this->ValidationError = $this->strMinDateErrorMsg; } else { $this->ValidationError = QApplication::Translate("Date is earlier than minimum allowed"); } return false; } } if (!is_null($this->Maximum)) { if ($dttDateTime->IsLaterThan($this->Maximum)) { if ($this->strMaxDateErrorMsg) { $this->ValidationError = $this->strMaxDateErrorMsg; } else { $this->ValidationError = QApplication::Translate("Date is later than maximum allowed"); } return false; } } } return true; }
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"; }
/** * Returns the status (with hovertip) of a Receipt based on it's ReceivedFlag * * @param QDatagrid Object $objControl * @return string that says either Received or Pending with a hovertip if the Receipt is overdue */ public function __toStringStatusWithHovertip($objControl) { $dtsDueDate = new QDateTime($this->DueDate); $dtsToday = new QDateTime(date('Y-m-d')); if ($this->ReceivedFlag) { $strToReturn = 'Received'; } elseif ($this->DueDate && $dtsDueDate->IsEarlierThan($dtsToday)) { //$now = new QDateTime(QDateTime::Now); $dtsDifference = $dtsToday->Difference($dtsDueDate); $lblStatus = new QLabelExt($objControl); $lblStatus->HtmlEntities = false; $lblStatus->Text = '<strong style="color:#BC3500;">Pending</strong>'; // create hovertip $objHoverTip = new QHoverTip($lblStatus); $lblOverdue = new QLabel($objHoverTip); $lblOverdue->Text = $dtsDifference->Days == 0 ? 'Due today' : sprintf('%s days overdue', $dtsDifference->Days); $objHoverTip->AutoRenderChildren = true; $lblStatus->HoverTip = $objHoverTip; $strToReturn = $lblStatus->Render(false); } elseif ($this->DueDate && ($dtsDueDate->IsLaterThan($dtsToday) || $dtsDueDate->IsEqualTo($dtsToday))) { $dtsDifference = $dtsDueDate->Difference($dtsToday); $lblStatus = new QLabelExt($objControl); $lblStatus->HtmlEntities = false; $lblStatus->Text = '<strong style="color:#CC9933">Pending</strong>'; // create hovertip $objHoverTip = new QHoverTip($lblStatus); $lblDueIn = new QLabel($objHoverTip); $lblDueIn->Text = $dtsDifference->Days == 0 ? 'Due today' : sprintf('Due in %s days', $dtsDifference->Days); $objHoverTip->AutoRenderChildren = true; $lblStatus->HoverTip = $objHoverTip; $strToReturn = $lblStatus->Render(false); } else { $strToReturn = '<strong style="color:#CC9933;">Pending</strong>'; } return sprintf('%s', $strToReturn); }