Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
UpdateModelsLatestActivityDateTimeByMeetingJob.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
41  {
45  protected static $pageSize = 200;
46 
50  public static function getDisplayName()
51  {
53  return Zurmo::t('JobsManagerModule',
54  'Process MeetingsModulePluralLowerCaseLabel for related records latest activity dates',
55  $params);
56  }
57 
61  public static function getType()
62  {
63  return 'UpdateModelsLatestActivityDateTimeByMeeting';
64  }
65 
66  public static function getRecommendedRunFrequencyContent()
67  {
68  return Zurmo::t('Core', 'Once per hour.');
69  }
70 
77  public function run()
78  {
79  $processed = 0;
80  foreach (static::getModelsToProcess(self::$pageSize) as $meeting)
81  {
84  $meeting->activityItems, $meeting->startDateTime, 'Contact');
87  $meeting->activityItems, $meeting->startDateTime, 'Account');
88  $meeting->processedForLatestActivity = true;
89  $saved = $meeting->save();
90  if (!$saved)
91  {
92  throw new FailedToSaveModelException();
93  }
94  else
95  {
96  $processed++;
97  }
98  }
99 
100  $this->getMessageLogger()->addInfoMessage($this->resolveProcessedMessage($processed));
101  return true;
102  }
103 
110  protected function resolveProcessedMessage($processed)
111  {
113  $params['{count}'] = $processed;
114  if ($processed > 0 && $processed < 2)
115  {
116  return Zurmo::t('MeetingsModule', 'Processed {count} MeetingsModuleSingularLabel',
117  $params);
118  }
119  else
120  {
121  return Zurmo::t('MeetingsModule', 'Processed {count} MeetingsModulePluralLabel',
122  $params);
123  }
124  }
125 
130  public static function getModelsToProcess($pageSize)
131  {
132  assert('is_int($pageSize)');
133  $searchAttributeData = array();
134  $searchAttributeData['clauses'] = array(
135  1 => array(
136  'attributeName' => 'processedForLatestActivity',
137  'operatorType' => 'equals',
138  'value' => '0',
139  ),
140  2 => array(
141  'attributeName' => 'processedForLatestActivity',
142  'operatorType' => 'isNull',
143  'value' => null,
144  ),
145  3 => array(
146  'attributeName' => 'startDateTime',
147  'operatorType' => 'lessThan',
148  'value' => DateTimeUtil::convertTimestampToDbFormatDateTime(
149  Yii::app()->timeZoneHelper->convertFromLocalTimeStampForCurrentUser(time()))
150  ),
151  );
152  $searchAttributeData['structure'] = '(1 or 2) and 3';
153  $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('Meeting');
154  $where = RedBeanModelDataProvider::makeWhere('Meeting', $searchAttributeData, $joinTablesAdapter);
155  return Meeting::getSubset($joinTablesAdapter, null, $pageSize, $where, null);
156  }
157  }
158 ?>
static getTranslationParamsForAllModules()
Definition: LabelUtil.php:75
static resolveRelatedModelsAndSetLatestActivityDateTime($activityItems, $dateTime, $modelClassName)
static makeWhere($modelClassName, array $metadata, &$joinTablesAdapter)
static getSubset(RedBeanModelJoinTablesQueryAdapter $joinTablesAdapter=null, $offset=null, $count=null, $where=null, $orderBy=null, $modelClassName=null, $selectDistinct=false)
Generated on Fri Jul 3 2020 07:10:34
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.