예제 #1
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}");
     }
 }
예제 #2
0
 public function recordEmailOpen()
 {
     if ($this->opened === null) {
         $openedAction = $this->createEmailOpenedAction();
         $event = $this->createEmailOpenedEvent();
         if ($openedAction->save() && $event->save()) {
             $this->opened = time();
             $this->update();
             $model = X2Model::getAssociationModel($openedAction->associationType, $openedAction->associationId);
             X2Flow::trigger('EmailOpenTrigger', array('model' => $model));
         }
     }
 }
예제 #3
0
 public function afterSave()
 {
     $this->saveMetaData();
     if ($this->reminder) {
         if (!$this->isNewRecord) {
             $this->deleteOldNotifications($this->notificationUsers);
         }
         $this->createNotifications($this->notificationUsers, $this->dueDate - $this->notificationTime * 60, 'action_reminder');
     }
     parent::afterSave();
     $association = X2Model::getAssociationModel($this->associationType, $this->associationId);
     if ($this->isNewRecord && $association && $association->hasAttribute('lastActivity')) {
         $association->lastActivity = time();
         $association->update(array('lastActivity'));
         X2Flow::trigger('RecordUpdateTrigger', array('model' => $association));
     }
 }
예제 #4
0
 public function getAssociation($type, $id)
 {
     return X2Model::getAssociationModel($type, $id);
 }
예제 #5
0
echo "</span>";
echo "<span class='field-value'>";
echo Formatter::convertLineBreaks($model->actionDescription);
echo "</span>";
echo '<div>';
echo CHtml::ajaxSubmitButton(Yii::t('app', 'Submit'), 'update?id=' . $model->id, array(), array('id' => 'action-edit-submit-button', 'style' => 'display:none;float:left;', 'class' => 'hidden-frame-form x2-button highlight'));
echo CHtml::link(Yii::t('actions', 'View Full Edit Page'), array('update', 'id' => $model->id), array('style' => 'float:right;display:none;', 'target' => '_parent', 'class' => 'x2-button hidden-frame-form'));
echo '</div>';
?>
            </div>
            </div>
                <?php 
$this->endWidget();
?>
                <?php 
if (!empty($model->associationType) && is_numeric($model->associationId) && !is_null(X2Model::getAssociationModel($model->associationType, $model->associationId)) && ($publisher == 'false' || !$publisher)) {
    ?>
                <div id="recordBody" class="form">
                    <?php 
    echo '<div class="page-title"><h3>' . Yii::t('actions', 'Associated Record') . '</h3></div>';
    ?>
                    <?php 
    if ($model->associationType == 'contacts') {
        $this->widget('DetailView', array('model' => X2Model::model('Contacts')->findByPk($model->associationId), 'scenario' => 'Inline', 'nameLink' => true));
        // $this->renderPartial('application.modules.contacts.views.contacts._@DETAILVIEWMini', array(
        // 'model' => X2Model::model('Contacts')->findByPk($model->associationId),
        // 'actionModel' => $model,
        // ));
    } else {
        echo ucwords(Events::parseModelName(X2Model::getModelName($model->associationType))) . ": <span class='model-link'>" . X2Model::getModelLink($model->associationId, X2Model::getModelName($model->associationType)) . "</span>";
    }
예제 #6
0
파일: view.php 프로젝트: tymiles003/X2CRM
<?php 
echo X2Html::editRecordbutton($model);
?>
</div>

<div class='<?php 
echo $imageExists ? 'x2-layout-island ' : '';
?>
tray media-tray'>
    <?php 
if ($imageExists) {
    ?>
    <div class='column'>
    <?php 
}
$assoc = X2Model::getAssociationModel($model->associationType, $model->associationId);
$this->widget('DetailView', array('model' => $model, 'scenario' => 'Default', 'specialFields' => array('associationId' => $assoc ? $assoc->link : ''), 'htmlOptions' => array('class' => $imageLink ? 'x2-layout-island' : '')));
echo $downloadLink;
?>
    <?php 
if ($imageExists) {
    ?>
    </div>
    <div class='column'>
        <div class="media-image">
            <div class='full-size-screen'>
                <?php 
    echo X2Html::fa('expand') . ' ';
    echo Yii::t('media', 'View Full Size');
    ?>
            </div>
예제 #7
0
 /**
  * Synchronize association name with association type and id 
  */
 public function validateAssociationName($attribute)
 {
     $association = X2Model::getAssociationModel($this->associationType, $this->associationId);
     if ($association) {
         $this->associationName = $association->name;
     }
 }