/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); $users = User::getNames(); $fields = Fields::model()->findAllByAttributes(array('modelName' => 'Product')); foreach ($fields as $field) { if ($field->type == 'link') { $fieldName = $field->fieldName; $type = ucfirst($field->linkType); if (is_numeric($model->{$fieldName}) && $model->{$fieldName} != 0) { eval("\$lookupModel={$type}::model()->findByPk(" . $model->{$fieldName} . ");"); if (isset($lookupModel)) { $model->{$fieldName} = $lookupModel->name; } } } } if (isset($_POST['Product'])) { $temp = $model->attributes; $model->setX2Fields($_POST['Product']); // generate history $action = new Actions(); $action->associationType = 'product'; $action->associationId = $model->id; $action->associationName = $model->name; $action->assignedTo = Yii::app()->user->getName(); $action->completedBy = Yii::app()->user->getName(); $action->dueDate = time(); $action->completeDate = time(); $action->visibility = 1; $action->complete = 'Yes'; $action->actionDescription = "Update: {$model->name}\n Type: {$model->type}\n Price: {$model->price}\n Currency: {$model->currency}\n Inventory: {$model->inventory}"; $action->save(); parent::update($model, $temp, '0'); } $this->render('update', array('model' => $model, 'users' => $users)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new X2Leads(); $users = User::getNames(); foreach (Groups::model()->findAll() as $group) { $users[$group->id] = $group->name; } unset($users['admin']); unset($users['']); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['X2Leads'])) { $temp = $model->attributes; $model->setX2Fields($_POST['X2Leads']); if (isset($_POST['x2ajax'])) { $ajaxErrors = $this->quickCreate($model); } else { if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } } if (isset($_POST['x2ajax'])) { $this->renderInlineCreateForm($model, isset($ajaxErrors) ? $ajaxErrors : false); } else { $this->render('create', array('model' => $model, 'users' => $users)); } }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); $users = User::getNames(); if (isset($_POST['BugReports'])) { $temp = $model->attributes; $model->setX2Fields($_POST['BugReports']); parent::update($model, $temp, '0'); } $this->render('update', array('model' => $model, 'users' => $users)); }
/** * Instantiates a subclass of X2Chart, passing it a function which allows it to save widget * settings. */ public function getSetupScript() { if (!isset($this->_setupScript)) { $widgetClass = get_called_class(); $chartData = $this->getInitialChartData(); $userNames = User::getNames(); $eventTypes = array('all' => Yii::t('app', 'All Events')) + Events::$eventLabels; $socialSubtypes = json_decode(Dropdowns::model()->findByPk(113)->options, true); $visibilityFilters = array('1' => 'Public', '0' => 'Private'); $chartSettingsData = self::getChartSettingsProvider($this->chartType)->data; $this->_setupScript = parent::getSetupScript() . "\n \$(function () {\n var chartUID = '{$this->chartType}{$this->widgetUID}';\n x2[chartUID] = {};\n x2[chartUID].chart = X2Chart.instantiateTemporarySubtype (\n X2UsersChart, {\n " . (isset($chartData) ? "chartData :" . CJSON::encode($chartData) . "," : '') . "\n actionParams: " . CJSON::encode(array('widgetType' => get_called_class())) . ",\n socialSubtypes:" . CJSON::encode(array_keys($socialSubtypes)) . ",\n visibilityTypes:" . CJSON::encode(array_keys($visibilityFilters)) . ",\n eventTypes:" . CJSON::encode(array_keys($eventTypes)) . ", \n translations: " . CJSON::encode($this->getTranslations()) . ",\n getChartDataActionName: 'getEventsBetween',\n saveChartSetting: function (key, value, callback) {\n this.lastChartSettings[key] = value;\n x2.{$widgetClass}{$this->widgetUID}.setProperty (\n 'chartSettings', this.lastChartSettings, callback);\n },\n suppressDateRangeSelector: false,\n suppressChartSettings: false,\n lastChartSettings: " . CJSON::encode($this->getChartSettings()) . ",\n widgetUID: '{$this->widgetUID}',\n chartType: '{$this->chartType}',\n chartSubtype: '" . self::getJSONProperty($this->profile, 'chartSubtype', $this->widgetType, $this->widgetUID) . "',\n chartSettings: " . CJSON::encode(count($chartSettingsData) ? array_combine(array_map(function ($setting) { return $setting->name; }, $chartSettingsData), $chartSettingsData) : array()) . "\n });\n \$(document).trigger ('{$this->chartType}' + 'Ready');\n });\n "; } return $this->_setupScript; }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); $users = User::getNames(); $fields = Fields::model()->findAllByAttributes(array('modelName' => "Products")); foreach ($fields as $field) { if ($field->type == 'link') { $fieldName = $field->fieldName; $type = ucfirst($field->linkType); if (is_numeric($model->{$fieldName}) && $model->{$fieldName} != 0) { eval("\$lookupModel={$type}::model()->findByPk(" . $model->{$fieldName} . ");"); if (isset($lookupModel)) { $model->{$fieldName} = $lookupModel->name; } } } } if (isset($_POST['Product'])) { $temp = $model->attributes; foreach ($_POST['Product'] as $name => $value) { if ($value == $model->getAttributeLabel($name)) { $_POST['Product'][$name] = ''; } } foreach ($_POST as $key => $arr) { $pieces = explode("_", $key); if (isset($pieces[0]) && $pieces[0] == 'autoselect') { $newKey = $pieces[1]; if (isset($_POST[$newKey . "_id"]) && $_POST[$newKey . "_id"] != "") { $val = $_POST[$newKey . "_id"]; } else { $field = Fields::model()->findByAttributes(array('fieldName' => $newKey)); if (isset($field)) { $type = ucfirst($field->linkType); if ($type != "Contacts") { eval("\$lookupModel={$type}::model()->findByAttributes(array('name'=>'{$arr}'));"); } else { $names = explode(" ", $arr); $lookupModel = Contacts::model()->findByAttributes(array('firstName' => $names[0], 'lastName' => $names[1])); } if (isset($lookupModel)) { $val = $lookupModel->id; } else { $val = $arr; } } } $model->{$newKey} = $val; } } foreach (array_keys($model->attributes) as $field) { if (isset($_POST['Product'][$field])) { $model->{$field} = $_POST['Product'][$field]; $fieldData = Fields::model()->findByAttributes(array('modelName' => 'Products', 'fieldName' => $field)); if ($fieldData->type == 'assignment' && $fieldData->linkType == 'multiple') { $model->{$field} = Accounts::parseUsers($model->{$field}); } elseif ($fieldData->type == 'date') { $model->{$field} = strtotime($model->{$field}); } } } // generate history $action = new Actions(); $action->associationType = 'product'; $action->associationId = $model->id; $action->associationName = $model->name; $action->assignedTo = Yii::app()->user->getName(); $action->completedBy = Yii::app()->user->getName(); $action->dueDate = time(); $action->completeDate = time(); $action->visibility = 1; $action->complete = 'Yes'; $action->actionDescription = "Update: <b>{$model->name}</b>\n\t\t\t\tType: <b>{$model->type}</b>\n\t\t\t\tPrice: <b>{$model->price}</b>\n\t\t\t\tCurrency: <b>{$model->currency}</b>\n\t\t\t\tInventory: <b>{$model->inventory}</b>"; $action->save(); parent::update($model, $temp, '0'); } $this->render('update', array('model' => $model, 'users' => $users)); }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id, $quick = 0) { $model = $this->getModel($id); if (isset($_POST['Quote'])) { $model->setX2Fields($_POST['Quote']); if (isset($_POST['lineitem'])) { $model->lineItems = $_POST['lineitem']; } if (!$model->hasLineItemErrors) { if ($model->save()) { $model->saveLineItems(); $this->redirect(array('view', 'id' => $model->id)); } } } $users = User::getNames(); $products = $model->activeProducts(); $quoteProducts = $model->lineItems; $viewData = array('model' => $model, 'users' => $users, 'products' => $products, 'orders' => $quoteProducts, 'quick' => $quick); if (!$quick) { $this->render('update', $viewData); } else { if ($model->hasErrors() || $model->hasLineItemErrors) { // Sneak into the response that validation failed via setting // the response code manually: header('HTTP/1.1 400 Validation Error'); } $this->renderPartial('update', $viewData, false, true); } }
Yii::app()->clientScript->registerScriptFile(Yii::app()->getBaseUrl() . '/js/ckeditor/adapters/jquery.js'); Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl . '/js/emailEditor.js'); Yii::app()->clientScript->registerScriptFile(Yii::app()->getBaseUrl() . '/js/multiselect/js/ui.multiselect.js'); Yii::app()->clientScript->registerScriptFile(Yii::app()->getBaseUrl() . '/js/lib/moment-with-locales.min.js'); $groups = Groups::getUserGroups(Yii::app()->user->getId()); $tempUserList = array(); foreach ($groups as $groupId) { $userLinks = GroupToUser::model()->findAllByAttributes(array('groupId' => $groupId)); foreach ($userLinks as $link) { $user = User::model()->findByPk($link->userId); if (isset($user)) { $tempUserList[] = $user->username; } } } $userList = array_keys(User::getNames()); $tempUserList = array_diff($userList, $tempUserList); $usersGroups = implode(",", $tempUserList); Yii::app()->clientScript->registerScript('setUpActivityFeedManager', "\n\nx2.activityFeed = new x2.ActivityFeed ({\n translations: " . CJSON::encode(array('Unselect All' => Yii::t('app', 'Unselect All'), 'Select All' => Yii::t('app', 'Select All'), 'Uncheck All' => Yii::t('app', 'Uncheck All'), 'Check All' => Yii::t('app', 'Check All'), 'Enter text here...' => Yii::t('app', 'Enter text here...'), 'Broadcast Event' => Yii::t('app', 'Broadcast Event'), 'Make Important' => Yii::t('app', 'Make Important'), 'Broadcast' => Yii::t('app', 'Broadcast'), 'broadcast error message 1' => Yii::t('app', 'Select at least one user to broadcast to'), 'broadcast error message 2' => Yii::t('app', 'Select at least one broadcast method'), 'Okay' => Yii::t('app', 'Okay'), 'Nevermind' => Yii::t('app', 'Cancel'), 'Create' => Yii::t('app', 'Create'), 'Cancel' => Yii::t('app', 'Cancel'), 'Read more' => Yii::t('app', 'Read') . ' ' . Yii::t('app', 'More'), 'Read less' => Yii::t('app', 'Read') . ' ' . Yii::t('app', 'Less'))) . ",\n usersGroups: '" . $usersGroups . "',\n minimizeFeed: " . (Yii::app()->params->profile->minimizeFeed == 1 ? 'true' : 'false') . ",\n commentFlag: false,\n lastEventId: " . (!empty($lastEventId) ? $lastEventId : 0) . ",\n lastTimestamp: " . (!empty($lastTimestamp) ? $lastTimestamp : 0) . ",\n profileId: " . $profileId . ",\n myProfileId: " . Yii::app()->params->profile->id . ",\n deletePostUrl: '" . $this->createUrl('/profile/deletePost') . "'\n});\n\n", CClientScript::POS_END); ?> <div id='activity-feed-container' class='x2-layout-island'> <div id='page-title-container'> <div class="page-title icon rounded-top activity-feed"> <h2><?php echo Yii::t('app', 'Activity Feed'); ?> </h2> <span title='<?php echo Yii::t('app', 'Feed Settings'); ?>
/** * Displays a particular model. This method is called in child controllers * which pass it a model to display and what type of model it is (i.e. Contact, * Sale, Account). It also creates an action history and provides appropriate * variables to the view. * * @param CActiveRecord $model The model to be displayed * @param String $type The type of the module being displayed */ public function view($model, $type, $params = array()) { // eval($this->varString); $actionHistory = $this->getHistory($model, $type); // $actionHistory=new CActiveDataProvider('Actions', array( // 'criteria'=>array( // 'order'=>'(IF (completeDate IS NULL, dueDate, completeDate)) DESC, createDate DESC', // 'condition'=>'associationId='.$model->id.' AND associationType=\''.$type.'\' AND (visibility="1" OR assignedTo="admin" OR assignedTo="'.Yii::app()->user->getName().'")' // ) // )); // if(isset($_GET['history'])) { // $history=$_GET['history']; // } else { // $history='all'; // } // if($history=='actions') { // $actionHistory=new CActiveDataProvider('Actions', array( // 'criteria'=>array( // 'order'=>'(IF (completeDate IS NULL, dueDate, completeDate)) DESC, createDate DESC', // 'condition'=>'associationId='.$model->id.' AND associationType=\''.$type.'\' AND type IS NULL' // ) // )); // } elseif($history=='comments') { // $actionHistory=new CActiveDataProvider('Actions', array( // 'criteria'=>array( // 'order'=>'(IF (completeDate IS NULL, dueDate, completeDate)) DESC, createDate DESC', // 'condition'=>'associationId='.$model->id.' AND associationType=\''.$type.'\' AND type="note"' // ) // )); // } elseif($history=='attachments') { // $actionHistory = new CActiveDataProvider('Actions', array( // 'criteria'=>array( // 'order'=>'(IF (completeDate IS NULL, dueDate, completeDate)) DESC, createDate DESC', // 'condition'=>'associationId='.$model->id.' AND associationType=\''.$type.'\' AND type="attachment"' // ) // )); // } $users = User::getNames(); $showActionForm = isset($_GET['showActionForm']); $this->render('view', array_merge($params, array('model' => $model, 'actionHistory' => $actionHistory, 'users' => $users, 'currentWorkflow' => $this->getCurrentWorkflow($model->id, $type)))); }
public function actionAddContact($id) { $users = User::getNames(); unset($users['admin']); unset($users['']); foreach (Groups::model()->findAll() as $group) { $users[$group->id] = $group->name; } $contacts = Contacts::getAllNames(); unset($contacts['0']); $model = $this->loadModel($id); $contacts = Sales::editContactArray($contacts, $model); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Sales'])) { $temp = $model->associatedContacts; $tempArr = $model->attributes; $model->attributes = $_POST['Sales']; $arr = $_POST['Sales']['associatedContacts']; foreach ($arr as $contactId) { $rel = new Relationships(); $rel->firstType = 'Contacts'; $rel->firstId = $contactId; $rel->secondType = 'Sales'; $rel->secondId = $model->id; $rel->save(); } $model->associatedContacts = Sales::parseContacts($arr); $temp .= " " . $model->associatedContacts; $model->associatedContacts = $temp; $changes = $this->calculateChanges($tempArr, $model->attributes); $model = $this->updateChangelog($model, $changes); if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('addContact', array('model' => $model, 'users' => $users, 'contacts' => $contacts, 'action' => 'Add')); }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); $users = User::getNames(); unset($users['admin']); unset($users['']); foreach (Groups::model()->findAll() as $group) { $users[$group->id] = $group->name; } if (isset($_POST['Services'])) { $temp = $model->attributes; foreach ($_POST['Services'] as $name => &$value) { if ($value == $model->getAttributeLabel($name)) { $value = null; } } $model->setX2Fields($_POST['Services']); if ($model->contactId != '' && !is_numeric($model->contactId)) { // make sure an existing contact is associated with this case, otherwise don't create it $model->addError('contactId', Yii::t('services', 'Contact does not exist')); } // $this->update($model,$temp,'0'); if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('update', array('model' => $model, 'users' => $users)); }
?> <a onclick="x2.forms.submitForm('chart');" href="#" class="x2-button"><span><?php echo Yii::t('app', 'Go'); ?> </span></a> </div> </div> </div> <div class="x2-chart-container-controls"> <div class="x2-chart-control"> <div class="row"> <?php echo $form->label($model, 'assignedTo', array('label' => Yii::t('charts', 'Select deals assigned to') . ' ')); ?> <?php echo $form->dropDownList($model, 'assignedTo', array_merge(array('0' => 'All'), Groups::getNames(), User::getNames())); ?> <a onclick="x2.forms.submitForm('chart');" href="#" class="x2-button"><span><?php echo Yii::t('app', 'Go'); ?> </span></a> </div> </div> </div> <p class="x2-chart-separator"/> <div class="x2-chart-container-center-large"> <?php $this->widget('X2BubbleChart', array('model' => $sqlView, 'options' => array('other-threshold' => 2, 'statistic' => 'none', 'orderby' => 'dealValue asc', 'slice' => array('part' => $slice), 'x-axis' => array('column' => "round((closeDate-unix_timestamp())/(24*3600))"), 'y-axis' => array('column' => 'round(dealValue)'), 'r-axis' => array('column' => 'confidence', 'label' => "concat('\$',format(dealValue,2))")), 'filters' => $filters, 'chartOptions' => array('title' => Yii::t('charts', 'Deals'), 'axes' => array('yaxis' => array('label' => Yii::t('charts', 'Value'), 'tickOptions' => array('formatString' => '$%d')), 'xaxis' => array('label' => Yii::t('charts', 'Days To Close')))))); ?> </div> <p class="x2-chart-separator"/>
<?php if (Yii::app()->params->admin->googleIntegration) { // menu if google integration is enables has additional options $this->menu = array(array('label' => Yii::t('calendar', 'Calendar'), 'url' => array('index')), array('label' => Yii::t('calendar', 'My Calendar Permissions'), 'url' => array('myCalendarPermissions')), array('label' => Yii::t('calendar', 'List'), 'url' => array('list')), array('label' => Yii::t('calendar', 'Create'), 'url' => array('create')), array('label' => Yii::t('calendar', 'View'), 'url' => array('view', 'id' => $model->id)), array('label' => Yii::t('calendar', 'Update')), array('label' => Yii::t('calendar', 'Delete'), 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => 'Are you sure you want to delete this item?')), array('label' => Yii::t('calendar', 'Sync My Actions To Google Calendar'), 'url' => array('syncActionsToGoogleCalendar'))); } else { $this->menu = array(array('label' => Yii::t('calendar', 'Calendar'), 'url' => array('index')), array('label' => Yii::t('calendar', 'My Calendar Permissions'), 'url' => array('myCalendarPermissions')), array('label' => Yii::t('calendar', 'List'), 'url' => array('list')), array('label' => Yii::t('calendar', 'Create'), 'url' => array('create')), array('label' => Yii::t('calendar', 'View'), 'url' => array('view', 'id' => $model->id)), array('label' => Yii::t('calendar', 'Update')), array('label' => Yii::t('calendar', 'Delete'), 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => 'Are you sure you want to delete this item?'))); } ?> <h2 style="margin-bottom:0;"><?php echo Yii::t('quotes', 'Update Quote: {name}', array('{name}' => $model->name)); ?> <a class="x2-button" href="javascript:void(0);" onclick="$('#save-button').click();">Save</a></h2> <?php $users = User::getNames(); unset($users['Anyone']); unset($users['admin']); $form = $this->beginWidget('CActiveForm', array('id' => 'calendar-form', 'enableAjaxValidation' => false)); echo $this->renderPartial('application.components.views._form', array('model' => $model, 'form' => $form, 'modelName' => 'calendar', 'users' => $users, 'isQuickCreate' => true)); ?> <?php if (!$googleIntegration) { ?> <div class="x2-layout form-view" style="margin-bottom: 0;"> <div class="formSection"> <div class="formSectionHeader"> <span class="sectionTitle"><?php echo Yii::t('calendar', 'Google');
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. ********************************************************************************/ $this->menu = array(array('label' => Yii::t('contacts', 'All Contacts'), 'url' => array('index')), array('label' => Yii::t('contacts', 'Lists'), 'url' => array('lists')), array('label' => Yii::t('contacts', 'Create'), 'url' => array('create')), array('label' => Yii::t('contacts', 'Import from Outlook'), 'url' => array('importContacts')), array('label' => Yii::t('contacts', 'Import from Template'), 'url' => array('importExcel')), array('label' => Yii::t('contacts', 'Export to CSV'), 'url' => array('export'))); Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('contacts-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n"); // $cs=Yii::app()->getClientScript(); // $cs->registerScriptFile(Yii::app()->request->baseUrl.'/assets/js/test.js'); ?> <h2><?php echo Yii::t('contacts', 'Manage Contacts'); ?> </h2> <?php echo Yii::t('app', 'You may optionally enter a comparison operator (<b><</b>, <b><=</b>, <b>></b>, <b>>=</b>, <b><></b>or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.'); ?> <br /> <div class="search-form" style="display:none"> <?php $this->renderPartial('_search', array('model' => $model, 'users' => User::getNames())); ?> </div><!-- search-form --> <?php $this->widget('application.components.X2GridView', array('id' => 'contacts-grid', 'baseScriptUrl' => Yii::app()->request->baseUrl . '/themes/' . Yii::app()->theme->name . '/css/gridview', 'template' => '<div class="title-bar">' . CHtml::link(Yii::t('app', 'Advanced Search'), '#', array('class' => 'search-button')) . ' | ' . CHtml::link(Yii::t('app', 'Clear Filters'), array(Yii::app()->controller->action->id, 'clearFilters' => 1)) . ' | ' . CHtml::link(Yii::t('app', 'Columns'), 'javascript:void(0);', array('class' => 'column-selector-link')) . '{summary}</div>{items}{pager}', 'dataProvider' => $model->searchAdmin(), 'filter' => $model, 'modelName' => 'Contacts', 'viewName' => 'contactsadmin', 'defaultGvSettings' => array('name' => 185, 'phone' => 95, 'lastUpdated' => 96, 'leadSource' => 138, 'gvControls' => 70), 'specialColumns' => array('name' => array('name' => 'name', 'header' => Yii::t('contacts', 'Name'), 'value' => 'CHtml::link($data->firstName." ".$data->lastName,array("view","id"=>$data->id))', 'type' => 'raw')), 'enableControls' => true));
public function getViewFileParams() { if (!isset($this->_viewFileParams)) { $this->_viewFileParams = array_merge(parent::getViewFileParams(), array('userNames' => User::getNames(), 'socialSubtypes' => Dropdowns::getSocialSubtypes(), 'visibilityFilters' => array('1' => 'Public', '0' => 'Private'), 'chartSettingsDataProvider' => self::getChartSettingsProvider($this->chartType), 'suppressChartSettings' => false, 'metricTypes' => array('any' => Yii::t('app', 'All Events'), 'notif' => Yii::t('app', 'Notifications'), 'feed' => Yii::t('app', 'Feed Events'), 'comment' => Yii::t('app', 'Comments'), 'record_create' => Yii::t('app', 'Records Created'), 'record_deleted' => Yii::t('app', 'Records Deleted'), 'weblead_create' => Yii::t('app', 'Webleads Created'), 'workflow_start' => Yii::t('app', '{Process} Started', array('{Process}' => Modules::displayName(false, 'Workflow'))), 'workflow_complete' => Yii::t('app', '{Process} Complete', array('{Process}' => Modules::displayName(false, 'Workflow'))), 'workflow_revert' => Yii::t('app', '{Process} Reverted', array('{Process}' => Modules::displayName(false, 'Workflow'))), 'email_sent' => Yii::t('app', 'Emails Sent'), 'email_opened' => Yii::t('app', 'Emails Opened'), 'web_activity' => Yii::t('app', 'Web Activity'), 'case_escalated' => Yii::t('app', 'Cases Escalated'), 'calendar_event' => Yii::t('app', '{Calendar} Events', array('{Calendar}' => Modules::displayName(false, 'Calendar'))), 'action_reminder' => Yii::t('app', '{Action} Reminders', array('{Action}' => Modules::displayName(false, 'Actions'))), 'action_complete' => Yii::t('app', '{Actions} Completed', array('{Actions}' => Modules::displayName(true, 'Actions'))), 'doc_update' => Yii::t('app', 'Doc Updates'), 'email_from' => Yii::t('app', 'Email Received'), 'voip_calls' => Yii::t('app', 'VOIP Calls'), 'media' => Yii::t('app', '{Media}', array('{Media}' => Modules::displayName(true, 'Media')))), 'chartType' => 'eventsChart', 'widgetUID' => $this->widgetUID)); } return $this->_viewFileParams; }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); $users = User::getNames(); if (isset($_POST['Topics'])) { $data = $_POST['Topics']; $data['text'] = $_POST['TopicReplies']['text']; $model->setX2Fields($data, false, true); if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } elseif ($model->hasErrors('text')) { Yii::app()->user->setFlash('error', 'Original post text cannot be blank.'); } } $this->render('update', array('model' => $model, 'users' => $users)); }
public function actionUpdateList($id) { $list = X2List::model()->findByPk($id); if (!isset($list)) { throw new CHttpException(400, Yii::t('app', 'This list cannot be found.')); } if (!$this->checkPermissions($list, 'edit')) { throw new CHttpException(403, Yii::t('app', 'You do not have permission to modify this list.')); } $contactModel = new Contacts(); $comparisonList = X2List::getComparisonList(); $fields = $contactModel->getFields(true); if ($list->type == 'dynamic') { $criteriaModels = X2ListCriterion::model()->findAllByAttributes(array('listId' => $list->id), new CDbCriteria(array('order' => 'id ASC'))); if (isset($_POST['X2List'], $_POST['X2List']['attribute'], $_POST['X2List']['comparison'], $_POST['X2List']['value'])) { $attributes =& $_POST['X2List']['attribute']; $comparisons =& $_POST['X2List']['comparison']; $values =& $_POST['X2List']['value']; if (count($attributes) > 0 && count($attributes) == count($comparisons) && count($comparisons) == count($values)) { $list->attributes = $_POST['X2List']; $list->modelName = 'Contacts'; $list->lastUpdated = time(); if ($list->save()) { $this->redirect(array('/contacts/contacts/list', 'id' => $list->id)); } } } } else { //static or campaign lists if (isset($_POST['X2List'])) { $list->attributes = $_POST['X2List']; $list->modelName = 'Contacts'; $list->lastUpdated = time(); $list->save(); $this->redirect(array('/contacts/contacts/list', 'id' => $list->id)); } } if (empty($criteriaModels)) { $default = new X2ListCriterion(); $default->value = ''; $default->attribute = ''; $default->comparison = 'contains'; $criteriaModels[] = $default; } else { if ($list->type = 'dynamic') { foreach ($criteriaModels as $criM) { if (isset($fields[$criM->attribute])) { if ($fields[$criM->attribute]->type == 'link') { $criM->value = implode(',', array_map(function ($c) { list($name, $id) = Fields::nameAndId($c); return $name; }, explode(',', $criM->value))); } } } } } $this->render('updateList', array('model' => $list, 'criteriaModels' => $criteriaModels, 'users' => User::getNames(), 'comparisonList' => $comparisonList, 'listTypes' => array('dynamic' => Yii::t('contacts', 'Dynamic'), 'static' => Yii::t('contacts', 'Static')), 'itemModel' => $contactModel)); }
/** * Updates a particular model. * * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { if ($id == Yii::app()->user->getId() || Yii::app()->params->isAdmin) { $model = $this->loadModel($id); $users = User::getNames(); if (isset($_POST['Profile'])) { foreach ($_POST['Profile'] as $name => $value) { if ($value == $model->getAttributeLabel($name)) { $_POST['Profile'][$name] = ''; } $model->{$name} = $value; } if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('update', array('model' => $model, 'users' => $users)); } else { $this->redirect(array('/profile/view', 'id' => $id)); } }
public function actionCreateRecords() { $contact = new Contacts(); $account = new Accounts(); $opportunity = new Opportunity(); $users = User::getNames(); if (isset($_POST['Contacts']) && isset($_POST['Accounts']) && isset($_POST['Opportunity'])) { $contact->setX2Fields($_POST['Contacts']); $account->setX2Fields($_POST['Accounts']); $opportunity->setX2Fields($_POST['Opportunity']); $validAccount = true; if ($account->validate() == false) { $validAccount = false; // validate other models so that the user gets feedback $contact->validate(); $opportunity->validate(); } if ($validAccount) { $allValid = true; $a = $this->createAccount($account, $account->attributes, '1'); // Contact and Opportunity require Account id for lookup field $contact->company = Fields::nameId($account->name, $account->id); if ($contact->validate() == false) { $allValid = false; } $c = $this->createContact($contact, $contact->attributes, '1'); $opportunity->accountName = Fields::nameId($account->name, $account->id); $opportunity->contactName = Fields::nameId($contact->name, $contact->id); if ($opportunity->validate() == false) { $allValid = false; } $o = $this->createOpportunity($opportunity, $opportunity->attributes, '1'); if ($allValid && $c && $a && $o) { // all records created? Relationships::create('Contacts', $contact->id, 'Accounts', $account->id); Relationships::create('Opportunity', $opportunity->id, 'Contacts', $contact->id); Relationships::create('Opportunity', $opportunity->id, 'Accounts', $account->id); if (isset($_GET['ret'])) { if ($_GET['ret'] == 'contacts') { $this->redirect(array("/contacts/contacts/view", 'id' => $contact->id)); } else { if ($_GET['ret'] == 'accounts') { $this->redirect(array("/accounts/accounts/view", 'id' => $account->id)); } else { if ($_GET['ret'] == 'opportunities') { $this->redirect(array("/opportunities/opportunities/view", 'id' => $opportunity->id)); } } } } else { $this->redirect(array("/contacts/contacts/view", $contact->id)); } } else { // otherwise clean up $types = array('account' => 'Accounts', 'contact' => 'Contacts', 'opportunity' => 'Opportunity'); foreach ($types as $model => $type) { if (${$model} && isset(${$model}->id)) { $modelId = ${$model}->id; ${$model}->delete(); // delete all new actions and events from creating/deleting records foreach (array('Actions', 'Events') as $meta) { X2Model::model($meta)->deleteAllByAttributes(array('associationId' => $modelId, 'associationType' => $type)); } } } } } } $this->render('createRecords', array('contact' => $contact, 'account' => $account, 'opportunity' => $opportunity, 'users' => $users)); }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { if ($id == Yii::app()->user->getId() || Yii::app()->user->getName() == 'admin') { $model = $this->loadModel($id); $users = User::getNames(); $accounts = Accounts::getNames(); if (isset($_POST['ProfileChild'])) { $temp = $model->attributes; foreach ($_POST['ProfileChild'] as $name => $value) { if ($value == $model->getAttributeLabel($name)) { $_POST['ProfileChild'][$name] = ''; } } $model->attributes = $_POST['ProfileChild']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('update', array('model' => $model, 'users' => $users, 'accounts' => $accounts)); } else { $this->redirect('view/' . $id); } }
public function actionAddUser($id) { $users = User::getNames(); unset($users['admin']); unset($users['']); foreach (Groups::model()->findAll() as $group) { $users[$group->id] = $group->name; } //$contacts = Contacts::getAllNames(); // very inefficient with large table $model = $this->loadModel($id); $users = Accounts::editUserArray($users, $model); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Accounts'])) { $temp = $model->assignedTo; $tempArr = $model->attributes; $model->attributes = $_POST['Accounts']; $arr = $_POST['Accounts']['assignedTo']; $model->assignedTo = Fields::parseUsers($arr); if ($temp != "") { $temp .= ", " . $model->assignedTo; } else { $temp = $model->assignedTo; } $model->assignedTo = $temp; // $changes=$this->calculateChanges($tempArr,$model->attributes); // $model=$this->updateChangelog($model,$changes); if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('addUser', array('model' => $model, 'users' => $users, 'action' => 'Add')); }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); $users = User::getNames(); $notifications = X2Model::model('Notification')->findAllByAttributes(array('modelType' => 'Actions', 'modelId' => $model->id, 'type' => 'action_reminder')); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Actions'])) { $oldAttributes = $model->attributes; $model->setX2Fields($_POST['Actions']); if ($model->lastUpdated != $oldAttributes['lastUpdated']) { $model->disableBehavior('X2TimestampBehavior'); } if ($model->dueDate != $oldAttributes['dueDate']) { $event = CActiveRecord::model('Events')->findByAttributes(array('type' => 'action_reminder', 'associationType' => 'Actions', 'associationId' => $model->id)); if (isset($event)) { $event->timestamp = $model->dueDate; $event->update(array('timestamp')); } } // $this->update($model,$oldAttributes,'0'); if ($model->save()) { if (Yii::app()->user->checkAccess('ActionsAdmin') || Yii::app()->settings->userActionBackdating) { $events = X2Model::model('Events')->findAllByAttributes(array('associationType' => 'Actions', 'associationId' => $model->id)); foreach ($events as $event) { $event->timestamp = $model->getRelevantTimestamp(); $event->update(array('timestamp')); } } $model->syncGoogleCalendar('update'); // if the action has an association if (isset($_GET['redirect']) && $model->associationType != 'none') { if ($model->associationType == 'product' || $model->associationType == 'products') { $this->redirect(array('/products/products/view', 'id' => $model->associationId)); //TODO: avoid such hackery } elseif ($model->associationType == 'Campaign') { $this->redirect(array('/marketing/marketing/view', 'id' => $model->associationId)); } else { $this->redirect(array('/' . $model->associationType . '/' . $model->associationType . '/view', 'id' => $model->associationId)); // go back to the association } } elseif (!Yii::app()->request->isAjaxRequest) { // no association $this->redirect(array('index')); // view the action } else { echo $this->renderPartial('_viewIndex', array('data' => $model), true); return; } } } else { /* Set assignedTo back into an array only before re-rendering the input box with assignees selected */ $model->assignedTo = array_map(function ($n) { return trim($n, ','); }, explode(' ', $model->assignedTo)); $this->render('update', array('model' => $model, 'users' => $users)); } }
public function actionChangePermissions($id) { $model = $this->loadModel($id); if (Yii::app()->user->getName() == 'admin' || Yii::app()->user->getName() == $model->createdBy) { $users = User::getNames(); unset($users['admin']); unset($users['Anyone']); $str = $model->editPermissions; $pieces = explode(", ", $str); $model->editPermissions = $pieces; if (isset($_POST['DocChild'])) { $model->attributes = $_POST['DocChild']; $arr = $model->editPermissions; $model->editPermissions = Accounts::parseUsers($arr); if ($model->save()) { $this->redirect(array('view', 'id' => $id)); } } $this->render('editPermissions', array('model' => $model, 'users' => $users)); } else { $this->redirect(array('view', 'id' => $id)); } }
</div> <div class="row row-no-title"> <div class="cell"> <?php echo CHtml::label(Yii::t('app', 'Record Type'), 'modelType'); ?> <?php echo CHtml::dropDownList('modelType', $modelType, X2Model::getModelTypesWhichSupportWorkflow(true, true), array('id' => 'workflow-model-type-filter')); ?> </div> </div> <div class="row row-no-title"> <div class="cell"> <?php echo CHtml::label(Yii::t('workflow', '{user}', array('{user}' => Modules::displayName(false, "Users"))), 'users'); echo CHtml::dropDownList('users', $users, array_merge(array('' => Yii::t('app', 'All')), User::getNames())); ?> </div> <?php echo CHtml::hiddenField('id', $model->id); ?> <div class="cell"> <?php echo CHtml::submitButton(Yii::t('charts', 'Go'), array('name' => '', 'class' => 'x2-button', 'style' => 'margin-top:13px;')); ?> </div> </div> <?php $this->endWidget(); ?> </div>
/** * Create a static page. * * This method allows the admin to create a static page to go on the top bar * menu. The page is a basic doc editor which is then saved as a Module record * of type "Document." */ public function actionCreatePage() { $existingDocs = X2Model::model('Docs')->findAll(); $existingDocs = CHtml::listData($existingDocs, 'id', 'name'); $model = new Docs(); $users = User::getNames(); if (isset($_POST['Docs'])) { $model->attributes = $_POST['Docs']; $model->createdBy = 'admin'; $model->createDate = time(); $model->lastUpdated = time(); $model->updatedBy = 'admin'; $module = new Modules(); $module->adminOnly = 0; $module->toggleable = 1; $module->custom = 1; $module->visible = 1; $module->editable = 0; $module->searchable = 0; $module->menuPosition = Modules::model()->count(); $module->name = 'document'; $module->title = $model->name; if ($module->save()) { if ($model->save()) { $this->redirect(array('/docs/docs/view', 'id' => $model->id, 'static' => 'true')); } } } else { if (isset($_POST['existingDoc'])) { $existingDoc = urldecode($_POST['existingDoc']); $docRecord = X2Model::model('Docs')->findByAttributes(array('name' => $existingDoc)); if (!is_null($docRecord)) { $module = new Modules(); $module->adminOnly = 0; $module->toggleable = 1; $module->custom = 1; $module->visible = 1; $module->editable = 0; $module->searchable = 0; $module->menuPosition = Modules::model()->count(); $module->name = 'document'; $module->title = $docRecord->name; if ($module->save()) { echo $docRecord->id; Yii::app()->end(); } else { $this->refresh(); } } } } $this->render('createPage', array('model' => $model, 'users' => $users, 'existingDocs' => $existingDocs)); }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); $users = User::getNames(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Actions'])) { $temp = $model->attributes; foreach ($model->attributes as $field => $value) { if (isset($_POST['Actions'][$field])) { $model->{$field} = $_POST['Actions'][$field]; } } $this->update($model, $temp, '0'); } $this->render('update', array('model' => $model, 'users' => $users)); }
/** * Returns assignment selection options * @param type $anyone * @param type $showGroups * @param type $showSeparator * @return type */ public static function getAssignmentOptions($anyone = true, $showGroups = true, $showSeparator = true) { $users = User::getNames(); if ($anyone !== true) { unset($users['Anyone']); } if ($showGroups === true) { $groups = Groups::getNames(); if (count($groups) > 0) { if ($showSeparator) { $users = $users + array('' => '--------------------') + $groups; } else { $users = $users + $groups; } } } return $users; }
$versions = FormVersions::model()->findAllByAttributes(array('modelName' => ucfirst($_GET['model']))); foreach ($versions as $version) { $str2 .= "<a href='?model=" . $_GET['model'] . "&version=" . CHtml::encode($version->name) . "'>" . $version->name . "</a> | "; } } $str2 = substr($str2, 0, -3); $str2 .= "</h4><br />"; echo $str2; } if ($formUrl == "") { } elseif ($model instanceof Contacts) { $this->renderPartial($formUrl, array('contactModel' => $model, 'users' => User::getNames(), 'editor' => true)); } elseif ($model instanceof Actions) { $this->renderPartial($formUrl, array('actionModel' => $model, 'users' => User::getNames(), 'editor' => true)); } else { $this->renderPartial($formUrl, array('model' => $model, 'users' => User::getNames(), 'contacts' => Contacts::getAllNames(), 'editor' => true)); } $fields = Fields::model()->findAllByAttributes(array('modelName' => get_class($model)), array('order' => 'tabOrder')); if (isset($_GET['version'])) { $version = $_GET['version']; $version = FormVersions::model()->findByAttributes(array('name' => $version)); $sizes = json_decode($version->sizes, true); $positions = json_decode($version->positions, true); $visibilities = json_decode($version->visibility, true); $tempArr = array(); foreach ($fields as $field) { if (isset($positions[$field->fieldName])) { $field->coordinates = $positions[$field->fieldName]; $field->size = $sizes[$field->fieldName]; $field->visible = $visibilities[$field->fieldName]; $tempArr[] = $field;
// $cs->registerScript(__CLASS__, $this->defaultOptions?'jQuery.{$this->mode}picker.setDefaults('.CJavaScript::encode($this->defaultOptions).');':''); // $cs->registerScript(__CLASS__.'#'.$id, $js); $fieldTypes = array(); $fieldLinkTypes = array(); $fieldOptions = array(); foreach ($itemModel->getFields() as $field) { $fieldTypes[$field->fieldName] = $field->type; if (!empty($field->linkType)) { $fieldLinkTypes[$field->fieldName] = $field->linkType; } switch ($field->type) { case 'dropdown': $fieldOptions[$field->fieldName] = Dropdowns::getItems($field->linkType); break; case 'assignment': $fieldOptions[$field->fieldName] = User::getNames() + Groups::getNames(); break; case 'link': $fieldOptions[$field->fieldName] = Yii::app()->request->scriptUrl . X2Model::model($field->linkType)->autoCompleteSource; break; } } $attributeLabels = $model->itemAttributeLabels; //hack tags in $fieldTypes['tags'] = 'tags'; $fieldOptions['tags'] = Tags::getAllTags(); $attributeLabels['tags'] = Yii::t('contacts', 'Tags'); natcasesort($attributeLabels); $comparisonList = array('=' => Yii::t('contacts', 'equals'), '>' => Yii::t('contacts', 'greater than'), '<' => Yii::t('contacts', 'less than'), '<>' => Yii::t('contacts', 'not equal to'), 'list' => Yii::t('contacts', 'in list'), 'notList' => Yii::t('contacts', 'not in list'), 'empty' => Yii::t('contacts', 'empty'), 'notEmpty' => Yii::t('contacts', 'not empty'), 'contains' => Yii::t('contacts', 'contains'), 'noContains' => Yii::t('contacts', 'does not contain')); $criteriaAttr = array(); foreach ($criteriaModels as $criterion) {
public function actionGetGroups() { $checked = false; if (isset($_POST['checked'])) { // coming from a group checkbox? $checked = json_decode($_POST['checked']); } elseif (isset($_POST['group'])) { $checked = true; } $id = null; if (isset($_POST['field'])) { $id = $_POST['field']; } $options = array(); if ($checked) { // group checkbox checked, return list of groups echo CHtml::listOptions($id, Groups::getNames(), $options); } else { // group checkbox unchecked, return list of user names $users = User::getNames(); if (!in_array($id, array_keys($users))) { $id = Yii::app()->user->getName(); } echo CHtml::listOptions($id, $users, $options); } }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); $users = User::getNames(); $fields = Fields::model()->findAllByAttributes(array('modelName' => "Templates")); foreach ($fields as $field) { if ($field->type == 'link') { $fieldName = $field->fieldName; $type = ucfirst($field->linkType); if (is_numeric($model->{$fieldName}) && $model->{$fieldName} != 0) { eval("\$lookupModel={$type}::model()->findByPk(" . $model->{$fieldName} . ");"); if (isset($lookupModel)) { $model->{$fieldName} = $lookupModel->name; } } } elseif ($field->type == 'date') { $fieldName = $field->fieldName; $model->{$fieldName} = date("Y-m-d", $model->{$fieldName}); } } if (isset($_POST['Templates'])) { $temp = $model->attributes; foreach ($_POST['Templates'] as $name => $value) { if ($value == $model->getAttributeLabel($name)) { $_POST['Templates'][$name] = ''; } } foreach ($_POST as $key => $arr) { $pieces = explode("_", $key); if (isset($pieces[0]) && $pieces[0] == 'autoselect') { $newKey = $pieces[1]; if (isset($_POST[$newKey . "_id"]) && $_POST[$newKey . "_id"] != "") { $val = $_POST[$newKey . "_id"]; } else { $field = Fields::model()->findByAttributes(array('fieldName' => $newKey)); if (isset($field)) { $type = ucfirst($field->linkType); if ($type != "Contacts") { eval("\$lookupModel={$type}::model()->findByAttributes(array('name'=>'{$arr}'));"); } else { $names = explode(" ", $arr); if (count($names) > 1) { $lookupModel = Contacts::model()->findByAttributes(array('firstName' => $names[0], 'lastName' => $names[1])); } } if (isset($lookupModel)) { $val = $lookupModel->id; } else { $val = $arr; } } } $model->{$newKey} = $val; } } $temp = $model->attributes; foreach (array_keys($model->attributes) as $field) { if (isset($_POST['Templates'][$field])) { $model->{$field} = $_POST['Templates'][$field]; $fieldData = Fields::model()->findByAttributes(array('modelName' => 'Templates', 'fieldName' => $field)); if ($fieldData->type == 'assignment' && $fieldData->linkType == 'multiple') { $model->{$field} = Accounts::parseUsers($model->{$field}); } elseif ($fieldData->type == 'date') { $model->{$field} = strtotime($model->{$field}); } } } parent::update($model, $temp, '0'); } $this->render('update', array('model' => $model, 'users' => $users)); }