Exemple #1
0
 public function run()
 {
     $object = Object::getForClass(\app\models\Form::className());
     $groups = PropertyGroup::getForModel($object->id, $this->formId);
     $view = !empty($this->model->form_view) ? $this->model->form_view : 'form';
     $successView = !empty($this->model->form_success_view) ? $this->model->form_success_view : 'success';
     if (!$this->isModal) {
         echo Html::beginTag('div', ['id' => 'form-info-' . $this->id, 'style' => 'display: none;']);
         echo $this->render($successView);
         echo '</div>';
     }
     echo $this->render($view, ['id' => $this->id, 'model' => $this->model, 'groups' => $groups, 'options' => $this->options]);
     if ($this->isModal) {
         Modal::end();
         Modal::begin(['id' => 'modal-form-info-' . $this->id, 'size' => Modal::SIZE_SMALL, 'header' => $this->statusHeaderName ? $this->statusHeaderName : $this->model->name . ' ' . \Yii::t('app', 'status')]);
         echo $this->render($successView);
         Modal::end();
     }
 }
 /**
  * @inheritdoc
  */
 public function run()
 {
     if (null === ($form = Form::findById($this->formId)) || null === $this->model || null === $this->model->object) {
         throw new InvalidParamException();
     }
     if ($this->registerCanonical === true) {
         $this->getView()->registerLinkTag(['rel' => 'canonical', 'href' => ObjectRule::canonical($this->additionalParams)], 'canonical');
     }
     $formObject = Object::getForClass(Form::className());
     $groups = PropertyGroup::getForModel($formObject->id, $form->id);
     $models = Review::getForObjectModel($this->model->id, $this->model->object->id, $form->id);
     $review = new Review(['scenario' => 'check']);
     $review->useCaptcha = $this->useCaptcha;
     /** @var $module \app\modules\review\ReviewModule */
     $module = Yii::$app->getModule('review');
     $maxPerPage = $module->maxPerPage;
     $pageSize = $module->pageSize;
     if ($pageSize > $maxPerPage) {
         $pageSize = $maxPerPage;
     }
     $this->additionalParams['review-page'] = Yii::$app->request->get('review-page');
     $this->additionalParams['review-per-page'] = Yii::$app->request->get('review-per-page');
     return $this->render($this->viewFile, ['reviews' => new ArrayDataProvider(['id' => 'review', 'allModels' => $models, 'pagination' => ['pageSize' => $pageSize, 'params' => $this->additionalParams], 'sort' => ['attributes' => ['submission_id'], 'defaultOrder' => ['submission_id' => $this->sort]]]), 'objectModel' => $this->model, 'model' => $form, 'review' => $review, 'groups' => $groups, 'ratingGroupName' => $this->ratingGroupName, 'useCaptcha' => $this->useCaptcha, 'additionalParams' => $this->additionalParams]);
 }
Exemple #3
0
?>
            <?php 
BackendWidget::end();
?>
        </div>
    </div>
</div>
<?php 
echo $this->blocks['page-buttons'];
$form->end();
?>

<?php 
\yii\bootstrap\Modal::begin(['id' => 'custom-fields-modal', 'header' => Yii::t('app', 'Edit order properties')]);
$form = \kartik\widgets\ActiveForm::begin(['action' => ['update-order-properties', 'id' => $model->id]]);
foreach (\app\models\PropertyGroup::getForModel($model->object->id, $model->id) as $group) {
    ?>
    <?php 
    if ($group->hidden_group_title == 0) {
        ?>
        <h4><?php 
        echo $group->name;
        ?>
</h4>
    <?php 
    }
    ?>
    <?php 
    $properties = \app\models\Property::getForGroupId($group->id);
    ?>
    <?php 
 * @var yii\web\View $this
 * @var app\backgroundtasks\models\Task $searchModel
 * @var $review \app\modules\review\models\Review
 */
use kartik\helpers\Html;
use app\models\Object;
use app\models\PropertyGroup;
use app\models\Property;
use app\models\Form;
use kartik\icons\Icon;
use yii\widgets\ActiveForm;
use app\modules\review\models\Review;
$this->title = Yii::t('app', 'Review show');
$this->params['breadcrumbs'] = [['label' => Yii::t('app', 'Reviews'), 'url' => ['index']], $this->title];
$formObject = Object::getForClass(Form::className());
$groups = PropertyGroup::getForModel($formObject->id, $review->submission->form_id);
$review->submission->getPropertyGroups(true);
?>
<div class="review-show">
    <section id="widget-grid">
        <div class="row">
            <article class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                <div class="jarviswidget">
                    <header>
                        <h2><i class="fa fa-cubes"></i> <?php 
echo Yii::t('app', 'Review data');
?>
</h2>
                    </header>
                    <div class="widget-body">
                        <div class="form-group field-page-name">
Exemple #5
0
 public function getPropertyGroups($force = false, $getByObjectId = false, $createAbstractModel = false)
 {
     $message = "getPropertyGroups " . $this->owner->className() . ':' . $this->owner->id . " force:" . ($force ? 'true' : 'false') . " getByObjectId:" . ($getByObjectId ? 'true' : 'false') . " createAbstractModel:" . ($createAbstractModel ? 'true' : 'false');
     Yii::trace($message, 'properties');
     $cacheKey = $message;
     if ($this->properties === null && $force === false) {
         // try to get from cache
         $data = Yii::$app->cache->get($message);
         if ($data !== false) {
             Yii::trace("Properties from cache", 'properties');
             $this->abstract_model = isset($data['abstract_model']) ? $data['abstract_model'] : [];
             $this->properties = $data['properties'];
             $this->property_key_to_id = $data['property_key_to_id'];
             $this->property_id_to_group_id = $data['property_id_to_group_id'];
         }
     }
     if ($createAbstractModel === true && is_null($this->abstract_model)) {
         // force creating abstract model if it is null and needed
         $force = true;
     }
     if ($this->properties === null || $force === true) {
         $tags = [ActiveRecordHelper::getObjectTag($this->owner->className(), $this->owner->id)];
         $this->properties = [];
         if ($getByObjectId === true) {
             $groups = PropertyGroup::getForObjectId($this->getObject()->id);
         } else {
             $groups = PropertyGroup::getForModel($this->getObject()->id, $this->owner->id);
         }
         $values_for_abstract = [];
         $properties_models = [];
         $rules = [];
         /** @var PropertyGroup $group */
         foreach ($groups as $group) {
             $tags[] = ActiveRecordHelper::getObjectTag(PropertyGroup::className(), $group->id);
             $this->properties[$group->id] = [];
             $props = Property::getForGroupId($group->id);
             foreach ($props as $p) {
                 $values = $this->getPropertyValues($p);
                 $this->properties[$group->id][$p->key] = $values;
                 if ($createAbstractModel === true) {
                     $values_for_abstract[$p->key] = $values;
                 }
                 $properties_models[$p->key] = $p;
                 $this->property_key_to_id[$p->key] = $p->id;
                 if (!isset($this->property_id_to_group_id[$group->id])) {
                     $this->property_id_to_group_id[$group->id] = [$p->key];
                 } else {
                     $this->property_id_to_group_id[$group->id][] = $p->key;
                 }
                 if ($createAbstractModel === true) {
                     $handlerAdditionalParams = Json::decode($p->handler_additional_params);
                     if (isset($handlerAdditionalParams['rules']) && is_array($handlerAdditionalParams['rules'])) {
                         foreach ($handlerAdditionalParams['rules'] as $rule) {
                             if (is_array($rule)) {
                                 $rules[] = ArrayHelper::merge([$p->key], $rule);
                             } else {
                                 $rules[] = [$p->key, $rule];
                             }
                         }
                     }
                 }
             }
         }
         if ($createAbstractModel === true) {
             $this->abstract_model = new AbstractModel([], $this->owner);
             $this->abstract_model->setPropertiesModels($properties_models);
             $this->abstract_model->setAttributes($values_for_abstract);
             $this->abstract_model->setFormName('Properties_' . $this->owner->formName() . '_' . $this->owner->id);
             $this->abstract_model->addRules($rules);
         }
         $res = Yii::$app->cache->set($cacheKey, ['properties' => $this->properties, 'abstract_model' => $this->abstract_model, 'property_id_to_group_id' => $this->property_id_to_group_id, 'property_key_to_id' => $this->property_key_to_id], 86400, new TagDependency(['tags' => $tags]));
         Yii::trace('putting props to cache: ' . ($res ? 'true' : 'false') . ' key:' . $cacheKey, 'properties');
     }
     return $this->properties;
 }