public function quickCreate($model)
 {
     if (isset($_POST['SelectedTab'])) {
         $this->owner->actionPublisherCreate();
     } else {
         return parent::quickCreate($model);
     }
 }
 /**
  * Returns an array of all model classes (associated with some module) which have this
  * behavior
  *
  * @return <array of strings>
  */
 public static function getModelsWhichSupportQuickCreate($includeActions = false)
 {
     if (!isset(self::$_modelsWhichSupportQuickCreate)) {
         self::$_modelsWhichSupportQuickCreate = array_diff(array_keys(X2Model::getModelNames()), array('Docs', 'Groups', 'Campaign', 'Media', 'Quote', 'BugReports'));
         self::$_modelsWhichSupportQuickCreate[] = 'Actions';
     }
     $modelNames = self::$_modelsWhichSupportQuickCreate;
     if (!$includeActions) {
         array_pop($modelNames);
     }
     return $modelNames;
 }
 /**
  * Renders an inline record create/update form
  * @param object $model 
  * @param bool $hasErrors
  */
 public function renderInlineForm($model, array $viewParams = array())
 {
     if (isset($_POST['modelId']) && !isset($model->associationId)) {
         $model->associationId = $_POST['modelId'];
     }
     if (isset($_POST['modelName']) && !isset($model->associationType)) {
         $model->associationType = $_POST['modelName'];
     }
     if ($model instanceof ActionFormModelBase) {
         echo CJSON::encode(array('status' => $model->hasErrors() ? 'userError' : 'success', 'page' => $this->owner->renderPartial('application.modules.actions.views.actions._' . lcfirst(preg_replace('/^(.*)FormModel/', '$1', get_class($model))) . 'Form', array('model' => $model), true, true)));
     } else {
         parent::renderInlineForm($model, array_merge(array('namespace' => get_class($this)), $viewParams));
     }
 }
예제 #4
0
 private function registerX2QuickCRUD()
 {
     $this->registerPackages(array('QuickCRUD' => array('baseUrl' => Yii::app()->request->baseUrl, 'js' => array('js/X2Widget.js', 'js/X2QuickCRUD.js', 'js/X2QuickCreate.js', 'js/X2QuickRead.js'))));
     $modelsWhichSupportQuickCreate = QuickCreateRelationshipBehavior::getModelsWhichSupportQuickCreate(true);
     $createUrls = QuickCreateRelationshipBehavior::getCreateUrlsForModels($modelsWhichSupportQuickCreate);
     $viewUrls = QuickCRUDBehavior::getUrlsForModels(QuickCRUDBehavior::getModelsWhichSupportQuickView(), 'view');
     $dialogTitles = QuickCreateRelationshipBehavior::getDialogTitlesForModels($modelsWhichSupportQuickCreate);
     $this->registerScript('registerQuickCreate', "\n            x2.QuickCreate.createRecordUrls = " . CJSON::encode($createUrls) . ";\n            x2.QuickCreate.dialogTitles = " . CJSON::encode($dialogTitles) . ";\n            x2.QuickRead.viewRecordUrls = " . CJSON::encode($viewUrls) . ";\n            x2.QuickRead.translations = " . CJSON::encode(array('View inline record details' => Yii::t('app', 'View inline record details'))) . ";\n            x2.QuickRead.dialogTitles = " . CJSON::encode($dialogTitles) . ";\n        ", CClientScript::POS_END);
 }
예제 #5
0
파일: _form.php 프로젝트: dsyman2/X2CRM
                        unset($col);
                        $htmlString .= '</tr>';
                    }
                    $htmlString .= '</table></div>';
                }
                unset($row);
                $htmlString .= '</div>';
                if (!$noItems) {
                    echo $htmlString;
                }
                $i++;
            }
        }
        ?>
    </div>
    <?php 
    }
    if (isset($suppressForm) && !$suppressForm || !isset($suppressForm)) {
        if ($renderFormTags) {
            echo '<div class="row buttons save-button-row">' . CHtml::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Save'), array('class' => 'x2-button', 'id' => 'save-button', 'tabindex' => 24)) . '</div>';
            $this->endWidget();
        }
    }
    Yii::app()->clientScript->registerScript('mask-currency', '
    $(".currency-field").maskMoney("mask");
', CClientScript::POS_READY);
    if (!$suppressQuickCreate) {
        Yii::app()->clientScript->registerScriptFile(Yii::app()->getBaseUrl() . '/js/Relationships.js');
        Yii::app()->clientScript->registerScript('_formScript', "\n\n(function () {\n    var quickCreateUrls = " . CJSON::encode(QuickCreateRelationshipBehavior::getCreateUrlsForModels($quickCreateButtonTypes)) . ";\n    var quickCreateTooltips = " . CJSON::encode(QuickCreateRelationshipBehavior::getDialogTooltipsForModels($quickCreateButtonTypes, get_class($model))) . ";\n    var quickCreateDialogTitles = " . CJSON::encode(QuickCreateRelationshipBehavior::getDialogTitlesForModels($quickCreateButtonTypes)) . ";\n    var defaultsByRelatedModelType = " . CJSON::encode(isset($defaultsByRelatedModelType) ? $defaultsByRelatedModelType : array()) . ";\n\n    \$('.quick-create-button').each (function () {\n        var relatedModelType = \$(this).attr ('class').match (/(?:[ ]|^)create-([^ ]+)/)[1];\n        new x2.RelationshipsManager ({\n            element: \$(this),\n            modelType: '" . get_class($model) . "',\n            modelId: " . (isset($model->id) ? $model->id : 'null') . ",\n            relatedModelType: relatedModelType,\n            createRecordUrl: quickCreateUrls[relatedModelType],\n            dialogTitle: quickCreateDialogTitles[relatedModelType],\n            tooltip: quickCreateTooltips[relatedModelType],\n            attributeDefaults: defaultsByRelatedModelType[relatedModelType],\n            lookupFieldElement: \$(this).siblings ('.formInputBox').find ('input').last (),\n            isViewPage: false\n        });\n    });\n\n}) ();\n\n", CClientScript::POS_READY);
    }
}
예제 #6
0
 public function getSetupScript()
 {
     if (!isset($this->_setupScript)) {
         $widgetClass = get_called_class();
         if (isset($_GET['ajax'])) {
             $this->_setupScript = "";
         } else {
             $modelsWhichSupportQuickCreate = QuickCreateRelationshipBehavior::getModelsWhichSupportQuickCreate();
             // get create action urls for each linkable model
             $createUrls = QuickCreateRelationshipBehavior::getCreateUrlsForModels($modelsWhichSupportQuickCreate);
             // get create relationship tooltips for each linkable model
             $tooltips = QuickCreateRelationshipBehavior::getDialogTooltipsForModels($modelsWhichSupportQuickCreate, get_class($this->model));
             // get create relationship dialog titles for each linkable model
             $dialogTitles = QuickCreateRelationshipBehavior::getDialogTitlesForModels($modelsWhichSupportQuickCreate);
             $this->_setupScript = "\n                    \$(function () {\n                        x2.inlineRelationshipsWidget = new x2.InlineRelationshipsWidget (" . CJSON::encode(array_merge($this->getJSSortableWidgetParams(), array('displayMode' => $this->getWidgetProperty('displayMode'), 'widgetClass' => $widgetClass, 'setPropertyUrl' => Yii::app()->controller->createUrl('/profile/setWidgetSetting'), 'cssSelectorPrefix' => $this->widgetType, 'widgetType' => $this->widgetType, 'widgetUID' => $this->widgetUID, 'enableResizing' => true, 'height' => $this->getWidgetProperty('height'), 'recordId' => $this->model->id, 'recordType' => get_class($this->model), 'defaultsByRelatedModelType' => $this->defaultsByRelatedModelType, 'createUrls' => $createUrls, 'dialogTitles' => $dialogTitles, 'tooltips' => $tooltips, 'modelsWhichSupportQuickCreate' => array_values($modelsWhichSupportQuickCreate), 'ajaxGetModelAutocompleteUrl' => Yii::app()->controller->createUrl('ajaxGetModelAutocomplete'), 'createRelationshipUrl' => Yii::app()->controller->createUrl('/relationships/addRelationship'), 'hasUpdatePermissions' => $this->checkModuleUpdatePermissions()))) . "\n                        );\n                    });\n                ";
         }
     }
     return $this->_setupScript;
 }
예제 #7
0
 public function getJSClassParams()
 {
     return array_merge(parent::getJSClassParams(), array('quickCreate' => array('urls' => QuickCreateRelationshipBehavior::getCreateUrlsForModels($this->_quickCreateButtonTypes), 'tooltips' => QuickCreateRelationshipBehavior::getDialogTooltipsForModels($this->_quickCreateButtonTypes, get_class($this->model)), 'dialogTitles' => QuickCreateRelationshipBehavior::getDialogTitlesForModels($this->_quickCreateButtonTypes), 'defaults' => $this->defaultsByRelatedModelType), 'translations' => array('title' => Yii::t('app', 'Discard unsaved changes?'), 'message' => Yii::t('app', 'You have unsaved changes to this record. Discard changes?'), 'cancel' => Yii::t('app', 'Cancel'), 'confirm' => Yii::t('app', 'Yes'))));
 }
예제 #8
0
파일: FormView.php 프로젝트: shuvro35/X2CRM
 public function getJSClassParams()
 {
     return array_merge(parent::getJSClassParams(), array('quickCreate' => array('urls' => QuickCreateRelationshipBehavior::getCreateUrlsForModels($this->_quickCreateButtonTypes), 'tooltips' => QuickCreateRelationshipBehavior::getDialogTooltipsForModels($this->_quickCreateButtonTypes, get_class($this->model)), 'dialogTitles' => QuickCreateRelationshipBehavior::getDialogTitlesForModels($this->_quickCreateButtonTypes), 'defaults' => $this->defaultsByRelatedModelType)));
 }