当前位置: 首页>>代码示例>>PHP>>正文


PHP X2Model::updateTimerTotals方法代码示例

本文整理汇总了PHP中X2Model::updateTimerTotals方法的典型用法代码示例。如果您正苦于以下问题:PHP X2Model::updateTimerTotals方法的具体用法?PHP X2Model::updateTimerTotals怎么用?PHP X2Model::updateTimerTotals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在X2Model的用法示例。


在下文中一共展示了X2Model::updateTimerTotals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionPublisherCreate


//.........这里部分代码省略.........
         $model->setX2Fields($_POST['Actions']);
         // format dates,
         if (isset($_POST[get_class($model)]['dueDate'])) {
             $model->dueDate = Formatter::parseDateTime($_POST[get_class($model)]['dueDate']);
         }
         if ($_POST['SelectedTab'] == 'new-event' || $_POST['SelectedTab'] == 'new-small-calendar-event') {
             $model->disableBehavior('changelog');
             $event = new Events();
             $event->type = 'calendar_event';
             $event->visibility = $model->visibility;
             $event->associationType = 'Actions';
             $event->timestamp = $model->dueDate;
             $model->type = 'event';
             if ($model->completeDate) {
                 $model->completeDate = Formatter::parseDateTime($model->completeDate);
             } else {
                 $model->completeDate = $model->dueDate;
             }
         }
         // format association
         if ($model->associationId == '') {
             $model->associationId = 0;
         }
         $association = $this->getAssociation($model->associationType, $model->associationId);
         if ($association) {
             $model->associationName = $association->name;
             if ($association->hasAttribute('lastActivity')) {
                 $association->lastActivity = time();
                 $association->update(array('lastActivity'));
                 X2Flow::trigger('RecordUpdateTrigger', array('model' => $association));
             }
         } else {
             $model->associationName = 'none';
         }
         if ($model->associationName == 'None' && $model->associationType != 'none') {
             $model->associationName = ucfirst($model->associationType);
         }
         if (in_array($_POST['SelectedTab'], array('log-a-call', 'new-comment', 'log-time-spent'))) {
             // Set the complete date accordingly:
             if (!empty($_POST[get_class($model)]['completeDate'])) {
                 $model->completeDate = Formatter::parseDateTime($_POST[get_class($model)]['completeDate']);
             }
             foreach (array('dueDate', 'completeDate') as $attr) {
                 if (empty($model->{$attr})) {
                     $model->{$attr} = time();
                 }
             }
             if ($model->dueDate > $model->completeDate) {
                 // User specified a negative time range! Let's say that the
                 // starting time is equal to when it ended (which is earlier)
                 $model->dueDate = $model->completeDate;
             }
             $model->complete = 'Yes';
             $model->visibility = '1';
             $model->assignedTo = Yii::app()->user->getName();
             $model->completedBy = Yii::app()->user->getName();
             if ($_POST['SelectedTab'] == 'log-a-call') {
                 $model->type = 'call';
             } elseif ($_POST['SelectedTab'] == 'log-time-spent') {
                 $model->type = 'time';
             } else {
                 $model->type = 'note';
             }
         }
         if (in_array($model->type, array('call', 'time', 'note'))) {
             $event = new Events();
             $event->associationType = 'Actions';
             $event->type = 'record_create';
             $event->user = Yii::app()->user->getName();
             $event->visibility = $model->visibility;
             $event->subtype = $model->type;
         }
         // save model
         $model->createDate = time();
         if (!empty($model->type)) {
             $model->disableBehavior('changelog');
         }
         if ($model->save()) {
             // action saved to database *
             if (isset($_POST['Actions']['reminder']) && $_POST['Actions']['reminder']) {
                 $model->createNotifications($_POST['notificationUsers'], $model->dueDate - $_POST['notificationTime'] * 60, 'action_reminder');
             }
             X2Model::updateTimerTotals($model->associationId, X2Model::getModelName($model->associationType));
             if (isset($event)) {
                 $event->associationId = $model->id;
                 $event->save();
             }
             $model->syncGoogleCalendar('create', true);
         } else {
             if ($model->hasErrors('verifyCode')) {
                 echo CJSON::encode(array('error' => $model->getError('verifyCode')));
                 Yii::app()->end();
             }
         }
         echo CJSON::encode(array('success'));
         Yii::app()->end();
     } else {
         throw new CHttpException(400, Yii::t('app', 'Bad request'));
     }
 }
开发者ID:shayanyi,项目名称:CRM,代码行数:101,代码来源:ActionsController.php


注:本文中的X2Model::updateTimerTotals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。