本文整理汇总了PHP中Bitrix\Main\Type\DateTime::getFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTime::getFormat方法的具体用法?PHP DateTime::getFormat怎么用?PHP DateTime::getFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bitrix\Main\Type\DateTime
的用法示例。
在下文中一共展示了DateTime::getFormat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onBeforeSave
/**
* @param array $userfield
* @param Type\Date|string $value
*
* @return Type\Date
*/
public function onBeforeSave($userfield, $value)
{
if (strlen($value) && !$value instanceof Type\Date) {
// try both site's format - short and full
try {
$value = new Type\Date($value);
} catch (Main\ObjectException $e) {
$value = new Type\Date($value, Type\DateTime::getFormat());
}
}
return $value;
}
示例2: register
/**
* @return boolean
*/
public static function register($ownerID, array $entityFields = null, array $options = null)
{
if (!is_int($ownerID)) {
$ownerID = (int) $ownerID;
}
if ($ownerID <= 0) {
throw new Main\ArgumentException('Owner ID must be greater than zero.', 'ownerID');
}
if (!is_array($options)) {
$options = array();
}
$date = isset($options['DATE']) ? $options['DATE'] : null;
if ($date === null) {
$date = new Date();
}
$day = (int) $date->format('d');
$month = (int) $date->format('m');
$quarter = $month <= 3 ? 1 : ($month <= 6 ? 2 : ($month <= 9 ? 3 : 4));
$year = (int) $date->format('Y');
if (!is_array($entityFields)) {
$dbResult = \CCrmDeal::GetListEx(array(), array('=ID' => $ownerID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('STAGE_ID', 'ASSIGNED_BY_ID', 'BEGINDATE', 'CLOSEDATE'));
$entityFields = is_object($dbResult) ? $dbResult->Fetch() : null;
if (!is_array($entityFields)) {
return false;
}
}
$stageID = isset($entityFields['STAGE_ID']) ? $entityFields['STAGE_ID'] : '';
$semanticID = \CCrmDeal::GetSemanticID($stageID);
$isLost = PhaseSemantics::isLost($semanticID);
$responsibleID = isset($entityFields['ASSIGNED_BY_ID']) ? (int) $entityFields['ASSIGNED_BY_ID'] : 0;
$callQty = 0;
$meetingQty = 0;
$emailQty = 0;
$startTime = new DateTime($date->format(DateTime::getFormat()));
$endTime = new DateTime($date->format(DateTime::getFormat()));
$endTime->setTime(23, 59, 59);
$query = new Query(Crm\ActivityTable::getEntity());
$query->addSelect('TYPE_ID');
$query->registerRuntimeField('', new ExpressionField('QTY', 'COUNT(*)'));
$query->addSelect('QTY');
$query->addFilter('=COMPLETED', 'Y');
$query->addFilter('>=DEADLINE', $startTime);
$query->addFilter('<=DEADLINE', $endTime);
$query->addGroup('TYPE_ID');
$subQuery = new Query(Crm\ActivityBindingTable::getEntity());
$subQuery->addSelect('ACTIVITY_ID');
$subQuery->addFilter('=OWNER_TYPE_ID', \CCrmOwnerType::Deal);
$subQuery->addFilter('=OWNER_ID', $ownerID);
$query->registerRuntimeField('', new ReferenceField('B', Base::getInstanceByQuery($subQuery), array('=this.ID' => 'ref.ACTIVITY_ID'), array('join_type' => 'INNER')));
$dbResult = $query->exec();
while ($stats = $dbResult->fetch()) {
$typeID = isset($stats['TYPE_ID']) ? (int) $stats['TYPE_ID'] : 0;
$qty = isset($stats['QTY']) ? (int) $stats['QTY'] : 0;
if ($typeID === \CCrmActivityType::Call) {
$callQty = $qty;
} elseif ($typeID === \CCrmActivityType::Meeting) {
$meetingQty = $qty;
} elseif ($typeID === \CCrmActivityType::Email) {
$emailQty = $qty;
}
}
if ($callQty === 0 && $meetingQty === 0 && $emailQty === 0) {
DealActivityStatisticsTable::delete(array('OWNER_ID' => $ownerID, 'DEADLINE_DATE' => $date));
return true;
}
$present = self::get($ownerID, $date);
if (is_array($present)) {
if ($responsibleID === (int) $present['RESPONSIBLE_ID'] && $stageID === $present['STAGE_ID'] && $callQty === (int) $present['CALL_QTY'] && $meetingQty === (int) $present['MEETING_QTY'] && $emailQty === (int) $present['EMAIL_QTY']) {
return false;
}
if ($responsibleID !== (int) $present['RESPONSIBLE_ID']) {
DealActivityStatisticsTable::synchronize($ownerID, array('RESPONSIBLE_ID' => $responsibleID));
}
}
$data = array('OWNER_ID' => $ownerID, 'DEADLINE_DATE' => $date, 'DEADLINE_YEAR' => $year, 'DEADLINE_QUARTER' => $quarter, 'DEADLINE_MONTH' => $month, 'DEADLINE_DAY' => $day, 'RESPONSIBLE_ID' => $responsibleID, 'STAGE_SEMANTIC_ID' => $semanticID, 'STAGE_ID' => $stageID, 'IS_LOST' => $isLost ? 'Y' : 'N', 'CALL_QTY' => $callQty, 'MEETING_QTY' => $meetingQty, 'EMAIL_QTY' => $emailQty);
DealActivityStatisticsTable::upsert($data);
return true;
}