* 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". *****************************************************************************************/ /** * Used by inline workflow widget to render the funnel */ if (AuxLib::isIE8()) { Yii::app()->clientScript->registerScriptFile(Yii::app()->getBaseUrl() . '/js/jqplot/excanvas.js'); } if ($this->id !== 'Workflow') { $assetsUrl = Yii::app()->assetManager->publish(Yii::getPathOfAlias('application.modules.workflow.assets'), false, -1, YII_DEBUG ? true : null); } else { $assetsUrl = $this->module->assetsUrl; } Yii::app()->clientScript->registerScriptFile($assetsUrl . '/js/X2Geometry.js', CClientScript::POS_END); Yii::app()->clientScript->registerScriptFile($assetsUrl . '/js/BaseFunnel.js', CClientScript::POS_END); Yii::app()->clientScript->registerScriptFile($assetsUrl . '/js/InlineFunnel.js', CClientScript::POS_END); Yii::app()->clientScript->registerScript('_funnelJS', "\n\nx2.inlineFunnel = new x2.InlineFunnel ({\n workflowStatus: " . CJSON::encode($workflowStatus) . ",\n translations: " . CJSON::encode(array('Completed' => Yii::t('workflow', 'Completed'), 'Started' => Yii::t('workflow', 'Started'), 'Details' => Yii::t('workflow', 'Details'), 'Revert Stage' => Yii::t('workflow', 'Revert Stage'), 'Complete Stage' => Yii::t('workflow', 'Complete Stage'), 'Start' => Yii::t('workflow', 'Start'), 'noRevertPermissions' => Yii::t('workflow', 'You do not have permission to revert this stage.'), 'noCompletePermissions' => Yii::t('workflow', 'You do not have permission to complete this stage.'))) . ",\n stageCount: " . $stageCount . ",\n containerSelector: '#funnel-container',\n colors: " . CJSON::encode($colors) . ",\n revertButtonUrl: '" . Yii::app()->theme->getBaseUrl() . "/images/icons/Uncomplete.png',\n completeButtonUrl: '" . Yii::app()->theme->getBaseUrl() . "/images/icons/Complete.png',\n stageNames: " . CJSON::encode(Workflow::getStageNames($workflowStatus)) . ",\n stagePermissions: " . CJSON::encode(Workflow::getStagePermissions($workflowStatus)) . ",\n uncompletionPermissions: " . CJSON::encode(Workflow::getStageUncompletionPermissions($workflowStatus)) . ",\n stagesWhichRequireComments: " . CJSON::encode(Workflow::getStageCommentRequirements($workflowStatus)) . "\n});\n\n", CClientScript::POS_END); ?> <div id='funnel-container'></div>
private function getDragAndDropViewParams($id, $users = '') { $model = $this->loadModel($id); $modelType = isset($_GET['modelType']) ? self::parseModelType($_GET['modelType']) : ''; $dateRange = self::getDateRange(); $expectedCloseDateDateRange = self::getDateRange('expectedCloseDateStart', 'expectedCloseDateEnd', 'expectedCloseDateRange'); $memberListContainerSelectors = array(); $stageValues = Workflow::getStageValues($model, $users, $modelType, $dateRange, $expectedCloseDateDateRange); $stageCount = count($model->stages); for ($i = 1; $i <= $stageCount; $i++) { $memberListContainerSelectors[] = '#workflow-stage-' . $i . ' .items'; } $workflowStatus = Workflow::getWorkflowStatus($id); $stagePermissions = Workflow::getStagePermissions($workflowStatus); $stagesWhichRequireComments = Workflow::getStageCommentRequirements($workflowStatus); $stageNames = Workflow::getStageNames($workflowStatus); $colors = $model->getWorkflowStageColors($stageCount, true); return array('model' => $model, 'modelType' => $modelType, 'dateRange' => $dateRange, 'expectedCloseDateDateRange' => $expectedCloseDateDateRange, 'users' => $users, 'colors' => $colors, 'listItemColors' => Workflow::getPipelineListItemColors($colors), 'memberListContainerSelectors' => $memberListContainerSelectors, 'stagePermissions' => $stagePermissions, 'stagesWhichRequireComments' => $stagesWhichRequireComments, 'stageNames' => $stageNames, 'stageValues' => $stageValues); }
/** * @param int $stageA * @param int $stageB * @param array $workflowStatus * @param array $comments Comments indexed by stage number * @return bool true if comments array has a comment for each stage which requires a comment * in the range [$stageA, $stageB] */ private static function checkCommentRequirements($stageA, $stageB = null, $workflowStatus, $comments) { $stagesWhichRequireComments = Workflow::getStageCommentRequirements($workflowStatus); $commentRequirementsMet = true; if ($stageB === null) { return !$stagesWhichRequireComments[$stageA - 1] || isset($comments[$stageA]) && !empty($comments[$stageA]); } for ($i = $stageA - 1; $i < $stageB - 1; ++$i) { $commentRequirementsMet &= !$stagesWhichRequireComments[$i] || isset($comments[$i + 1]) && !empty($comments[$i + 1]); } return $commentRequirementsMet; }
private function getDragAndDropViewParams($id, $users = '') { $model = $this->loadModel($id); if (isset($_GET['modelType'])) { $modelType = $_GET['modelType']; } elseif (!empty($model->financialModel)) { if (X2Model::getModelName($model->financialModel)) { $modelType = $model->financialModel; } else { $modelType = 'contacts'; } } else { $modelType = 'contacts'; } $dateRange = self::getDateRange(); $memberListContainerSelectors = array(); $stageCount = count($model->stages); for ($i = 1; $i <= $stageCount; $i++) { $memberListContainerSelectors[] = '#workflow-stage-' . $i . ' .items'; } $workflowStatus = Workflow::getWorkflowStatus($id); $stagePermissions = Workflow::getStagePermissions($workflowStatus); $stagesWhichRequireComments = Workflow::getStageCommentRequirements($workflowStatus); $stageNames = Workflow::getStageNames($workflowStatus); $colors = $model->getWorkflowStageColors($stageCount, true); $stageCounts = Workflow::getStageCounts($workflowStatus, $dateRange, $users, $modelType); $stageValues = Workflow::getStageValues($workflowStatus, $dateRange, $users, $modelType); return array('model' => $model, 'modelType' => $modelType, 'dateRange' => $dateRange, 'users' => $users, 'colors' => $colors, 'listItemColors' => Workflow::getPipelineListItemColors($colors), 'memberListContainerSelectors' => $memberListContainerSelectors, 'stagePermissions' => $stagePermissions, 'stagesWhichRequireComments' => $stagesWhichRequireComments, 'stageNames' => $stageNames, 'stageCounts' => $stageCounts, 'stageValues' => $stageValues); }