當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。