本文整理汇总了PHP中SugarDateTime类的典型用法代码示例。如果您正苦于以下问题:PHP SugarDateTime类的具体用法?PHP SugarDateTime怎么用?PHP SugarDateTime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SugarDateTime类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getDSTRange
/**
* @deprecated for public use
* get timezone start & end
*/
public function getDSTRange($year, $zone)
{
$year_date = SugarDateTime::createFromFormat("Y", $year, self::$gmtTimezone);
$year_end = clone $year_date;
$year_end->setDate((int) $year, 12, 31);
$year_end->setTime(23, 59, 59);
$year_date->setDate((int) $year, 1, 1);
$year_date->setTime(0, 0, 0);
$tz = $this->_getUserTZ();
$transitions = $tz->getTransitions($year_date->getTimestamp(), $year_end->getTimestamp());
$idx = 0;
while (!$transitions[$idx]["isdst"]) {
$idx++;
}
$startdate = new DateTime("@" . $transitions[$idx]["ts"], self::$gmtTimezone);
while ($transitions[$idx]["isdst"]) {
$idx++;
}
$enddate = new DateTime("@" . $transitions[$idx]["ts"], self::$gmtTimezone);
return array("start" => $this->asDb($startdate), "end" => $this->asDb($enddate));
}
开发者ID:nickpro,项目名称:sugarcrm_dev,代码行数:25,代码来源:TimeDate.php
示例2: getAgenda
public function getAgenda($api, $args)
{
// Fetch the next 14 days worth of meetings (limited to 20)
$end_time = new SugarDateTime("+14 days");
$start_time = new SugarDateTime("-1 hour");
$meeting = BeanFactory::newBean('Meetings');
$meetingList = $meeting->get_list('date_start', "date_start > " . $GLOBALS['db']->convert($GLOBALS['db']->quoted($start_time->asDb()), 'datetime') . " AND date_start < " . $GLOBALS['db']->convert($GLOBALS['db']->quoted($end_time->asDb()), 'datetime'));
// Setup the breaks for the various time periods
$datetime = new SugarDateTime();
$today_stamp = $datetime->get_day_end()->getTimestamp();
$tomorrow_stamp = $datetime->setDate($datetime->year, $datetime->month, $datetime->day + 1)->get_day_end()->getTimestamp();
$timeDate = TimeDate::getInstance();
$returnedMeetings = array('today' => array(), 'tomorrow' => array(), 'upcoming' => array());
foreach ($meetingList['list'] as $meetingBean) {
$meetingStamp = $timeDate->fromUser($meetingBean->date_start)->getTimestamp();
$meetingData = $this->formatBean($api, $args, $meetingBean);
if ($meetingStamp < $today_stamp) {
$returnedMeetings['today'][] = $meetingData;
} else {
if ($meetingStamp < $tomorrow_stamp) {
$returnedMeetings['tomorrow'][] = $meetingData;
} else {
$returnedMeetings['upcoming'][] = $meetingData;
}
}
}
return $returnedMeetings;
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:28,代码来源:MeetingsApi.php
示例3: get_time_data
/**
* Get array of needed time data
* @param SugarBean $bean
* @return array
*/
static function get_time_data($bean)
{
$arr = array();
$date_field = "date_start";
if ($bean->object_name == 'Task') {
$date_field = "date_due";
}
$timestamp = SugarDateTime::createFromFormat($GLOBALS['timedate']->get_date_time_format(), $bean->{$date_field}, new DateTimeZone('UTC'))->format('U');
$arr['timestamp'] = $timestamp;
$arr['time_start'] = $GLOBALS['timedate']->fromTimestamp($arr['timestamp'])->format($GLOBALS['timedate']->get_time_format());
return $arr;
}
开发者ID:netconstructor,项目名称:sugarcrm_dev,代码行数:17,代码来源:CalendarUtils.php
示例4: toDatabaseSearchDateTime
/**
* Set the DateTime Search Data based on Current User TimeZone
*
* @param string $userSearchDateTime - user Search Datetime
* @return string $dbSearchDateTime - database Search Datetime
*/
public function toDatabaseSearchDateTime($userSearchDateTime)
{
global $timedate;
global $current_user;
$usertimezone = $current_user->getPreference('timezone');
if (empty($usertimezone)) {
$usertimezone = "UTC";
}
$tz = new DateTimeZone($usertimezone);
$sugarDateTime = new SugarDateTime($userSearchDateTime);
$sugarDateTime->setTimezone($tz);
$dbSearchDateTime = $timedate->asDb($sugarDateTime);
return $dbSearchDateTime;
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:20,代码来源:Email.php
示例5: importSanitize
/**
* @see SugarFieldBase::importSanitize()
*/
public function importSanitize($value, $vardef, $focus, ImportFieldSanitize $settings)
{
global $timedate;
$format = $timedate->merge_date_time($settings->dateformat, $settings->timeformat);
if (!$timedate->check_matching_format($value, $format)) {
$parts = $timedate->split_date_time($value);
if (empty($parts[0])) {
$datepart = $timedate->getNow()->format($settings->dateformat);
} else {
$datepart = $parts[0];
}
if (empty($parts[1])) {
$timepart = $timedate->fromTimestamp(0)->format($settings->timeformat);
} else {
$timepart = $parts[1];
// see if we can get by stripping the seconds
if (strpos($settings->timeformat, 's') === false) {
$sep = $timedate->timeSeparatorFormat($settings->timeformat);
// We are assuming here seconds are the last component, which
// is kind of reasonable - no sane time format puts seconds first
$timeparts = explode($sep, $timepart);
if (!empty($timeparts[2])) {
$timepart = join($sep, array($timeparts[0], $timeparts[1]));
}
}
}
$value = $timedate->merge_date_time($datepart, $timepart);
if (!$timedate->check_matching_format($value, $format)) {
return false;
}
}
try {
$date = SugarDateTime::createFromFormat($format, $value, new DateTimeZone($settings->timezone));
} catch (Exception $e) {
return false;
}
return $date->asDb();
}
开发者ID:delkyd,项目名称:sugarcrm_dev,代码行数:41,代码来源:SugarFieldDatetime.php
示例6: saveRecurring
/**
* Save repeat activities
* @param SugarBean $bean
* @param array $timeArray array of datetimes
* @return array
*/
static function saveRecurring(SugarBean $bean, $timeArray)
{
// Here we will create single big inserting query for each invitee relationship
// rather than using relationships framework due to performance issues.
// Relationship framework runs very slowly
$db = $GLOBALS['db'];
$id = $bean->id;
$date_modified = $GLOBALS['timedate']->nowDb();
$lower_name = strtolower($bean->object_name);
$qu = "SELECT * FROM {$bean->rel_users_table} WHERE deleted = 0 AND {$lower_name}_id = '{$id}'";
$re = $db->query($qu);
$users_rel_arr = array();
// If the bean has a users_arr then related records for those ids will have
// already been created. This prevents duplicates of those records for
// users, contacts and leads (handled below)
$exclude_users = empty($bean->users_arr) ? array() : array_flip($bean->users_arr);
while ($ro = $db->fetchByAssoc($re)) {
if (!isset($exclude_users[$ro['user_id']])) {
$users_rel_arr[] = $ro['user_id'];
}
}
$qu = "SELECT * FROM {$bean->rel_contacts_table} WHERE deleted = 0 AND {$lower_name}_id = '{$id}'";
$re = $db->query($qu);
$contacts_rel_arr = array();
while ($ro = $db->fetchByAssoc($re)) {
$contacts_rel_arr[] = $ro['contact_id'];
}
$qu = "SELECT * FROM {$bean->rel_leads_table} WHERE deleted = 0 AND {$lower_name}_id = '{$id}'";
$re = $db->query($qu);
$leads_rel_arr = array();
while ($ro = $db->fetchByAssoc($re)) {
$leads_rel_arr[] = $ro['lead_id'];
}
$qu_contacts = array();
$qu_users = array();
$qu_leads = array();
$arr = array();
$i = 0;
Activity::disable();
$clone = clone $bean;
//this is a new bean being created - so throw away cloned fetched_row
//attribute that incorrectly makes it look like an existing bean
$clone->fetched_row = false;
foreach ($timeArray as $date_start) {
$clone->id = "";
$clone->date_start = $date_start;
// TODO CHECK DATETIME VARIABLE
$date = SugarDateTime::createFromFormat($GLOBALS['timedate']->get_date_time_format(), $date_start);
$date = $date->get("+{$bean->duration_hours} Hours")->get("+{$bean->duration_minutes} Minutes");
$date_end = $date->format($GLOBALS['timedate']->get_date_time_format());
$clone->date_end = $date_end;
$clone->recurring_source = "Sugar";
$clone->repeat_parent_id = $id;
$clone->update_vcal = false;
$clone->save(false);
if ($clone->id) {
foreach ($users_rel_arr as $user_id) {
$qu_users[] = array('id' => create_guid(), 'user_id' => $user_id, $lower_name . '_id' => $clone->id, 'date_modified' => $date_modified);
}
foreach ($contacts_rel_arr as $contact_id) {
$qu_contacts[] = array('id' => create_guid(), 'contact_id' => $contact_id, $lower_name . '_id' => $clone->id, 'date_modified' => $date_modified);
}
foreach ($leads_rel_arr as $lead_id) {
$qu_leads[] = array('id' => create_guid(), 'lead_id' => $lead_id, $lower_name . '_id' => $clone->id, 'date_modified' => $date_modified);
}
if ($i < 44) {
$clone->date_start = $date_start;
$clone->date_end = $date_end;
$arr[] = array_merge(array('id' => $clone->id), CalendarUtils::get_time_data($clone));
}
$i++;
}
}
Activity::enable();
if (!empty($qu_users)) {
$fields = array('id' => array('name' => 'id', 'type' => 'id'), 'user_id' => array('name' => 'user_id', 'type' => 'id'), $lower_name . '_id' => array('name' => $lower_name . '_id', 'type' => 'id'), 'date_modified' => array('name' => 'date_modified', 'type' => 'datetime'));
foreach ($qu_users as $qu_user) {
$db->insertParams($bean->rel_users_table, $fields, $qu_user);
}
}
if (!empty($qu_contacts)) {
$fields = array('id' => array('name' => 'id', 'type' => 'id'), 'contact_id' => array('name' => 'contact_id', 'type' => 'id'), $lower_name . '_id' => array('name' => $lower_name . '_id', 'type' => 'id'), 'date_modified' => array('name' => 'date_modified', 'type' => 'datetime'));
foreach ($qu_contacts as $qu_contact) {
$db->insertParams($bean->rel_contacts_table, $fields, $qu_contact);
}
}
if (!empty($qu_leads)) {
$fields = array('id' => array('name' => 'id', 'type' => 'id'), 'lead_id' => array('name' => 'lead_id', 'type' => 'id'), $lower_name . '_id' => array('name' => $lower_name . '_id', 'type' => 'id'), 'date_modified' => array('name' => 'date_modified', 'type' => 'datetime'));
foreach ($qu_leads as $qu_lead) {
$db->insertParams($bean->rel_leads_table, $fields, $qu_lead);
}
}
vCal::cache_sugar_vcal($GLOBALS['current_user']);
return $arr;
//.........这里部分代码省略.........
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:101,代码来源:CalendarUtils.php
示例7: fill_in_additional_detail_fields
function fill_in_additional_detail_fields()
{
global $locale;
// Fill in the assigned_user_name
$this->assigned_user_name = get_assigned_user_name($this->assigned_user_id);
if (!empty($this->contact_id)) {
$query = "SELECT first_name, last_name FROM contacts ";
$query .= "WHERE id='{$this->contact_id}' AND deleted=0";
$result = $this->db->limitQuery($query, 0, 1, true, " Error filling in additional detail fields: ");
// Get the contact name.
$row = $this->db->fetchByAssoc($result);
$GLOBALS['log']->info("additional call fields {$query}");
if ($row != null) {
$this->contact_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name'], '', '');
$GLOBALS['log']->debug("Call({$this->id}): contact_name = {$this->contact_name}");
$GLOBALS['log']->debug("Call({$this->id}): contact_id = {$this->contact_id}");
}
}
$this->created_by_name = get_assigned_user_name($this->created_by);
$this->modified_by_name = get_assigned_user_name($this->modified_user_id);
$this->fill_in_additional_parent_fields();
if (!isset($this->time_hour_start)) {
$this->time_start_hour = intval(substr($this->time_start, 0, 2));
}
//if-else
if (isset($this->time_minute_start)) {
$time_start_minutes = $this->time_minute_start;
} else {
$time_start_minutes = substr($this->time_start, 3, 5);
if ($time_start_minutes > 0 && $time_start_minutes < 15) {
$time_start_minutes = "15";
} else {
if ($time_start_minutes > 15 && $time_start_minutes < 30) {
$time_start_minutes = "30";
} else {
if ($time_start_minutes > 30 && $time_start_minutes < 45) {
$time_start_minutes = "45";
} else {
if ($time_start_minutes > 45) {
$this->time_start_hour += 1;
$time_start_minutes = "00";
}
}
}
}
//if-else
}
//if-else
if (isset($this->time_hour_start)) {
$time_start_hour = $this->time_hour_start;
} else {
$time_start_hour = intval(substr($this->time_start, 0, 2));
}
global $timedate;
$this->time_meridiem = $timedate->AMPMMenu('', $this->time_start, 'onchange="SugarWidgetScheduler.update_time();"');
$hours_arr = array();
$num_of_hours = 13;
$start_at = 1;
if (empty($time_meridiem)) {
$num_of_hours = 24;
$start_at = 0;
}
//if
for ($i = $start_at; $i < $num_of_hours; $i++) {
$i = $i . "";
if (strlen($i) == 1) {
$i = "0" . $i;
}
$hours_arr[$i] = $i;
}
//for
if (!isset($this->duration_minutes)) {
$this->duration_minutes = $this->minutes_value_default;
}
//setting default date and time
if (is_null($this->date_start)) {
$this->date_start = $timedate->now();
}
if (is_null($this->time_start)) {
$this->time_start = $timedate->to_display_time(TimeDate::getInstance()->nowDb(), true);
}
if (is_null($this->duration_hours)) {
$this->duration_hours = "0";
}
if (is_null($this->duration_minutes)) {
$this->duration_minutes = "1";
}
if (empty($this->id) && !empty($_REQUEST['date_start'])) {
$this->date_start = $_REQUEST['date_start'];
}
if (!empty($this->date_start)) {
$start = SugarDateTime::createFromFormat($GLOBALS['timedate']->get_date_time_format(), $this->date_start);
if (!empty($start)) {
if (!empty($this->duration_hours) || !empty($this->duration_minutes)) {
$this->date_end = $start->modify("+{$this->duration_hours} Hours +{$this->duration_minutes} Minutes")->format($GLOBALS['timedate']->get_date_time_format());
}
} else {
$GLOBALS['log']->fatal("Meeting::save: Bad date {$this->date_start} for format " . $GLOBALS['timedate']->get_date_time_format());
}
}
//.........这里部分代码省略.........
开发者ID:jgera,项目名称:sugarcrm_dev,代码行数:101,代码来源:Meeting.php
示例8: get_ical_event
/**
* get ics file content for meeting invite email
*/
public static function get_ical_event(SugarBean $bean, User $user)
{
$str = "";
$str .= "BEGIN:VCALENDAR\n";
$str .= "VERSION:2.0\n";
$str .= "PRODID:-//SugarCRM//SugarCRM Calendar//EN\n";
$str .= "BEGIN:VEVENT\n";
$str .= "UID:" . $bean->id . "\n";
$str .= "ORGANIZER;CN=" . $user->full_name . ":" . $user->email1 . "\n";
$str .= "DTSTART:" . SugarDateTime::createFromFormat($GLOBALS['timedate']->get_db_date_time_format(), $bean->date_start)->format(self::UTC_FORMAT) . "\n";
$str .= "DTEND:" . SugarDateTime::createFromFormat($GLOBALS['timedate']->get_db_date_time_format(), $bean->date_end)->format(self::UTC_FORMAT) . "\n";
$str .= "DTSTAMP:" . $GLOBALS['timedate']->getNow(false)->format(self::UTC_FORMAT) . "\n";
$str .= "SUMMARY:" . $bean->name . "\n";
$str .= "DESCRIPTION:" . $bean->description . "\n";
$str .= "END:VEVENT\n";
$str .= "END:VCALENDAR\n";
return $str;
}
开发者ID:jgera,项目名称:sugarcrm_dev,代码行数:21,代码来源:vCal.php
示例9: formatDate
/**
* Formats a DateTime object as string for given widget
*
* @param SugarDateTime $date - Date to be formatted for widget
* @return string date formatted for widget type
*/
protected function formatDate($date)
{
return $date->asDbDate(false);
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:10,代码来源:SugarWidgetFielddate.php
示例10: getGenericStartEndByDuration
/**
* @param integer $duration
* @param string|null $start_date The starting date in format of Y-m-d
* @return array
*/
public function getGenericStartEndByDuration($duration, $start_date = null)
{
$mapping = array('current' => 0, 'next' => 3, 'year' => 12);
if (array_key_exists($duration, $mapping)) {
$duration = $mapping[$duration];
} elseif (!is_numeric($duration)) {
$duration = 0;
}
$start = false;
if (!is_null($start_date)) {
$start = SugarDateTime::createFromFormat('Y-m-d', $start_date);
$end = SugarDateTime::createFromFormat('Y-m-d', $start_date);
}
if ($start === false) {
$start = new SugarDateTime();
$end = new SugarDateTime();
}
// since we subtract one from the month, we need to add one to the duration since php is
// not zero 0 based for months
// figure out what the starting month is.
$startMonth = floor(($start->month - 1) / 3) * 3 + $duration + 1;
$year = $start->year;
$endYear = $year;
$endMonth = $startMonth + 3;
// if the end month is dec, we put it to Jan and increase the end year as well so it goes back to the last
// day of dec
if ($endMonth == 12) {
$endYear++;
$endMonth = 1;
}
if ($duration == 12) {
$endYear++;
$startMonth = 1;
$endMonth = 1;
}
$start->setDate($year, $startMonth, 1);
$end->setDate($endYear, $endMonth, 0);
// since we are using timestamp, we need to convert this into UTC since that is
// what the DB is storing as
$tz = new DateTimeZone("UTC");
return array('start_date' => $start->asDbDate(false), 'start_date_timestamp' => $start->setTimezone($tz)->setTime(0, 0, 0)->format('U'), 'end_date' => $end->asDbDate(false), 'end_date_timestamp' => $end->setTimezone($tz)->setTime(0, 0, 0)->format('U'));
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:47,代码来源:TimePeriod.php
示例11: addTrackerFilter
protected static function addTrackerFilter(SugarQuery $q, SugarQuery_Builder_Where $where, $interval)
{
global $db;
$td = new SugarDateTime();
$td->modify($interval);
$min_date = $td->asDb();
// Have to do a subselect because MAX() and GROUP BY don't get along with
// databases other than MySQL
$q->joinRaw(" INNER JOIN ( SELECT t.item_id item_id, MAX(t.date_modified) track_max " . " FROM tracker t " . " WHERE t.module_name = '" . $db->quote($q->from->module_name) . "' " . " AND t.user_id = '" . $db->quote($GLOBALS['current_user']->id) . "' " . " AND t.date_modified >= " . $db->convert("'" . $min_date . "'", 'datetime') . " " . " GROUP BY t.item_id " . " ) tracker ON tracker.item_id = " . $q->from->getTableName() . ".id ", array('alias' => 'tracker'));
// Now, if they want tracker records, so let's order it by the tracker date_modified
$q->order_by = array();
$q->orderByRaw('tracker.track_max', 'DESC');
$q->distinct(false);
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:14,代码来源:FilterApi.php
示例12: formatDate
/**
* Formats a DateTime object as string for given widget
*
* @param SugarDateTime $date - Date to be formatted for widget
* @return string date formatted for widget type
*/
protected function formatDate($date)
{
return $date->asDb();
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:10,代码来源:SugarWidgetFielddatetime.php
示例13: getDSTRange
/**
* @deprecated for public use
* get timezone start & end
*/
public function getDSTRange($year, $zone)
{
$tz = $this->_getUserTZ();
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
$year_date = SugarDateTime::createFromFormat("Y", $year, self::$gmtTimezone);
$year_end = clone $year_date;
$year_end->setDate((int) $year, 12, 31);
$year_end->setTime(23, 59, 59);
$year_date->setDate((int) $year, 1, 1);
$year_date->setTime(0, 0, 0);
$transitions = $tz->getTransitions($year_date->getTimestamp(), $year_end->getTimestamp());
$idx = 0;
while (!$transitions[$idx]["isdst"]) {
$idx++;
}
$startdate = new DateTime("@" . $transitions[$idx]["ts"], self::$gmtTimezone);
while ($transitions[$idx]["isdst"]) {
$idx++;
}
$enddate = new DateTime("@" . $transitions[$idx]["ts"], self::$gmtTimezone);
} else {
$transitions = $tz->getTransitions();
$idx = 0;
while (!$transitions[$idx]["isdst"] || intval(substr($transitions[$idx]["time"], 0, 4)) < intval(date("Y"))) {
$idx++;
}
$startdate = new DateTime("@" . $transitions[$idx]["ts"], self::$gmtTimezone);
while ($transitions[$idx]["isdst"] || intval(substr($transitions[$idx]["time"], 0, 4)) < intval(date("Y"))) {
$idx++;
}
$enddate = new DateTime("@" . $transitions[$idx]["ts"], self::$gmtTimezone);
}
return array("start" => $this->asDb($startdate), "end" => $this->asDb($enddate));
}
开发者ID:rgauss,项目名称:sugarcrm_dev,代码行数:38,代码来源:TimeDate.php
示例14: getDSTRange
public function getDSTRange($current_user, $year)
{
$tz = $this->getUserTimezone($current_user);
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
$year_date = SugarDateTime::createFromFormat("Y", $year, $tz);
$year_end = clone $year_date;
$year_end->setDate((int) $year, 12, 31);
$year_end->setTime(23, 59, 59);
$year_date->setDate((int) $year, 1, 1);
$year_date->setTime(0, 0, 0);
$transitions = $tz->getTransitions($year_date->getTimestamp(), $year_end->getTimestamp());
$idx = 0;
while (!$transitions[$idx]["isdst"] && $idx < count($transitions)) {
$idx++;
}
if (!$transitions[$idx]["isdst"]) {
// No DST transitions found
return array();
}
$startTransition = $transitions[$idx];
while ($transitions[$idx]["isdst"]) {
$idx++;
}
$endTransition = $transitions[$idx];
} else {
$transitions = $tz->getTransitions();
$idx = 0;
while (!$transitions[$idx]["isdst"] || intval(substr($transitions[$idx]["time"], 0, 4)) < intval(date("Y"))) {
$idx++;
}
$startTransition = $transitions[$idx];
while ($transitions[$idx]["isdst"] || intval(substr($transitions[$idx]["time"], 0, 4)) < intval(date("Y"))) {
$idx++;
}
$endTransition = $transitions[$idx];
}
return array("start" => $startTransition, "end" => $endTransition);
}
开发者ID:rgauss,项目名称:sugar-ical-patch,代码行数:38,代码来源:iCal.php
示例15: save_repeat_activities
/**
* Save repeat activities
* @param SugarBean $bean
* @param array $time_arr array of datetimes
* @return array
*/
static function save_repeat_activities(SugarBean $bean, $time_arr)
{
// Here we will create single big inserting query for each invitee relationship
// rather than using relationships framework due to performance issues.
// Relationship framework runs very slowly
global $db;
$id = $bean->id;
$date_modified = $GLOBALS['timedate']->nowDb();
$lower_name = strtolower($bean->object_name);
$qu = "SELECT * FROM {$bean->rel_users_table} WHERE deleted = 0 AND {$lower_name}_id = '{$id}'";
$re = $db->query($qu);
$users_rel_arr = array();
while ($ro = $db->fetchByAssoc($re)) {
$users_rel_arr[] = $ro['user_id'];
}
$qu_users = "\n\t\t\t\tINSERT INTO {$bean->rel_users_table}\n\t\t\t\t(id,user_id,{$lower_name}_id,date_modified)\n\t\t\t\tVALUES\n\t\t";
$users_filled = false;
$qu = "SELECT * FROM {$bean->rel_contacts_table} WHERE deleted = 0 AND {$lower_name}_id = '{$id}'";
$re = $db->query($qu);
$contacts_rel_arr = array();
while ($ro = $db->fetchByAssoc($re)) {
$contacts_rel_arr[] = $ro['contact_id'];
}
$qu_contacts = "\n\t\t\t\tINSERT INTO {$bean->rel_contacts_table}\n\t\t\t\t(id,contact_id,{$lower_name}_id,date_modified)\n\t\t\t\tVALUES\n\t\t";
$contacts_filled = false;
$qu = "SELECT * FROM {$bean->rel_leads_table} WHERE deleted = 0 AND {$lower_name}_id = '{$id}'";
$re = $db->query($qu);
$leads_rel_arr = array();
while ($ro = $db->fetchByAssoc($re)) {
$leads_rel_arr[] = $ro['lead_id'];
}
$qu_leads = "\n\t\t\t\tINSERT INTO {$bean->rel_leads_table}\n\t\t\t\t(id,lead_id,{$lower_name}_id,date_modified)\n\t\t\t\tVALUES\n\t\t";
$leads_filled = false;
$arr = array();
$i = 0;
foreach ($time_arr as $date_start) {
$clone = $bean;
// we don't use clone keyword cause not necessary
$clone->id = "";
$clone->date_start = $date_start;
// TODO CHECK DATETIME VARIABLE
$date = SugarDateTime::createFromFormat($GLOBALS['timedate']->get_date_time_format(), $date_start);
$date = $date->get("+{$bean->duration_hours} Hours")->get("+{$bean->duration_minutes} Minutes");
$date_end = $date->format($GLOBALS['timedate']->get_date_time_format());
$clone->date_end = $date_end;
$clone->recurring_source = "Sugar";
$clone->repeat_parent_id = $id;
$clone->update_vcal = false;
$clone->save(false);
if ($clone->id) {
foreach ($users_rel_arr as $user_id) {
if ($users_filled) {
$qu_users .= "," . PHP_EOL;
}
$qu_users .= "('" . create_guid() . "','{$user_id}','{$clone->id}','{$date_modified}')";
$users_filled = true;
}
foreach ($contacts_rel_arr as $contact_id) {
if ($contacts_filled) {
$qu_contacts .= "," . PHP_EOL;
}
$qu_contacts .= "('" . create_guid() . "','{$contact_id}','{$clone->id}','{$date_modified}')";
$contacts_filled = true;
}
foreach ($leads_rel_arr as $lead_id) {
if ($leads_filled) {
$qu_leads .= "," . PHP_EOL;
}
$qu_leads .= "('" . create_guid() . "','{$lead_id}','{$clone->id}','{$date_modified}')";
$leads_filled = true;
}
if ($i < 44) {
$clone->date_start = $date_start;
$clone->date_end = $date_end;
$arr[] = array_merge(array('id' => $clone->id), CalendarUtils::get_time_data($clone));
}
$i++;
}
}
if ($users_filled) {
$db->query($qu_users);
}
if ($contacts_filled) {
$db->query($qu_contacts);
}
if ($leads_filled) {
$db->query($qu_leads);
}
vCal::cache_sugar_vcal($GLOBALS['current_user']);
return $arr;
}
开发者ID:sacredwebsite,项目名称:SuiteCRM,代码行数:97,代码来源:CalendarUtils.php
示例16: get_freebusy_activities
function get_freebusy_activities($user_focus, $start_date_time, $end_date_time)
{
$act_list = array();
$vcal_focus = new vCal();
$vcal_str = $vcal_focus->get_vcal_freebusy($user_focus);
$lines = explode("\n", $vcal_str);
$utc = new DateTimeZone("UTC");
foreach ($lines as $line) {
if (preg_match('/^FREEBUSY.*?:([^\\/]+)\\/([^\\/]+)/i', $line, $matches)) {
$dates_arr = array(SugarDateTime::createFromFormat(vCal::UTC_FORMAT, $matches[1], $utc), SugarDateTime::createFromFormat(vCal::UTC_FORMAT, $matches[2], $utc));
$act_list[] = new CalendarActivity($dates_arr);
}
}
return $act_list;
}
开发者ID:NALSS,项目名称:SuiteCRM,代码行数:15,代码来源:CalendarActivity.php
示例17: fill_in_additional_detail_fields
function fill_in_additional_detail_fields()
{
global $locale;
parent::fill_in_additional_detail_fields();
if (!empty($this->contact_id)) {
$query = "SELECT first_name, last_name FROM contacts ";
$query .= "WHERE id='{$this->contact_id}' AND deleted=0";
$result = $this->db->limitQuery($query, 0, 1, true, " Error filling in additional detail fields: ");
// Get the contact name.
$row = $this->db->fetchByAssoc($result);
$GLOBALS['log']->info("additional call fields {$query}");
if ($row != null) {
$this->contact_name = $locale->formatName('Contacts', $row);
$GLOBALS['log']->debug("Call({$this->id}): contact_name = {$this->contact_name}");
$GLOBALS['log']->debug("Call({$this->id}): contact_id = {$this->contact_id}");
}
}
if (!isset($this->time_hour_start)) {
$this->time_start_hour = intval(substr($this->time_start, 0, 2));
}
//if-else
if (isset($this->time_minute_start)) {
$time_start_minutes = $this->time_minute_start;
} else {
$time_start_minutes = substr($this->time_start, 3, 5);
if ($time_start_minutes > 0 && $time_start_minutes < 15) {
$time_start_minutes = "15";
} else {
if ($time_start_minutes > 15 && $time_start_minutes < 30) {
$time_start_minutes = "30";
} else {
if ($time_start_minutes > 30 && $time_start_minutes < 45) {
$time_start_minutes = "45";
} else {
if ($time_start_minutes > 45) {
$this->time_start_hour += 1;
$time_start_minutes = "00";
}
}
}
}
//if-else
}
//if-else
if (isset($this->time_hour_start)) {
$time_start_hour = $this->time_hour_start;
} else {
$time_start_hour = intval(substr($this->time_start, 0, 2));
}
global $timedate;
$this->time_meridiem = $timedate->AMPMMenu('', $this->time_start, 'onchange="SugarWidgetScheduler.update_time();"');
$hours_arr = array();
$num_of_hours = 13;
$start_at = 1;
if (empty($time_meridiem)) {
$num_of_hours = 24;
$start_at = 0;
}
//if
for ($i = $start_at; $i < $num_of_hours; $i++) {
$i = $i . "";
if (strlen($i) == 1) {
$i = "0" . $i;
}
$hours_arr[$i] = $i;
}
//for
if (!isset($this->duration_minutes)) {
$this->duration_minutes = $this->minutes_value_default;
}
//setting default date and time
if (is_null($this->date_start)) {
$this->date_start = $timedate->now();
}
if (is_null($this->time_start)) {
$this->time_start = $timedate->to_display_time(TimeDate::getInstance()->nowDb(), true);
}
if (is_null($this->duration_hours)) {
$this->duration_hours = "0";
}
if (is_null($this->duration_minutes)) {
$this->duration_minutes = "1";
}
if (empty($this->id) && !empty($_REQUEST['date_start'])) {
$this->date_start = $_REQUEST['date_start'];
}
if (!empty($this->date_start)) {
$td = SugarDateTime::createFromFormat($GLOBALS['timedate']->get_date_time_format(), $this->date_start);
if (!empty($td)) {
if (!empty($this->duration_hours) && $this->duration_hours != '') {
$td = $td->modify("+{$this->duration_hours} hours");
}
if (!empty($this->duration_minutes) && $this->duration_minutes != '') {
$td = $td->modify("+{$this->duration_minutes} mins");
}
$this->date_end = $td->format($GLOBALS['timedate']->get_date_time_format());
} else {
$GLOBALS['log']->fatal("Meeting::save: Bad date {$this->date_start} for format " . $GLOBALS['timedate']->get_date_time_format());
}
}
//.........这里部分代码省略.........
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:101,代码来源:Meeting.php
示例18: getRecentlyViewedQueryObject
/**
* Returns query object to retrieve list of recently viewed records by
* module.
*
* @param SugarBean $seed Instance of current bean.
* @param array $options Prepared options.
* @return SugarQuery query to execute.
*/
protected function getRecentlyViewedQueryObject($seed, $options)
{
$currentUser = $this->getUserBean();
$query = new SugarQuery();
$query->from($seed);
// FIXME: FRM-226, logic for these needs to be moved to SugarQuery
// Since tracker relationships don't actually exist, we're gonna have to add a direct join
$query->joinRaw(sprintf(" JOIN tracker ON tracker.item_id=%s.id AND tracker.module_name='%s' AND tracker.user_id='%s' ", $query->from->getTableName(), $query->from->module_name, $currentUser->id), array('alias' => 'tracker'));
// we need to set the linkName to hack around tracker not having real relationships
/* TODO think about how to fix this so we can be less restrictive to raw joins that don't have a relationship */
$query->join['tracker']->linkName = 'tracker';
$query->select(array('id', array('tracker.module_name', 'module_name')));
if (!empty($options['date'])) {
$td = new SugarDateTime();
$td->modify($options['date']);
$query->where()->queryAnd()->gte('tracker.date_modified', $td->asDb());
}
foreach ($query->select()->select as $v) {
$query->groupBy($v->table . '.' . $v->field);
}
$query->select()->fieldRaw('MAX(tracker.date_modified)', 'last_viewed_date');
return $query;
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:31,代码来源:RecentApi.php
示例19: testparseDateRange
/**
* @dataProvider dateRanges
*/
public function testparseDateRange($range, $start, $end)
{
$this->time_date->setNow(SugarDateTime::createFromFormat(TimeDate::DB_DATETIME_FORMAT, "2011-08-30 12:01:02", new DateTimeZone($this->time_date->userTimezone())));
$this->time_date->allow_cache = true;
$daterage = $this->time_date->parseDateRange($range);
$this->assertEquals($start, $daterage[0]->format(TimeDate::DB_DATETIME_FORMAT), 'Start date is wrong');
$this->assertEquals($end, $daterage[1]->format(TimeDate::DB_DATETIME_FORMAT), 'End date is wrong');
}
开发者ID:netconstructor,项目名称:sugarcrm_dev,代码行数:11,代码来源:TimeDateTest.php
示例20: getDSTRange
/**
* @deprecated for public use
* get timezone start & end
* @param $year
* @param string $zone
* @return array
*/
public function getDSTRange($year, $zone = null)
{
if (!empty($
|
请发表评论