コード例 #1
0
 /**
  * Render a hidden input, a text input with an auto-complete
  * event, and a select button. These three items together
  * form the Contract Editable Element
  * @return The element's content as a string.
  */
 protected function renderControlEditable()
 {
     $content = null;
     $content .= ZurmoHtml::textField('stageToProbabilityMapping_notUsed', null, array('id' => $this->getEditableInputId(), 'style' => "display:none;"));
     $fieldData = CustomFieldData::getByName('SalesStages');
     if ($fieldData->serializedData != null) {
         $values = unserialize($fieldData->serializedData);
         if (!is_array($values)) {
             $values = array();
         }
     } else {
         $values = array();
     }
     $stagesToProbabilities = ContractsModule::getStageToProbabilityMappingData();
     foreach ($values as $value) {
         if (isset($stagesToProbabilities[$value])) {
             $probability = $stagesToProbabilities[$value];
         } else {
             $probability = 0;
         }
         $htmlOptions = array('name' => $this->getNameForInputField($value), 'value' => $probability);
         $element = $this->form->textField($this->model, $this->attribute, $htmlOptions);
         $element .= ZurmoHtml::tag('span', array(), $value);
         $content .= ZurmoHtml::tag('div', array('class' => 'has-lang-label'), $element);
     }
     return $content;
 }
コード例 #2
0
 protected function processUpdate($id, $data)
 {
     $automaticMappingDisabled = ContractsModule::isAutomaticProbabilityMappingDisabled();
     if ($automaticMappingDisabled === false) {
         // discard probability from $data
         unset($data['probability']);
     }
     return parent::processUpdate($id, $data);
 }
コード例 #3
0
 protected function registerStageToProbabilityMappingScript($form)
 {
     $stageInputId = Element::resolveInputIdPrefixIntoString(array(get_class($this->model), 'stage', 'value'));
     $probabilityInputId = Element::resolveInputIdPrefixIntoString(array(get_class($this->model), 'probability'));
     $mappingData = ContractsModule::getStageToProbabilityMappingData();
     if (count($mappingData) > 0) {
         $jsonEncodedMapping = CJSON::encode($mappingData);
         // In case of edit, we need the exact value from db
         if ($this->model->id > 0) {
             $initialCallToFunction = "";
         } else {
             $initialCallToFunction = " stageToProbabilityMapping(\$('#" . $stageInputId . "'));";
         }
         Yii::app()->clientScript->registerScript('stageToProbabilityMapping', "\n                \$('#" . $stageInputId . "').unbind('change.probabilityMapping');\n                \$('#" . $stageInputId . "').bind('change.probabilityMapping', function()\n                    {\n                        stageToProbabilityMapping(\$(this));\n                    }\n                );\n                function stageToProbabilityMapping(stageInput)\n                {\n                    var value  = stageInput.val();\n                    var result = \$.parseJSON('" . $jsonEncodedMapping . "');\n                    \$('#" . $probabilityInputId . "').val(0);\n                    \$.each(result, function(stage, probability)\n                    {\n                        if (value == stage)\n                        {\n                            \$('#" . $probabilityInputId . "').val(probability);\n                            return false;\n                        }\n                    });\n                 }\n                 " . $initialCallToFunction);
     }
 }
コード例 #4
0
 protected function resolveConfirmAlertInHtmlOptions($htmlOptions)
 {
     $htmlOptions['confirm'] = Zurmo::t('Core', 'Are you sure you want to delete this {modelLabel}?', array('{modelLabel}' => ContractsModule::getModuleLabelByTypeAndLanguage('SingularLowerCase')));
     return $htmlOptions;
 }
コード例 #5
0
 /**
  * Action called in the event that the mass delete quantity is larger than the pageSize.
  * This action is called after the pageSize quantity has been delted and continues to be
  * called until the mass delete action is complete.  For example, if there are 20 records to delete
  * and the pageSize is 5, then this action will be called 3 times.  The first 5 are updated when
  * the actionMassDelete is called upon the initial form submission.
  */
 public function actionMassDeleteProgress()
 {
     $pageSize = Yii::app()->pagination->resolveActiveForCurrentUserByType('massDeleteProgressPageSize');
     $contract = new Contract(false);
     $dataProvider = $this->getDataProviderByResolvingSelectAllFromGet(new ContractsSearchForm($contract), $pageSize, Yii::app()->user->userModel->id, null, 'ContractsSearchView');
     $this->processMassDeleteProgress('Contract', $pageSize, ContractsModule::getModuleLabelByTypeAndLanguage('Plural'), $dataProvider);
 }
コード例 #6
0
 public function testGetModelClassNames()
 {
     $modelClassNames = ContractsModule::getModelClassNames();
     $this->assertEquals(2, count($modelClassNames));
     $this->assertEquals('Contract', $modelClassNames[0]);
     $this->assertEquals('ContractStarred', $modelClassNames[1]);
 }
 public function testSuperUserContractDefaultControllerActions()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     //Default Controller actions requiring some sort of parameter via POST or GET
     //Load Contract Modules Menu.
     $this->setGetArray(array('moduleClassName' => 'ContractsModule'));
     $this->runControllerWithNoExceptionsAndGetContent('designer/default/modulesMenu');
     //Load AttributesList for Contract module.
     $this->setGetArray(array('moduleClassName' => 'ContractsModule'));
     $this->runControllerWithNoExceptionsAndGetContent('designer/default/attributesList');
     //Load ModuleLayoutsList for Contract module.
     $this->setGetArray(array('moduleClassName' => 'ContractsModule'));
     $this->runControllerWithNoExceptionsAndGetContent('designer/default/moduleLayoutsList');
     //Load ModuleEdit view for each applicable module.
     $this->setGetArray(array('moduleClassName' => 'ContractsModule'));
     $this->runControllerWithNoExceptionsAndGetContent('designer/default/moduleEdit');
     //Now validate save with failed validation.
     $this->setGetArray(array('moduleClassName' => 'ContractsModule'));
     $this->setPostArray(array('ajax' => 'edit-form', 'ContractsModuleForm' => $this->createModuleEditBadValidationPostData()));
     $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/moduleEdit');
     $this->assertTrue(strlen($content) > 50);
     //approximate, but should definetely be larger than 50.
     //Now validate save with successful validation.
     $this->setGetArray(array('moduleClassName' => 'ContractsModule'));
     $this->setPostArray(array('ajax' => 'edit-form', 'ContractsModuleForm' => $this->createModuleEditGoodValidationPostData('opp new name')));
     $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/moduleEdit');
     $this->assertEquals('[]', $content);
     //Now save successfully.
     $this->setGetArray(array('moduleClassName' => 'ContractsModule'));
     $this->setPostArray(array('save' => 'Save', 'ContractsModuleForm' => $this->createModuleEditGoodValidationPostData('opp new name')));
     $this->runControllerWithRedirectExceptionAndGetContent('designer/default/moduleEdit');
     //Now confirm everything did in fact save correctly.
     $this->assertEquals('Opp New Name', ContractsModule::getModuleLabelByTypeAndLanguage('Singular'));
     $this->assertEquals('Opp New Names', ContractsModule::getModuleLabelByTypeAndLanguage('Plural'));
     $this->assertEquals('opp new name', ContractsModule::getModuleLabelByTypeAndLanguage('SingularLowerCase'));
     $this->assertEquals('opp new names', ContractsModule::getModuleLabelByTypeAndLanguage('PluralLowerCase'));
     //Load LayoutEdit for each applicable module and applicable layout
     $this->resetPostArray();
     $this->setGetArray(array('moduleClassName' => 'ContractsModule', 'viewClassName' => 'ContractsListView'));
     $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit');
     $this->setGetArray(array('moduleClassName' => 'ContractsModule', 'viewClassName' => 'ContractsModalListView'));
     $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit');
     $this->setGetArray(array('moduleClassName' => 'ContractsModule', 'viewClassName' => 'ContractsModalSearchView'));
     $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit');
     $this->setGetArray(array('moduleClassName' => 'ContractsModule', 'viewClassName' => 'ContractsMassEditView'));
     $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit');
     $this->setGetArray(array('moduleClassName' => 'ContractsModule', 'viewClassName' => 'ContractsRelatedListView'));
     $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit');
     $this->setGetArray(array('moduleClassName' => 'ContractsModule', 'viewClassName' => 'ContractsSearchView'));
     $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit');
     $this->setGetArray(array('moduleClassName' => 'ContractsModule', 'viewClassName' => 'ContractEditAndDetailsView'));
     $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit');
 }
コード例 #8
0
ファイル: Contract.php プロジェクト: maruthisivaprasad/zurmo
 private function resolveStageToProbability()
 {
     if ($this->stage === null) {
         throw new NotSupportedException();
     } else {
         $this->probability = ContractsModule::getProbabilityByStageValue($this->stage->value);
     }
 }