Exemple #1
0
 public function renderAttribute($attr, $makeLinks = true, $textOnly = true, $encode = true)
 {
     if ($attr === 'text') {
         $action = Actions::model();
         $action->actionDescription = $this->{$attr};
         return $action->renderAttribute('actionDescription', $makeLinks, $textOnly, $encode);
     }
 }
Exemple #2
0
 /**
  * Creates the widget. 
  */
 public function run()
 {
     list($assignedToCondition, $params) = Actions::model()->getAssignedToCondition();
     $total = Yii::app()->db->createCommand("\n            select count(*)\n            from x2_actions\n            where {$assignedToCondition} and (type='' or type is null)\n        ")->queryScalar($params);
     $incomplete = Yii::app()->db->createCommand("\n            select count(*)\n            from x2_actions\n            where {$assignedToCondition} and (type='' or type is null) and complete='No'\n        ")->queryScalar($params);
     $overdue = Actions::model()->countByAttributes(array('assignedTo' => Yii::app()->user->getName(), 'complete' => 'No'), 'dueDate < ' . time() . ' AND (type="" OR type IS NULL)');
     $complete = Actions::model()->countByAttributes(array('completedBy' => Yii::app()->user->getName(), 'complete' => 'Yes'), 'type="" OR type IS NULL');
     $this->render('actionMenu', array('total' => $total, 'unfinished' => $incomplete, 'overdue' => $overdue, 'complete' => $complete));
 }
 public function run()
 {
     $total = Actions::model()->findAllByAttributes(array('assignedTo' => Yii::app()->user->getName(), 'type' => null));
     $total = count($total);
     $temp = Actions::model()->findAllByAttributes(array('assignedTo' => Yii::app()->user->getName(), 'complete' => 'No', 'type' => null));
     $unfinished = count($temp);
     $overdue = 0;
     foreach ($temp as $action) {
         if ($action->dueDate < time()) {
             $overdue++;
         }
     }
     $complete = Actions::model()->findAllByAttributes(array('completedBy' => Yii::app()->user->getName(), 'complete' => 'Yes', 'type' => null));
     $complete = count($complete);
     $this->render('actionMenu', array('total' => $total, 'unfinished' => $unfinished, 'overdue' => $overdue, 'complete' => $complete));
 }
Exemple #4
0
 public function assertActionCreated($type, $message = null)
 {
     $action = Actions::model()->findBySql("SELECT * FROM x2_actions WHERE type='{$type}' ORDER BY createDate DESC,id DESC LIMIT 1");
     $this->assertTrue((bool) $action, "Failed asserting that an action was created. {$type}");
     $associatedModel = X2Model::getAssociationModel($action->associationType, $action->associationId);
     // Test that the models are identical:
     $this->eml->targetModel->refresh();
     foreach (array('myModelName', 'id', 'name', 'lastUpdated', 'createDate', 'assignedTo', 'status') as $property) {
         if ($this->eml->targetModel->hasProperty($property) && $associatedModel->hasProperty($property)) {
             $this->assertEquals($this->eml->targetModel->{$property}, $associatedModel->{$property}, "Failed asserting that an action's associated model record was the same, property: {$property}. {$message}");
         }
     }
     // Assert that the username fields are set properly:
     foreach (array('assignedTo', 'completedBy') as $attr) {
         $this->assertEquals('testuser', $action->assignedTo, "Failed asserting that {$attr} was set properly on the action record. {$message}");
     }
 }
 public function actionWhatsNew()
 {
     if (!Yii::app()->user->isGuest) {
         $user = User::model()->findByPk(Yii::app()->user->getId());
         $lastLogin = $user->lastLogin;
         $contacts = Contacts::model()->findAll("lastUpdated > {$lastLogin} ORDER BY lastUpdated DESC LIMIT 50");
         $actions = Actions::model()->findAll("lastUpdated > {$lastLogin} AND (assignedTo='" . Yii::app()->user->getName() . "' OR assignedTo='Anyone') ORDER BY lastUpdated DESC LIMIT 50");
         $sales = Sales::model()->findAll("lastUpdated > {$lastLogin} ORDER BY lastUpdated DESC LIMIT 50");
         $accounts = Accounts::model()->findAll("lastUpdated > {$lastLogin} ORDER BY lastUpdated DESC LIMIT 50");
         $arr = array_merge($contacts, $actions, $sales, $accounts);
         $records = Record::convert($arr);
         $dataProvider = new CArrayDataProvider($records, array('id' => 'id', 'pagination' => array('pageSize' => ProfileChild::getResultsPerPage()), 'sort' => array('attributes' => array('lastUpdated', 'name'))));
         $this->render('whatsNew', array('records' => $records, 'dataProvider' => $dataProvider));
     } else {
         $this->redirect('login');
     }
 }
 public function testMigration()
 {
     $model = $this->contacts('contact935');
     $workflowActions = Actions::model()->findAllByAttributes(array('associationType' => 'contacts', 'associationId' => $model->id, 'type' => 'workflow'));
     $this->assertEquals(4, count($workflowActions));
     $stage1 = $this->workflowStages('stage1');
     $stage1Action = Actions::model()->findByAttributes(array('associationType' => 'contacts', 'associationId' => $model->id, 'type' => 'workflow', 'workflowId' => 2, 'stageNumber' => 1));
     $this->assertInstanceOf('Actions', $stage1Action);
     $this->assertEquals($stage1->workflowId, $stage1Action->workflowId);
     $this->assertEquals($stage1->stageNumber, $stage1Action->stageNumber);
     //Confirm that saving an action with non-existent stageNumber is okay
     $badAction = new Actions();
     $badAction->type = 'workflow';
     $badAction->workflowId = 2;
     $badAction->stageNumber = -1;
     $badAction->associationType = 'contacts';
     $badAction->associationId = $model->id;
     $this->assertSaves($badAction);
     //Confirm that saving an action with non-existent workflowId is okay
     $badAction->stageNumber = 1;
     $badAction->workflowId = -1;
     $this->assertSaves($badAction);
     //Confirm that saving an action with non-existent workflowId and stageNumber is okay
     $badAction->stageNumber = -1;
     $this->assertSaves($badAction);
     //Confirm that saving duplicate workflow stages is okay
     $badAction2 = new Actions();
     $badAction2->type = 'workflow';
     $badAction2->workflowId = -1;
     $badAction2->stageNumber = -1;
     $badAction2->associationType = 'contacts';
     $badAction2->associationId = $model->id;
     $this->assertSaves($badAction2);
     //Non-duplicate action to confirm deletion of actions with bad workflowId
     $badAction3 = new Actions();
     $badAction3->type = 'workflow';
     $badAction3->workflowId = -99;
     $badAction3->stageNumber = 1;
     $badAction3->associationType = 'contacts';
     $badAction3->associationId = $model->id;
     $this->assertSaves($badAction3);
     //Non-duplicate action to confirm deletion of actions with bad stageNumber
     $badAction4 = new Actions();
     $badAction4->type = 'workflow';
     $badAction4->workflowId = 2;
     $badAction4->stageNumber = -99;
     $badAction4->associationType = 'contacts';
     $badAction4->associationId = $model->id;
     $this->assertSaves($badAction4);
     $workflowActions = Actions::model()->findAllByAttributes(array('associationType' => 'contacts', 'associationId' => $model->id, 'type' => 'workflow'));
     $this->assertEquals(8, count($workflowActions));
     $this->runMigrationScript();
     $workflowActions = Actions::model()->findAllByAttributes(array('associationType' => 'contacts', 'associationId' => $model->id, 'type' => 'workflow'));
     $this->assertEquals(4, count($workflowActions));
     $this->assertNull(Actions::model()->findByPk($badAction->id));
     $this->assertNull(Actions::model()->findByPk($badAction2->id));
     $this->assertNull(Actions::model()->findByPk($badAction3->id));
     $this->assertNull(Actions::model()->findByPk($badAction4->id));
     $stage1ActionPostMigrate = Actions::model()->findByPK($stage1Action->id);
     $this->assertEquals($stage1->workflowId, $stage1ActionPostMigrate->workflowId);
     $this->assertEquals($stage1->id, $stage1ActionPostMigrate->stageNumber);
     //Fails new foreign key constraint
     $badAction5 = new Actions();
     $badAction5->type = 'workflow';
     $badAction5->workflowId = 2;
     $badAction5->stageNumber = -1;
     $badAction5->associationType = 'contacts';
     $badAction5->associationId = $model->id;
     try {
         $badAction5->save();
         $this->assertFalse(true);
     } catch (CDbException $e) {
         $this->assertTrue(true);
     }
     //Fails new unique constraint
     $badAction6 = new Actions();
     $badAction6->type = 'workflow';
     $badAction6->workflowId = 2;
     $badAction6->stageNumber = 5;
     $badAction6->associationType = 'contacts';
     $badAction6->associationId = $model->id;
     try {
         $badAction6->save();
         $this->assertFalse(true);
     } catch (CDbException $e) {
         $this->assertTrue(true);
     }
 }
 public function actionDeleteAction()
 {
     if (isset($_POST['id'])) {
         $id = $_POST['id'];
         $action = Actions::model()->findByPk($id);
         $profile = ProfileChild::model()->findByAttributes(array('username' => $action->assignedTo));
         $profile->deleteGoogleCalendarEvent($action);
         // update action in Google Calendar if user has a Google Calendar
         $action->delete();
     }
 }
 /**
  * Retrieve calendar events for a given user happening between two specified
  * dates.
  * @param string|integer $calendarUser Username or group ID whose calendar
  *  events are to be loaded and returned
  * @param type $start Beginning time range
  * @param type $end End time range
  * @param mixed $includePublic Set to 1 or boolean true to include all
  *  calendar events 
  * @return array An array of action records
  */
 public function calendarActions($calendarUser, $start, $end)
 {
     $filter = explode(',', $this->currentUser->calendarFilter);
     // action types user doesn't want filtered
     $staticAction = Actions::model();
     // View permissions for the viewing user
     $criteria = $staticAction->getAccessCriteria();
     // Assignment condition: all events for the user whose calendar is being viewed:
     $criteria->addCondition('`assignedTo` REGEXP BINARY :unameRegex');
     $permissionsBehavior = Yii::app()->params->modelPermissions;
     $criteria->params[':unameRegex'] = $permissionsBehavior::getUserNameRegex($calendarUser);
     // Action type filters:
     $criteria->addCondition(self::constructFilterClause($filter));
     $criteria->addCondition("`type` IS NULL OR `type`='' OR `type`!='quotes'");
     $criteria->addCondition('(`dueDate` >= :start1 AND `dueDate` <= :end1) ' . 'OR (`completeDate` >= :start2 AND `completeDate` <= :end2)');
     $criteria->params = array_merge($criteria->params, array(':start1' => $start, ':start2' => $start, ':end1' => $end, ':end2' => $end));
     return Actions::model()->findAllWithoutActionText($criteria);
 }
 public function testRecordEmailSent()
 {
     $contact = $this->contacts('testUser');
     $campaign = $this->campaign('testUser');
     $now = time();
     CampaignMailingBehavior::recordEmailSent($campaign, $contact);
     $action = Actions::model()->findByAttributes(array('associationType' => 'contacts', 'associationId' => $contact->id, 'type' => 'email'));
     $this->assertTrue((bool) $action);
     $this->assertTrue(abs($action->completeDate - $now) <= 1);
 }
Exemple #10
0
 private function assertEmailOpenAction($model)
 {
     $action = Actions::model()->findByAttributes(array('associationType' => $model->module, 'associationId' => $model->id, 'type' => 'emailOpened'));
     $this->assertNotNull($action);
     //Make sure the module text is correct in the open text
     $openText = Modules::displayName(false, $model->module) . ' has opened the email sent on';
     $this->assertNotFalse(strpos($action->actionDescription, $openText));
 }
 public function actionDelete($id)
 {
     $model = $this->loadModel($id);
     if (Yii::app()->request->isPostRequest) {
         $event = new Events();
         $event->type = 'record_deleted';
         $event->associationType = $this->modelClass;
         $event->associationId = $model->id;
         $event->text = $model->name;
         $event->user = Yii::app()->user->getName();
         $event->save();
         Actions::model()->deleteAll('associationId=' . $id . ' AND associationType=\'x2Leads\'');
         $this->cleanUpTags($model);
         $model->delete();
     } else {
         throw new CHttpException(400, Yii::t('app', 'Invalid request. Please do not repeat this request again.'));
     }
     // if AJAX request (triggered by deletion via admin grid view), we should not redirect
     // the browser
     if (!isset($_GET['ajax'])) {
         $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('index'));
     }
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Actions the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Actions::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 public function actionDelete_user($id)
 {
     if ($user = Users::model()->findByPk($id)) {
         $admin = new Users();
         $admin_id = $admin->getAdminId();
         $new_responsible = $user->parent_id != null ? $user->parent_id : $admin_id;
         Clients::model()->updateAll(array('responsable_id' => $new_responsible, 'creator_id' => $new_responsible), 'responsable_id=' . $id);
         Deals::model()->updateAll(array('responsable_id' => $new_responsible), 'responsable_id=' . $id);
         Actions::model()->updateAll(array('responsable_id' => $new_responsible), 'responsable_id=' . $id);
         $user->delete();
         $this->redirect(array('user_info'));
     }
 }
            <?php 
    }
    ?>
        <?php 
}
?>
        <span class="photo_by">photo by <a href="">Nesterenko Sergey</a></span>
      </div>
    </div>
    <div class="slider">
      <ul class="slider__wrapper">
        <li class="slider__item"><div class="box"><img src="/img/slide-1.jpg" alt=""></div></li>
      </ul>
    </div>
<?php 
$actions = Actions::model()->findAllBySql('select * from {{actions}} where date_end>=:date_end and picture<>"" order by rand() limit 4', array(':date_end' => date('Y-m-d')));
if (count($actions) > 0) {
    ?>
    <div class="wrapper wrapper--users-promotions">
      <section class="container">
        <div class="container__title-wrapper">
          <h5 class="container__title">АКЦИИ УЧАСТНИКОВ</h5>
        </div>
        <div class="action-blocks-wrapper">
<?php 
    foreach ($actions as $action) {
        $act_user = Users::model()->findByPk($action['uid']);
        $new_price = $action['price'] - round($action['price'] * $action['sale'] / 100);
        ?>

                <a class="action-block" href="/actions/<?php 
 public function getSearchList()
 {
     $res = array();
     $occ = Occupation::model()->findAll();
     foreach ($occ as $item) {
         $action = Actions::model()->countBySql('select id from {{actions}} where occupation_id="' . $item->id . '" and date_end>="' . date('Y-m-d') . '"');
         if ($action > 0) {
             $res[$item->id] = $item->name;
         }
     }
     $res_list = '';
     foreach ($res as $k => $v) {
         $res_list .= '<option value="' . $k . '">' . $v . '</option>';
     }
     return $res;
 }
 public function actionDelete()
 {
     switch ($_GET['model']) {
         // Load the respective model
         case 'Contacts':
             $model = Contacts::model()->findByPk($_GET['id']);
             break;
         case 'Actions':
             $model = Actions::model()->findByPk($_GET['id']);
             break;
         case 'Accounts':
             $model = Accounts::model()->findByPk($_GET['id']);
             break;
         default:
             $this->_sendResponse(501, sprintf('Error: Mode <b>delete</b> is not implemented for model <b>%s</b>', $_GET['model']));
             exit;
     }
     // Was a model found? If not, raise an error
     if (is_null($model)) {
         $this->_sendResponse(400, sprintf("Error: Didn't find any model <b>%s</b> with ID <b>%s</b>.", $_GET['model'], $_GET['id']));
     }
     // Delete the model
     $num = $model->delete();
     if ($num > 0) {
         $this->_sendResponse(200, sprintf("Model <b>%s</b> with ID <b>%s</b> has been deleted.", $_GET['model'], $_GET['id']));
     } else {
         $this->_sendResponse(500, sprintf("Error: Couldn't delete model <b>%s</b> with ID <b>%s</b>.", $_GET['model'], $_GET['id']));
     }
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Actions::model('Actions')->findByPk((int) $id);
     //$dueDate=$model->dueDate;
     //$model=Actions::changeDates($model);
     // if($model->associationId!=0) {
     // $model->associationName = $this->parseName(array($model->associationType,$model->associationId));
     // } else
     // $model->associationName = 'None';
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 public function actionQuickDelete($id)
 {
     $model = $this->loadModel($id);
     if ($model) {
         // delete associated actions
         Actions::model()->deleteAllByAttributes(array('associationId' => $id, 'associationType' => 'quotes'));
         // delete product relationships
         QuoteProduct::model()->deleteAllByAttributes(array('quoteId' => $id));
         // delete contact relationships
         Relationships::model()->deleteAllByAttributes(array('firstType' => 'quotes', 'firstId' => $id, 'secondType' => 'contacts'));
         $name = $model->name;
         // generate history
         $contact = Contacts::model()->findByPk($_GET['contactId']);
         $action = new Actions();
         $action->associationType = 'contacts';
         $action->type = 'quotes';
         $action->associationId = $contact->id;
         $action->associationName = $contact->name;
         $action->assignedTo = Yii::app()->user->getName();
         $action->completedBy = Yii::app()->user->getName();
         $action->createDate = time();
         $action->dueDate = time();
         $action->completeDate = time();
         $action->visibility = 1;
         $action->complete = 'Yes';
         $action->actionDescription = "Deleted Quote: <span style=\"font-weight:bold;\">{$model->id}</span> {$model->name}";
         $action->save();
         $this->cleanUpTags($model);
         $model->delete();
     } else {
         throw new CHttpException(400, Yii::t('app', 'Invalid request. Please do not repeat this request again.'));
     }
     if ($_GET['contactId']) {
         Yii::app()->clientScript->scriptMap['*.js'] = false;
         $contact = Contacts::model()->findByPk($_GET['contactId']);
         $this->renderPartial('quoteFormWrapper', array('model' => $contact), false, true);
     }
 }
Exemple #19
0
 public function getText(array $params = array(), array $htmlOptions = array())
 {
     $truncated = array_key_exists('truncated', $params) ? $params['truncated'] : false;
     $requireAbsoluteUrl = array_key_exists('requireAbsoluteUrl', $params) ? $params['requireAbsoluteUrl'] : false;
     $text = "";
     $authorText = "";
     if (Yii::app()->user->getName() == $this->user) {
         $authorText = CHtml::link(Yii::t('app', 'You'), Yii::app()->controller->createAbsoluteUrl('/profile/view', array('id' => Yii::app()->user->getId())), $htmlOptions);
     } else {
         $authorText = User::getUserLinks($this->user);
     }
     if (!empty($authorText)) {
         $authorText .= " ";
     }
     switch ($this->type) {
         case 'notif':
             $parent = X2Model::model('Notification')->findByPk($this->associationId);
             if (isset($parent)) {
                 $text = $parent->getMessage();
             } else {
                 $text = Yii::t('app', "Notification not found");
             }
             break;
         case 'record_create':
             $actionFlag = false;
             if (class_exists($this->associationType)) {
                 if (count(X2Model::model($this->associationType)->findAllByPk($this->associationId)) > 0) {
                     if ($this->associationType == 'Actions') {
                         $action = X2Model::model('Actions')->findByPk($this->associationId);
                         if (isset($action) && (strcasecmp($action->associationType, 'contacts') === 0 || in_array($action->type, array('call', 'note', 'time')))) {
                             // Special considerations for publisher-created actions, i.e. call,
                             // note, time, and anything associated with a contact
                             $actionFlag = true;
                             // Retrieve the assigned user from the related action
                             $relatedAction = Actions::model()->findByPk($this->associationId);
                             if ($authorText) {
                                 $authorText = User::getUserLinks($relatedAction->assignedTo);
                             }
                         }
                     }
                     if ($actionFlag) {
                         $authorText = empty($authorText) ? Yii::t('app', 'Someone') : $authorText;
                         switch ($action->type) {
                             case 'call':
                                 $text = Yii::t('app', '{authorText} logged a call ({duration}) with {modelLink}: "{logAbbrev}"', array('{authorText}' => $authorText, '{duration}' => empty($action->dueDate) || empty($action->completeDate) ? Yii::t('app', 'duration unknown') : Formatter::formatTimeInterval($action->dueDate, $action->completeDate, '{hoursMinutes}'), '{modelLink}' => X2Model::getModelLink($action->associationId, ucfirst($action->associationType), $requireAbsoluteUrl), '{logAbbrev}' => CHtml::encode($action->actionDescription)));
                                 break;
                             case 'note':
                                 $text = Yii::t('app', '{authorText} posted a comment on {modelLink}: "{noteAbbrev}"', array('{authorText}' => $authorText, '{modelLink}' => X2Model::getModelLink($action->associationId, ucfirst($action->associationType), $requireAbsoluteUrl), '{noteAbbrev}' => CHtml::encode($action->actionDescription)));
                                 break;
                             case 'time':
                                 $text = Yii::t('app', '{authorText} logged {time} on {modelLink}: "{noteAbbrev}"', array('{authorText}' => $authorText, '{time}' => Formatter::formatTimeInterval($action->dueDate, $action->dueDate + $action->timeSpent, '{hoursMinutes}'), '{modelLink}' => X2Model::getModelLink($action->associationId, ucfirst($action->associationType)), '{noteAbbrev}' => CHtml::encode($action->actionDescription)));
                                 break;
                             default:
                                 if (!empty($authorText)) {
                                     $text = Yii::t('app', "A new {actionLink} associated with the contact {contactLink} has been assigned to " . $authorText, array('{actionLink}' => CHtml::link(Events::parseModelName($this->associationType), '#', array_merge($htmlOptions, array('class' => 'action-frame-link', 'data-action-id' => $this->associationId))), '{contactLink}' => X2Model::getModelLink($action->associationId, ucfirst($action->associationType), $requireAbsoluteUrl)));
                                 } else {
                                     $text = Yii::t('app', "A new {actionLink} associated with the contact {contactLink} has been created.", array('{actionLink}' => CHtml::link(Events::parseModelName($this->associationType), '#', array_merge($htmlOptions, array('class' => 'action-frame-link', 'data-action-id' => $this->associationId))), '{contactLink}' => X2Model::getModelLink($action->associationId, ucfirst($action->associationType), $requireAbsoluteUrl)));
                                 }
                         }
                     } else {
                         if (!empty($authorText)) {
                             $modelLink = X2Model::getModelLink($this->associationId, $this->associationType, $requireAbsoluteUrl);
                             if (isset($action) && $this->user !== $action->assignedTo) {
                                 // Include the assignee if this is for an action assigned to someone other than the creator
                                 $translateText = "created a new {modelName} for {assignee}, {modelLink}";
                             } elseif ($modelLink !== '') {
                                 $translateText = "created a new {modelName}, {modelLink}";
                             } else {
                                 $translateText = "created a new {modelName}";
                             }
                             $text = $authorText . Yii::t('app', $translateText, array('{modelName}' => Events::parseModelName($this->associationType), '{modelLink}' => $modelLink, '{assignee}' => isset($action) ? User::getUserLinks($action->assignedTo) : null));
                         } else {
                             $text = Yii::t('app', "A new {modelName}, {modelLink}, has been created.", array('{modelName}' => Events::parseModelName($this->associationType), '{modelLink}' => X2Model::getModelLink($this->associationId, $this->associationType, $requireAbsoluteUrl)));
                         }
                     }
                 } else {
                     $deletionEvent = X2Model::model('Events')->findByAttributes(array('type' => 'record_deleted', 'associationType' => $this->associationType, 'associationId' => $this->associationId));
                     if (isset($deletionEvent)) {
                         if (!empty($authorText)) {
                             $text = $authorText . Yii::t('app', "created a new {modelName}, {deletionText}. It has been deleted.", array('{modelName}' => Events::parseModelName($this->associationType), '{deletionText}' => $deletionEvent->text));
                         } else {
                             $text = Yii::t('app', "A {modelName}, {deletionText}, was created. It has been deleted.", array('{modelName}' => Events::parseModelName($this->associationType), '{deletionText}' => $deletionEvent->text));
                         }
                     } else {
                         if (!empty($authorText)) {
                             $text = $authorText . Yii::t('app', "created a new {modelName}, but it could not be found.", array('{modelName}' => Events::parseModelName($this->associationType)));
                         } else {
                             $text = Yii::t('app', "A {modelName} was created, but it could not be found.", array('{modelName}' => Events::parseModelName($this->associationType)));
                         }
                     }
                 }
             }
             break;
         case 'weblead_create':
             if (count(X2Model::model($this->associationType)->findAllByPk($this->associationId)) > 0) {
                 $text = Yii::t('app', "A new web lead has come in: {modelLink}", array('{modelLink}' => X2Model::getModelLink($this->associationId, $this->associationType)));
             } else {
                 $deletionEvent = X2Model::model('Events')->findByAttributes(array('type' => 'record_deleted', 'associationType' => $this->associationType, 'associationId' => $this->associationId));
                 if (isset($deletionEvent)) {
                     $text = Yii::t('app', "A new web lead has come in: {deletionText}. It has been deleted.", array('{deletionText}' => $deletionEvent->text));
                 } else {
                     $text = Yii::t('app', "A new web lead has come in, but it could not be found.");
                 }
             }
             break;
         case 'record_deleted':
             if (class_exists($this->associationType)) {
                 if (Yii::app()->params->profile !== null && Yii::app()->params->profile->language != 'en' && !empty(Yii::app()->params->profile->language) || Yii::app()->params->profile === null && Yii::app()->language !== 'en' || strpos($this->associationType, 'A') !== 0 && strpos($this->associationType, 'E') !== 0 && strpos($this->associationType, 'I') !== 0 && strpos($this->associationType, 'O') !== 0 && strpos($this->associationType, 'U') !== 0) {
                     if (!empty($authorText)) {
                         $text = $authorText . Yii::t('app', "deleted a {modelType}, {text}", array('{modelType}' => Events::parseModelName($this->associationType), '{text}' => $this->text));
                     } else {
                         $text = Yii::t('app', "A {modelType}, {text}, was deleted", array('{modelType}' => Events::parseModelName($this->associationType), '{text}' => $this->text));
                     }
                 } else {
                     if (!empty($authorText)) {
                         $text = $authorText . Yii::t('app', "deleted an {modelType}, {text}.", array('{modelType}' => Events::parseModelName($this->associationType), '{text}' => $this->text));
                     } else {
                         $text = Yii::t('app', "An {modelType}, {text}, was deleted.", array('{modelType}' => Events::parseModelName($this->associationType), '{text}' => $this->text));
                     }
                 }
             }
             break;
         case 'workflow_start':
             $action = X2Model::model('Actions')->findByPk($this->associationId);
             if (isset($action)) {
                 $record = X2Model::model(ucfirst($action->associationType))->findByPk($action->associationId);
                 if (isset($record)) {
                     $stages = Workflow::getStages($action->workflowId);
                     if (isset($stages[$action->stageNumber - 1])) {
                         $text = $authorText . Yii::t('app', 'started the process stage "{stage}" for the {modelName} {modelLink}', array('{stage}' => $stages[$action->stageNumber - 1], '{modelName}' => Events::parseModelName($action->associationType), '{modelLink}' => X2Model::getModelLink($action->associationId, $action->associationType)));
                     } else {
                         $text = $authorText . Yii::t('app', "started a process stage for the {modelName} {modelLink}, but the process stage could not be found.", array('{modelName}' => Events::parseModelName($action->associationType), '{modelLink}' => X2Model::getModelLink($action->associationId, $action->associationType)));
                     }
                 } else {
                     $text = $authorText . Yii::t('app', "started a process stage, but the associated {modelName} was not found.", array('{modelName}' => Events::parseModelName($action->associationType)));
                 }
             } else {
                 $text = $authorText . Yii::t('app', "started a process stage, but the process record could not be found.");
             }
             break;
         case 'workflow_complete':
             $action = X2Model::model('Actions')->findByPk($this->associationId);
             if (isset($action)) {
                 $record = X2Model::model(ucfirst($action->associationType))->findByPk($action->associationId);
                 if (isset($record)) {
                     $stages = Workflow::getStages($action->workflowId);
                     if (isset($stages[$action->stageNumber - 1])) {
                         $text = $authorText . Yii::t('app', 'completed the process stage "{stageName}" for the {modelName} {modelLink}', array('{stageName}' => $stages[$action->stageNumber - 1], '{modelName}' => Events::parseModelName($action->associationType), '{modelLink}' => X2Model::getModelLink($action->associationId, $action->associationType)));
                     } else {
                         $text = $authorText . Yii::t('app', "completed a process stage for the {modelName} {modelLink}, but the process stage could not be found.", array('{modelName}' => Events::parseModelName($action->associationType), '{modelLink}' => X2Model::getModelLink($action->associationId, $action->associationType)));
                     }
                 } else {
                     $text = $authorText . Yii::t('app', "completed a process stage, but the associated {modelName} was not found.", array('{modelName}' => Events::parseModelName($action->associationType)));
                 }
             } else {
                 $text = $authorText . Yii::t('app', "completed a process stage, but the process record could not be found.");
             }
             break;
         case 'workflow_revert':
             $action = X2Model::model('Actions')->findByPk($this->associationId);
             if (isset($action)) {
                 $record = X2Model::model(ucfirst($action->associationType))->findByPk($action->associationId);
                 if (isset($record)) {
                     $stages = Workflow::getStages($action->workflowId);
                     $text = $authorText . Yii::t('app', 'reverted the process stage "{stageName}" for the {modelName} {modelLink}', array('{stageName}' => $stages[$action->stageNumber - 1], '{modelName}' => Events::parseModelName($action->associationType), '{modelLink}' => X2Model::getModelLink($action->associationId, $action->associationType)));
                 } else {
                     $text = $authorText . Yii::t('app', "reverted a process stage, but the associated {modelName} was not found.", array('{modelName}' => Events::parseModelName($action->associationType)));
                 }
             } else {
                 $text = $authorText . Yii::t('app', "reverted a process stage, but the process record could not be found.");
             }
             break;
         case 'feed':
             if (Yii::app()->user->getName() == $this->user) {
                 $author = CHtml::link(Yii::t('app', 'You'), Yii::app()->controller->createAbsoluteUrl('/profile/view', array('id' => Yii::app()->user->getId())), $htmlOptions) . " ";
             } else {
                 $author = User::getUserLinks($this->user);
             }
             $recipUser = Yii::app()->db->createCommand()->select('username')->from('x2_users')->where('id=:id', array(':id' => $this->associationId))->queryScalar();
             $modifier = '';
             $recipient = '';
             if ($this->user != $recipUser && $this->associationId != 0) {
                 if (Yii::app()->user->getId() == $this->associationId) {
                     $recipient = Yii::t('app', 'You');
                 } else {
                     $recipient = User::getUserLinks($recipUser);
                 }
                 if (!empty($recipient)) {
                     $modifier = ' &raquo; ';
                 }
             }
             $text = $author . $modifier . $recipient . ": " . ($truncated ? strip_tags(Formatter::convertLineBreaks(x2base::convertUrls($this->text), true, true), '<a></a>') : $this->text);
             break;
         case 'email_sent':
             if (class_exists($this->associationType)) {
                 $model = X2Model::model($this->associationType)->findByPk($this->associationId);
                 if (!empty($model)) {
                     switch ($this->subtype) {
                         case 'quote':
                             $text = $authorText . Yii::t('app', "issued the {transModelName} \"{modelLink}\" via email", array('{transModelName}' => Yii::t('quotes', 'quote'), '{modelLink}' => X2Model::getModelLink($this->associationId, $this->associationType)));
                             break;
                         case 'invoice':
                             $text = $authorText . Yii::t('app', "issued the {transModelName} \"{modelLink}\" via email", array('{transModelName}' => Yii::t('quotes', 'invoice'), '{modelLink}' => X2Model::getModelLink($this->associationId, $this->associationType)));
                             break;
                         default:
                             $text = $authorText . Yii::t('app', "sent an email to the {transModelName} {modelLink}", array('{transModelName}' => Events::parseModelName($this->associationType), '{modelLink}' => X2Model::getModelLink($this->associationId, $this->associationType)));
                             break;
                     }
                 } else {
                     $deletionEvent = X2Model::model('Events')->findByAttributes(array('type' => 'record_deleted', 'associationType' => $this->associationType, 'associationId' => $this->associationId));
                     switch ($this->subtype) {
                         case 'quote':
                             if (isset($deletionEvent)) {
                                 $text = $authorText . Yii::t('app', "issued a quote by email, but that record has been deleted.");
                             } else {
                                 $text = $authorText . Yii::t('app', "issued a quote by email, but that record could not be found.");
                             }
                             break;
                         case 'invoice':
                             if (isset($deletionEvent)) {
                                 $text = $authorText . Yii::t('app', "issued an invoice by email, but that record has been deleted.");
                             } else {
                                 $text = $authorText . Yii::t('app', "issued an invoice by email, but that record could not be found.");
                             }
                             break;
                         default:
                             if (isset($deletionEvent)) {
                                 $text = $authorText . Yii::t('app', "sent an email to a {transModelName}, but that record has been deleted.", array('{transModelName}' => Events::parseModelName($this->associationType)));
                             } else {
                                 $text = $authorText . Yii::t('app', "sent an email to a {transModelName}, but that record could not be found.", array('{transModelName}' => Events::parseModelName($this->associationType)));
                             }
                             break;
                     }
                 }
             }
             break;
         case 'email_opened':
             switch ($this->subtype) {
                 case 'quote':
                     $emailType = Yii::t('app', 'a quote email');
                     break;
                 case 'invoice':
                     $emailType = Yii::t('app', 'an invoice email');
                     break;
                 default:
                     $emailType = Yii::t('app', 'an email');
                     break;
             }
             if (X2Model::getModelName($this->associationType) && count(X2Model::model($this->associationType)->findAllByPk($this->associationId)) > 0) {
                 $text = X2Model::getModelLink($this->associationId, $this->associationType) . Yii::t('app', ' has opened {emailType}!', array('{emailType}' => $emailType, '{modelLink}' => X2Model::getModelLink($this->associationId, $this->associationType)));
             } else {
                 $text = Yii::t('app', "A contact has opened {emailType}, but that contact cannot be found.", array('{emailType}' => $emailType));
             }
             break;
         case 'email_clicked':
             if (count(X2Model::model($this->associationType)->findAllByPk($this->associationId)) > 0) {
                 $text = X2Model::getModelLink($this->associationId, $this->associationType) . Yii::t('app', ' opened a link in an email campaign and is visiting your website!', array('{modelLink}' => X2Model::getModelLink($this->associationId, $this->associationType)));
             } else {
                 $text = Yii::t('app', "A contact has opened a link in an email campaign, but that contact cannot be found.");
             }
             break;
         case 'web_activity':
             if (count(X2Model::model($this->associationType)->findAllByPk($this->associationId)) > 0) {
                 $text = "";
                 $text .= X2Model::getModelLink($this->associationId, $this->associationType) . " " . Yii::t('app', "is currently on your website!");
             } else {
                 $text = Yii::t('app', "A contact was on your website, but that contact cannot be found.");
             }
             break;
         case 'case_escalated':
             if (count(X2Model::model($this->associationType)->findAllByPk($this->associationId)) > 0) {
                 $case = X2Model::model($this->associationType)->findByPk($this->associationId);
                 $text = $authorText . Yii::t('app', "escalated service case {modelLink} to {userLink}", array('{modelLink}' => X2Model::getModelLink($this->associationId, $this->associationType), '{userLink}' => User::getUserLinks($case->escalatedTo)));
             } else {
                 $text = $authorText . Yii::t('app', "escalated a service case but that case could not be found.");
             }
             break;
         case 'calendar_event':
             $action = X2Model::model('Actions')->findByPk($this->associationId);
             if (isset($action)) {
                 $text = Yii::t('app', "{calendarText} event: {actionDescription}", array('{calendarText}' => CHtml::link(Yii::t('calendar', 'Calendar'), Yii::app()->controller->createAbsoluteUrl('/calendar/calendar/index'), $htmlOptions), '{actionDescription}' => CHtml::encode($action->actionDescription)));
             } else {
                 $text = Yii::t('app', "{calendarText} event: event not found.", array('{calendarText}' => CHtml::link(Yii::t('calendar', 'Calendar'), Yii::app()->controller->createAbsoluteUrl('/calendar/calendar/index'), $htmlOptions)));
             }
             break;
         case 'action_reminder':
             $action = X2Model::model('Actions')->findByPk($this->associationId);
             if (isset($action)) {
                 $text = Yii::t('app', "Reminder! The following {action} is due now: {transModelLink}", array('{transModelLink}' => X2Model::getModelLink($this->associationId, $this->associationType), '{action}' => strtolower(Modules::displayName(false, 'Actions'))));
             } else {
                 $text = Yii::t('app', "An {action} is due now, but the record could not be found.", array('{action}' => strtolower(Modules::displayName(false, 'Actions'))));
             }
             break;
         case 'action_complete':
             $action = X2Model::model('Actions')->findByPk($this->associationId);
             if (isset($action)) {
                 $text = $authorText . Yii::t('app', "completed the following {action}: {actionDescription}", array('{actionDescription}' => X2Model::getModelLink($this->associationId, $this->associationType, $requireAbsoluteUrl), '{action}' => strtolower(Modules::displayName(false, 'Actions'))));
             } else {
                 $text = $authorText . Yii::t('app', "completed an {action}, but the record could not be found.", array('{action}' => strtolower(Modules::displayName(false, 'Actions'))));
             }
             break;
         case 'doc_update':
             $text = $authorText . Yii::t('app', 'updated a document, {docLink}', array('{docLink}' => X2Model::getModelLink($this->associationId, $this->associationType)));
             break;
         case 'email_from':
             if (class_exists($this->associationType)) {
                 if (count(X2Model::model($this->associationType)->findAllByPk($this->associationId)) > 0) {
                     $text = $authorText . Yii::t('app', "received an email from a {transModelName}, {modelLink}", array('{transModelName}' => Events::parseModelName($this->associationType), '{modelLink}' => X2Model::getModelLink($this->associationId, $this->associationType)));
                 } else {
                     $deletionEvent = X2Model::model('Events')->findByAttributes(array('type' => 'record_deleted', 'associationType' => $this->associationType, 'associationId' => $this->associationId));
                     if (isset($deletionEvent)) {
                         $text = $authorText . Yii::t('app', "received an email from a {transModelName}, but that record has been deleted.", array('{transModelName}' => Events::parseModelName($this->associationType)));
                     } else {
                         $text = $authorText . Yii::t('app', "received an email from a {transModelName}, but that record could not be found.", array('{transModelName}' => Events::parseModelName($this->associationType)));
                     }
                 }
             }
             break;
         case 'voip_call':
             if (count(X2Model::model($this->associationType)->findAllByPk($this->associationId)) > 0) {
                 $text = Yii::t('app', "{modelLink} called.", array('{modelLink}' => X2Model::getModelLink($this->associationId, $this->associationType)));
             } else {
                 $deletionEvent = X2Model::model('Events')->findByAttributes(array('type' => 'record_deleted', 'associationType' => $this->associationType, 'associationId' => $this->associationId));
                 if (isset($deletionEvent)) {
                     $text = $authorText . Yii::t('app', "A contact called, but the contact record has been deleted.");
                 } else {
                     $text = $authorText . Yii::t('app', "Call from a contact whose record could not be found.");
                 }
             }
             break;
         case 'media':
             $media = X2Model::model('Media')->findByPk($this->associationId);
             $text = substr($authorText, 0, -1) . ": " . $this->text;
             if (isset($media)) {
                 if (!$truncated) {
                     $text .= "<br>" . Media::attachmentSocialText($media->getMediaLink(), true, true);
                 } else {
                     $text .= "<br>" . Media::attachmentSocialText($media->getMediaLink(), true, false);
                 }
             } else {
                 $text .= "<br>Media file not found.";
             }
             break;
         case 'topic_reply':
             $reply = TopicReplies::model()->findByPk($this->associationId);
             if (isset($reply)) {
                 $topicLink = X2Html::link($reply->topic->name, Yii::app()->controller->createUrl('/topics/topics/view', array('id' => $reply->topic->id, 'replyId' => $reply->id)));
                 $text = Yii::t('topics', '{poster} posted a new reply to {topic}.', array('{poster}' => $authorText, '{topic}' => $topicLink));
             } else {
                 $text = Yii::t('topics', '{poster} posted a new reply to a topic, but that reply has been deleted.', array('{poster}' => $authorText));
             }
             break;
         default:
             $text = $authorText . CHtml::encode($this->text);
             break;
     }
     if ($truncated && mb_strlen($text, 'UTF-8') > 250) {
         $text = mb_substr($text, 0, 250, 'UTF-8') . "...";
     }
     return $text;
 }
Exemple #20
0
 public function testChangeCompleteState()
 {
     TestingAuxLib::suLogin('admin');
     VERBOSE_MODE && (print Yii::app()->user->name . "\n");
     VERBOSE_MODE && (print (int) Yii::app()->params->isAdmin);
     VERBOSE_MODE && (print "\n");
     $action = $this->actions('action6');
     $completedNum = Actions::changeCompleteState('complete', array($action->id));
     $this->assertEquals(1, $completedNum);
     $action = Actions::model()->findByPk($action->id);
     VERBOSE_MODE && (print $action->complete . "\n");
     $this->assertTrue($action->complete === 'Yes');
     Actions::changeCompleteState('uncomplete', array($action->id));
     $action = Actions::model()->findByPk($action->id);
     $this->assertTrue($action->complete === 'No');
 }
Exemple #21
0
 /**
  * Deletes a particular model.
  * If deletion is successful, the browser will be redirected to the 'admin' page.
  * @param integer $id the ID of the model to be deleted
  */
 public function actionDelete($id)
 {
     if (Yii::app()->request->isPostRequest) {
         $model = $this->loadModel($id);
         Actions::model()->deleteAll('associationId=' . $id . ' AND associationType=\'account\'');
         $this->cleanUpTags($model);
         $model->delete();
     } else {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
     // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
     if (!isset($_GET['ajax'])) {
         $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('index'));
     }
 }
Exemple #22
0
 /**
  * Tests a method in WorkflowController which belongs in the Workflow model class
  */
 public function testGetStageMemberDataProvider()
 {
     $workflow = $this->workflows('workflow2');
     $workflowStatus = Workflow::getWorkflowStatus($workflow->id);
     $this->assertDataProviderCountMatchesStageCount($workflow, $workflowStatus, 1);
     $this->assertDataProviderCountMatchesStageCount($workflow, $workflowStatus, 4);
     // make record invisible
     $action = Actions::model()->findByAttributes(array('workflowId' => $workflow->id, 'complete' => 'No', 'stageNumber' => 8));
     $record = X2Model::getModelOfTypeWithId($action->associationType, $action->associationId);
     $record->visibility = 0;
     $record->assignedTo = 'admin';
     $this->assertSaves($record);
     $counts = $this->assertDataProviderCountMatchesStageCount($workflow, $workflowStatus, 4);
     $this->assertEquals(1, $counts[3]);
     TestingAuxLib::suLogin('testuser');
     $counts = $this->assertDataProviderCountMatchesStageCount($workflow, $workflowStatus, 4);
     $this->assertEquals(0, $counts[3]);
     $record->assignedTo = 'testuser';
     $this->assertSaves($record);
     $counts = $this->assertDataProviderCountMatchesStageCount($workflow, $workflowStatus, 4);
     $this->assertEquals(1, $counts[3]);
 }
 public function actionIndex()
 {
     $urls = array();
     // Actions
     $urls[] = $this->createUrl('actions/index');
     $actions = Actions::model()->findAll('t.picture != "" AND t.date_end <= ' . date('Y-m-d'));
     if (count($actions) > 0) {
         foreach ($actions as $action) {
             $urls[] = $this->createUrl('actions/view', array('id' => $action->id));
         }
     }
     // Tenders
     $urls[] = $this->createUrl('tenders/index');
     $tenders = Tenders::model()->findAll('t.date_end <= ' . date('Y-m-d'));
     if (count($tenders) > 0) {
         foreach ($tenders as $tender) {
             $urls[] = $this->createUrl('tenders/view', array('id' => $tender->id));
         }
     }
     // Freefoto
     $urls[] = $this->createUrl('freefoto/index');
     // Static Pages
     $urls[] = $this->createUrl('page/hmagent');
     $urls[] = $this->createUrl('page/advertisment');
     $urls[] = $this->createUrl('page/help_us');
     $urls[] = $this->createUrl('page/about');
     $urls[] = $this->createUrl('page/accounts');
     // News
     $urls[] = $this->createUrl('page/news');
     $news = News::model()->findAll('t.title != "" AND t.intro_text != ""');
     if (count($news) > 0) {
         foreach ($news as $item) {
             $urls[] = $this->createUrl('page/news', array('id' => $item->id));
         }
     }
     // Categories
     $cats = Occupation::model()->localized('ru')->findAll(array('condition' => 't.name!="" AND t.active=1', 'order' => 't.cat_id ASC'));
     if (count($cats) > 0) {
         foreach ($cats as $cat) {
             $urls[] = $this->createUrl('/cat/view', array('id' => 'c' . $cat->id . '_' . Settings::toLatin($cat->name)));
         }
     }
     // Users
     $users = Users::model()->findAll('t.name!="" AND t.activate=1');
     if (count($users) > 0) {
         foreach ($users as $user) {
             if ($user->filesCount >= 4 || $user->videosCount >= 4 || $user->floCount >= 4) {
                 $urls[] = '/id' . $user->id;
                 // Photo albums
                 if ($user->occupation_id == 1) {
                     $alb = Portfolio::model()->findAllByAttributes(array('uid' => $user->id, 'visible' => 1));
                     if (count($alb) > 0) {
                         foreach ($alb as $item) {
                             if ($item->filesCount > 0) {
                                 $urls[] = $this->createUrl('user/album', array('id' => $item->id));
                             }
                         }
                     }
                 }
                 // Video albums
                 if ($user->occupation_id == 2) {
                     $vid = Video::model()->findAllByAttributes(array('uid' => $user->id, 'visible' => 1));
                     if (count($vid) > 0) {
                         foreach ($vid as $item) {
                             if ($item->filesCount > 0) {
                                 $urls[] = $this->createUrl('user/videoalbum', array('id' => $item->id));
                             }
                         }
                     }
                 }
             }
         }
     }
     // Photo albums
     $users_alb = Users::model()->findAll('t.name!="" AND t.activate=1 AND t.occupation_id=1');
     if (count($users_alb) > 0) {
         foreach ($users_alb as $user_alb) {
             if ($user_alb->filesCount >= 4 || $user->videosCount >= 4 || $user->floCount >= 4) {
                 $urls[] = '/id' . $user->id;
             }
         }
     }
     /*// Страницы
             $pages = Page::model()->findAll(array(
                 'condition' => 't.public = 1';
             ));
             foreach ($posts as $page){
                 $urls[] = $this->createUrl('page/view', array('alias'=>$page->alias));
             }
      
             // Новости
             $news = News::model()->findAll(array(
                 'condition' => 't.public = 1';
             ));
             foreach ($news as $new){
                 $urls[] = $this->createUrl('news/view', array('id'=>$new->id));
             }
      
             // Работы портфолио
             $works = Work::model()->findAll(array(
                 'condition' => 't.public = 1';
             ));
             foreach ($works as $work){
                 $urls[] = $this->createUrl('work/view', array('id'=>$work->id));
             }
      
             // Товары
             $products = Product::model()->findAll(array(
                 'condition' => 't.public = 1 AND t.count > 0';
             ));
             foreach ($products as $product){
                 $urls[] = $this->createUrl('product/view', array('category'=>$product->category->alias, 'id'=>$product->id));
             }
      
             // ...*/
     $host = Yii::app()->request->hostInfo;
     echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
     echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
     echo '<url>
             <loc>' . $host . '</loc>
             <changefreq>daily</changefreq>
             <priority>0.5</priority>
         </url>';
     if (count($urls) > 0) {
         foreach ($urls as $url) {
             echo '<url>
                 <loc>' . $host . $url . '</loc>
                 <changefreq>daily</changefreq>
                 <priority>0.5</priority>
             </url>';
         }
     }
     echo '</urlset>';
     Yii::app()->end();
 }
Exemple #24
0
 /**
  * Called by the duplicate checker when discarding the new record.
  */
 public function actionDiscardNew()
 {
     if (isset($_POST['id'])) {
         $ref = $_POST['ref'];
         // Referring action
         $action = $_POST['action'];
         $oldId = $_POST['id'];
         if ($ref == 'create' && is_null($action) || $action == 'null') {
             echo CHtml::encode($oldId);
             return;
         } elseif ($ref == 'create') {
             $oldRecord = X2Model::model('Contacts')->findByPk($oldId);
             if (isset($oldRecord)) {
                 $oldRecord->disableBehavior('X2TimestampBehavior');
                 Relationships::model()->deleteAllByAttributes(array('firstType' => 'Contacts', 'firstId' => $oldRecord->id));
                 Relationships::model()->deleteAllByAttributes(array('secondType' => 'Contacts', 'secondId' => $oldRecord->id));
                 if ($action == 'hideThis') {
                     $oldRecord->dupeCheck = 1;
                     $oldRecord->assignedTo = 'Anyone';
                     $oldRecord->visibility = 0;
                     $oldRecord->doNotCall = 1;
                     $oldRecord->doNotEmail = 1;
                     $oldRecord->save();
                     $notif = new Notification();
                     $notif->user = '******';
                     $notif->createdBy = Yii::app()->user->getName();
                     $notif->createDate = time();
                     $notif->type = 'dup_discard';
                     $notif->modelType = 'Contacts';
                     $notif->modelId = $oldId;
                     $notif->save();
                     return;
                 } elseif ($action == 'deleteThis') {
                     $oldRecord->delete();
                     return;
                 }
             }
         } elseif (isset($_POST['newId'])) {
             $newId = $_POST['newId'];
             $oldRecord = X2Model::model('Contacts')->findByPk($oldId);
             $oldRecord->disableBehavior('X2TimestampBehavior');
             $newRecord = Contacts::model()->findByPk($newId);
             $newRecord->disableBehavior('X2TimestampBehavior');
             $newRecord->dupeCheck = 1;
             $newRecord->save();
             if ($action === '') {
                 $newRecord->delete();
                 echo CHtml::encode($oldId);
                 return;
             } else {
                 if (isset($oldRecord)) {
                     if ($action == 'hideThis') {
                         $oldRecord->dupeCheck = 1;
                         $oldRecord->assignedTo = 'Anyone';
                         $oldRecord->visibility = 0;
                         $oldRecord->doNotCall = 1;
                         $oldRecord->doNotEmail = 1;
                         $oldRecord->save();
                         $notif = new Notification();
                         $notif->user = '******';
                         $notif->createdBy = Yii::app()->user->getName();
                         $notif->createDate = time();
                         $notif->type = 'dup_discard';
                         $notif->modelType = 'Contacts';
                         $notif->modelId = $oldId;
                         $notif->save();
                     } elseif ($action == 'deleteThis') {
                         Relationships::model()->deleteAllByAttributes(array('firstType' => 'Contacts', 'firstId' => $oldRecord->id));
                         Relationships::model()->deleteAllByAttributes(array('secondType' => 'Contacts', 'secondId' => $oldRecord->id));
                         Tags::model()->deleteAllByAttributes(array('type' => 'Contacts', 'itemId' => $oldRecord->id));
                         Actions::model()->deleteAllByAttributes(array('associationType' => 'Contacts', 'associationId' => $oldRecord->id));
                         $oldRecord->delete();
                     }
                 }
                 echo CHtml::encode($newId);
             }
         }
     }
 }
Exemple #25
0
 * You can contact X2Engine, Inc. P.O. Box 66752, Scotts Valley,
 * California 95067, USA. or at email address contact@x2engine.com.
 * 
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 * 
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * X2Engine" logo. If the display of the logo is not reasonably feasible for
 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by X2Engine".
 *****************************************************************************************/
Yii::app()->clientScript->registerScript('deleteActionJs', "\nfunction deleteAction(actionId, type) {\n\n\tif(confirm('" . Yii::t('app', 'Are you sure you want to delete this item?') . "')) {\n\t\t\$.ajax({\n\t\t\turl: '" . CHtml::normalizeUrl(array('/actions/actions/delete')) . "/'+actionId+'?ajax=1',\n\t\t\ttype: 'POST',\n\t\t\tsuccess: function(response) {\n\t\t\t\tif(response === 'success')\n\t\t\t\t\t\$('#history-'+actionId).fadeOut(200,function() { \n                        \$('#history-'+actionId).remove(); \n                    });\n\n\t\t\t\t\t// event detected by x2chart.js\n\t\t\t\t\t\$(document).trigger ('deletedAction');\n                    x2.TransactionalViewWidget.refreshByActionType (type);\n\t\t\t\t}\n\t\t});\n\t}\n}\n", CClientScript::POS_HEAD);
$themeUrl = Yii::app()->theme->getBaseUrl();
$data = Actions::model()->findByPk($data['id']);
if (!$data) {
    return;
}
if (empty($data->type)) {
    if ($data->complete == 'Yes') {
        $type = 'complete';
    } else {
        if ($data->dueDate < time()) {
            $type = 'overdue';
        } else {
            $type = 'action';
        }
    }
} else {
    $type = $data->type;
                                    color: #222;
                                    line-height: 12px;'), 'value' => function ($data) {
    if ($data->name == 'Действие не указано') {
        return $data->name;
    } else {
        return CHtml::submitButton($data->name, array("class" => "button_to_link", 'onClick' => 'ActionEdit(' . $data->id . ',"action_type")'));
    }
}), array('name' => 'id', 'header' => 'Количество действий', 'headerHtmlOptions' => array('style' => '   height: 12px;
                                    border-right: 1px solid #d9d9d9;
                                    border-bottom: 1px solid #d9d9d9;
                                    padding: 8px 11px;
                                    text-align:left;
                                    font-size: 11px;
                                    color: #222;
                                    line-height: 12px;'), 'type' => 'raw', 'value' => function ($data) {
    return count(Actions::model()->findAll('action_type_id=' . $data->id . ' and company_id=' . Users::model()->findByPk(Yii::app()->user->id)->company_id));
}))));
?>
        <div class="settings-footer">
            <div class="help-dropdown open">
                <dl>
                    <dt class="simple none"><a class="add-btn__white popup-open" id="popup_new_action_type_button" href="#popup-new-action">Добавить тип действия</a></dt>
                    <dt class="dt simple"><i class="icon-help">help</i>Справка</dt>
                    <dd class="dd">
                        <ul>
                            <li>
                                надо добавить блок Показать справку, он должен отображаться под шапкой окна. При нажатии он раскрывается, и там просто текст выровненный по левой стороне
                            </li>
                        </ul>
                    </dd>
                </dl>
Exemple #27
0
 /**
  * Runs when a model is deleted.
  * Clears any entries in <tt>x2_phone_numbers</tt>.
  * Fires onAfterDelete event.
  */
 public function afterDelete()
 {
     // Clear out old tags:
     $class = get_class($this);
     Tags::model()->deleteAllByAttributes(array('type' => $class, 'itemId' => $this->id));
     // Clear out old phone numbers
     X2Model::model('PhoneNumber')->deleteAllByAttributes(array('modelId' => $this->id, 'modelType' => $class));
     RecordAliases::model()->deleteAllByAttributes(array('recordId' => $this->id, 'recordType' => $class));
     // Change all references to this record so that they retain the name but
     // exclude the ID:
     if ($this->hasAttribute('nameId') && $this->hasAttribute('name')) {
         $this->_oldAttributes = $this->getAttributes();
         $this->nameId = $this->name;
         $this->updateNameIdRefs();
     }
     // clear out associated actions
     Actions::model()->deleteAllByAttributes(array('associationType' => strtolower(self::getAssociationType(get_class($this))), 'associationId' => $this->id));
     if ($this->hasEventHandler('onAfterDelete')) {
         $this->onAfterDelete(new CEvent($this));
     }
 }
Exemple #28
0
 public static function completeAction($id)
 {
     $action = Actions::model()->findByPk($id);
     $action->complete = "Yes";
     $action->completedBy = Yii::app()->user->getName();
     $action->completeDate = time();
     $action->update();
 }