public static function defaultColumns()
 {
     return ['fqdn' => ['attribute' => 'fqdn', 'value' => function ($model) {
         return $model->fqdn;
     }], 'type' => ['value' => function ($model) {
         return strtoupper($model->type);
     }], 'value' => ['value' => function ($model) {
         return $model->getValueText();
     }], 'zone' => ['class' => MainColumn::className(), 'label' => Yii::t('hipanel:dns', 'Zone'), 'attribute' => 'name'], 'actions' => ['class' => ActionColumn::className(), 'template' => '{update} {delete}', 'visibleButtonsCount' => 2, 'options' => ['style' => 'width: 15%'], 'buttons' => ['update' => function ($url, $model, $key) {
         if ($model->is_system) {
             return Html::tag('div', Html::a('<i class="fa fa-pencil"></i> ' . Yii::t('hipanel', 'Update'), null, ['class' => 'btn btn-default btn-xs disabled']), ['data-placement' => 'top', 'data-toggle' => 'tooltip', 'title' => Yii::t('hipanel:dns', 'This record was created by hosting panel automatically and cannot be updated'), 'style' => 'display: inline-block; cursor: not-allowed;']);
         }
         $data = Html::a('<i class="fa fa-pencil"></i> ' . Yii::t('hipanel', 'Update'), null, ['class' => 'btn btn-default btn-xs edit-dns-toggle', 'data' => ['record_id' => $model->id, 'hdomain_id' => $model->hdomain_id, 'load-url' => Url::to(['@dns/record/update', 'hdomain_id' => $model->hdomain_id, 'id' => $model->id])]]);
         $progress = Json::htmlEncode("<tr><td colspan='5'>" . Progress::widget(['id' => 'progress-bar', 'percent' => 100, 'barOptions' => ['class' => 'active progress-bar-striped', 'style' => 'width: 100%']]) . '</td></tr>');
         Yii::$app->view->registerJs("\n                            \$('.edit-dns-toggle').click(function () {\n                                var record_id = \$(this).data('id');\n                                var hdomain_id = \$(this).data('hdomain_id');\n\n                                var currentRow = \$(this).closest('tr');\n                                var newRow = \$({$progress});\n\n                                \$(newRow).data({'record_id': record_id, hdomain_id: hdomain_id});\n                                \$('tr').filter(function () { return \$(this).data('id') == record_id; }).find('.btn-cancel').click();\n                                \$(newRow).insertAfter(currentRow);\n\n                                jQuery.ajax({\n                                    url: \$(this).data('load-url'),\n                                    type: 'GET',\n                                    timeout: 0,\n                                    error: function() {\n\n                                    },\n                                    success: function(data) {\n                                        newRow.find('td').html(data);\n                                        newRow.find('.btn-cancel').on('click', function (event) {\n                                            event.preventDefault();\n                                            newRow.remove();\n                                        });\n                                    }\n                                });\n\n                            });\n                        ");
         return $data;
     }, 'delete' => function ($url, $model, $key) {
         if ($model->type === 'ns' && $model->is_system) {
             return Html::tag('div', Html::a('<i class="fa text-danger fa-trash-o"></i> ' . Yii::t('hipanel', 'Delete'), null, ['class' => 'btn btn-default btn-xs disabled']), ['data-placement' => 'top', 'data-toggle' => 'tooltip', 'title' => Yii::t('hipanel:dns', 'This record is important for the domain zone viability and can not be deleted'), 'style' => 'display: inline-block; cursor: not-allowed;']);
         }
         return ModalButton::widget(['model' => $model, 'scenario' => 'delete', 'submit' => ModalButton::SUBMIT_PJAX, 'form' => ['action' => Url::to('@dns/record/delete')], 'button' => ['class' => 'btn btn-default btn-xs', 'label' => '<i class="fa text-danger fa-trash-o"></i> ' . Yii::t('hipanel', 'Delete')], 'modal' => ['header' => Html::tag('h4', Yii::t('hipanel:dns', 'Confirm DNS record deleting')), 'headerOptions' => ['class' => 'label-danger'], 'footer' => ['label' => Yii::t('hipanel:dns', 'Delete record'), 'data-loading-text' => Yii::t('hipanel:dns', 'Deleting record...'), 'class' => 'btn btn-danger']], 'body' => function ($model) {
             echo Html::activeHiddenInput($model, 'hdomain_id');
             echo Yii::t('hipanel:dns', 'Are you sure, that you want to delete record {name}?', ['name' => $model->fqdn]);
         }]);
     }]]];
 }
 public function items()
 {
     $actions = IpActionsMenu::create(['model' => $this->model])->items();
     $items = array_merge($actions, [['label' => ModalButton::widget(['model' => $this->model, 'scenario' => 'delete', 'button' => ['label' => '<i class="fa fa-fw fa-trash-o"></i> ' . Yii::t('hipanel', 'Delete')], 'modal' => ['header' => Html::tag('h4', Yii::t('hipanel:hosting', 'Confirm IP address deleting')), 'headerOptions' => ['class' => 'label-danger'], 'footer' => ['label' => Yii::t('hipanel:hosting', 'Delete IP address'), 'data-loading-text' => Yii::t('hipanel:hosting', 'Deleting IP address...'), 'class' => 'btn btn-danger']], 'body' => Yii::t('hipanel:hosting', 'Are you sure, that you want to delete IP address {ip}? All related objects might be deleted too!', ['ip' => Html::tag('b', $this->model->ip)])]), 'encode' => false, 'visible' => Yii::$app->user->can('admin')]]);
     unset($items['view']);
     return $items;
 }
 public function items()
 {
     return [['label' => $this->renderView('_change-password', ['model' => $this->model]), 'encode' => false], ['label' => ModalButton::widget(['model' => $this->model, 'scenario' => 'truncate', 'button' => ['label' => '<i class="fa fa-fw fa-file-o"></i>' . Yii::t('hipanel:hosting', 'Truncate')], 'modal' => ['header' => Html::tag('h4', Yii::t('hipanel:hosting', 'Confirm database truncating')), 'headerOptions' => ['class' => 'label-danger'], 'footer' => ['label' => Yii::t('hipanel:hosting', 'Truncate database'), 'data-loading-text' => Yii::t('hipanel', 'Performing...'), 'class' => 'btn btn-danger']], 'body' => Yii::t('hipanel:hosting', 'Are you sure that to truncate database {name}? All tables will be dropped, all data will be lost!', ['name' => Html::tag('b', $this->model->name)])]), 'encode' => false], ['label' => ModalButton::widget(['model' => $this->model, 'scenario' => 'delete', 'button' => ['label' => '<i class="fa fa-fw fa-trash-o"></i>' . Yii::t('hipanel', 'Delete')], 'modal' => ['header' => Html::tag('h4', Yii::t('hipanel:hosting', 'Confirm database deleting')), 'headerOptions' => ['class' => 'label-danger'], 'footer' => ['label' => Yii::t('hipanel:hosting', 'Delete database'), 'data-loading-text' => Yii::t('hipanel', 'Deleting...'), 'class' => 'btn btn-danger']], 'body' => Yii::t('hipanel:hosting', 'Are you sure to delete database {name}? All tables will be dropped, all data will be lost!', ['name' => Html::tag('b', $this->model->name)])]), 'encode' => false]];
 }
    ?>
    </li>
<?php 
}
if ($model->isFreezed() && Yii::$app->user->can('domain.unfreeze')) {
    ?>
    <li>
        <?php 
    echo ModalButton::widget(['model' => $model, 'scenario' => 'disable-freeze', 'button' => ['label' => '<i class="fa fa-fw fa-unlock"></i>' . Yii::t('hipanel:domain', 'Unfreeze domain')], 'modal' => ['header' => Html::tag('h4', Yii::t('hipanel:domain', 'Confirm domain unfreezing')), 'headerOptions' => ['class' => 'label-info'], 'footer' => ['label' => Yii::t('hipanel:domain', 'Unfreeze domain'), 'data-loading-text' => Yii::t('hipanel:domain', 'Unfreezing domain...'), 'class' => 'btn btn-danger']], 'body' => Yii::t('hipanel:domain', 'Are you sure, that you want to unfreeze domain <b>{domain}</b>?', ['domain' => $model->domain])]);
    ?>
    </li>
<?php 
}
if (!$model->isWPFreezed() && Yii::$app->user->can('domain.freeze')) {
    ?>
    <li>
        <?php 
    echo ModalButton::widget(['model' => $model, 'scenario' => 'enable-freeze-w-p', 'button' => ['label' => '<i class="fa fa-fw fa-lock"></i>' . Yii::t('hipanel:domain', 'Freeze WHOIS-protect')], 'modal' => ['header' => Html::tag('h4', Yii::t('hipanel:domain', 'Confirm freezing WHOIS-protect')), 'headerOptions' => ['class' => 'label-info'], 'footer' => ['label' => Yii::t('hipanel:domain', 'Freeze WHOIS-protect'), 'data-loading-text' => Yii::t('hipanel:domain', 'Freezing WHOIS-protect...'), 'class' => 'btn btn-danger']], 'body' => Yii::t('hipanel:domain', 'Are you sure, that you want to freeze WHOIS-protect <b>{domain}</b>?', ['domain' => $model->domain])]);
    ?>
    </li>
<?php 
}
if ($model->isWPFreezed() && Yii::$app->user->can('domain.unfreeze')) {
    ?>
    <li>
        <?php 
    echo ModalButton::widget(['model' => $model, 'scenario' => 'disable-freeze-w-p', 'button' => ['label' => '<i class="fa fa-fw fa-unlock"></i>' . Yii::t('hipanel:domain', 'Unfreeze WHOIS-protect')], 'modal' => ['header' => Html::tag('h4', Yii::t('hipanel:domain', 'Confirm unfreezing WHOIS-protect')), 'headerOptions' => ['class' => 'label-info'], 'footer' => ['label' => Yii::t('hipanel:domain', 'Unfreeze WHOIS-protect'), 'data-loading-text' => Yii::t('hipanel:domain', 'Unfreezing WHOIS-protect...'), 'class' => 'btn btn-danger']], 'body' => Yii::t('hipanel:domain', 'Are you sure, that you want to unfreeze WHOIS-protect for domain <b>{domain}</b>?', ['domain' => $model->domain])]);
    ?>
    </li>
<?php 
}
 public function items()
 {
     return [['label' => Yii::t('hipanel', 'Update'), 'icon' => 'fa-pencil', 'url' => ['update', 'id' => $this->model->id]], ['label' => $this->renderView('_change-password', ['model' => $this->model]), 'encode' => false, 'visible' => $this->model->canChangePassword()], ['label' => ModalButton::widget(['model' => $this->model, 'scenario' => 'delete', 'button' => ['label' => '<i class="fa fa-fw fa-trash-o"></i> ' . Yii::t('hipanel', 'Delete')], 'modal' => ['header' => Html::tag('h4', Yii::t('hipanel:hosting', 'Confirm mailbox deleting')), 'headerOptions' => ['class' => 'label-danger'], 'footer' => ['label' => Yii::t('hipanel:hosting', 'Delete mailbox'), 'data-loading-text' => Yii::t('hipanel', 'Deleting...'), 'class' => 'btn btn-danger']], 'body' => Yii::t('hipanel:hosting', 'Are you sure to delete mail {name}?', ['name' => Html::tag('b', $this->model->mail)])]), 'encode' => false]];
 }
Example #6
0
echo $form->field($model, "[{$id}]value", ['inputOptions' => ['data-attribute' => 'value']]);
?>
                </div>
                <div class="col-lg-2 col-md-2">
                    <?php 
echo $form->field($model, "[{$id}]ttl")->dropDownList([60 => 60, 600 => 600, 3600 => 3600, 7200 => 7200, 86400 => 86400]);
?>
                </div>
            </div>


            <?php 
if ($model->scenario === 'create') {
    echo Html::submitButton(Yii::t('hipanel', 'Create'), ['class' => 'btn btn-success']);
} else {
    echo Html::submitButton(Yii::t('hipanel', 'Save'), ['class' => 'btn btn-success']);
}
echo '&nbsp;';
echo Html::button(Yii::t('hipanel', 'Cancel'), ['type' => 'reset', 'class' => 'btn btn-default btn-cancel']);
echo '&nbsp;';
if ($model->scenario === 'update') {
    echo ModalButton::widget(['model' => $model, 'scenario' => 'delete', 'submit' => ModalButton::SUBMIT_PJAX, 'form' => false, 'button' => ['tag' => 'a', 'label' => '<i class="fa fa-trash-o"></i> ' . Yii::t('hipanel', 'Delete'), 'class' => 'pull-right btn btn-default'], 'modal' => ['header' => Html::tag('h4', Yii::t('hipanel:dns', 'Confirm DNS record deleting')), 'headerOptions' => ['class' => 'label-danger'], 'footer' => ['label' => Yii::t('hipanel:dns', 'Delete record'), 'data-loading-text' => Yii::t('hipanel:dns', 'Deleting record...'), 'class' => 'btn btn-danger']], 'body' => function ($model) {
        echo Yii::t('hipanel:dns', 'Are you sure, that you want to delete record {name}?', ['name' => $model->fqdn]);
    }]);
}
?>
        </div>
    </div>
<?php 
$form->end();
$this->registerJs("\$('#{$form->id} .record-item').on('change', '[data-attribute=type]', function () {\n    var form = \$(this).closest('form');\n    var name = \$(this).closest('.record-item').find('[data-attribute=name]');\n    var value = \$(this).closest('.record-item').find('[data-attribute=value]');\n\n    \$.each({name: name, value: value}, function (name, input) {\n        if (input.val().length > 0) {\n            \$(form).yiiActiveForm('validateAttribute', \$(input).attr('id'));\n        }\n    });\n\n    return true;\n});\n\n\$('#{$form->id}').on('beforeSubmit', function () {\n    \$(this).find('.btn').attr('disabled', true);\n});");
 public function items()
 {
     $url = 'http://' . $this->model->domain . '/';
     return [['label' => Yii::t('hipanel:hosting', 'Go to site {link}', ['link' => StringHelper::truncate($url, 15)]), 'icon' => 'fa-paper-plane', 'url' => $url, 'encode' => false, 'linkOptions' => ['target' => '_blank']], ['label' => Yii::t('hipanel:hosting', 'Advanced settings'), 'icon' => 'fa-pencil', 'url' => ['/hosting/vhost/advanced-config', 'id' => $this->model->id], 'visible' => !$this->model->isAlias()], ['label' => Yii::t('hipanel:hosting', 'Proxy settings'), 'icon' => 'fa-adjust', 'url' => ['/hosting/vhost/manage-proxy', 'id' => $this->model->id], 'visible' => !$this->model->isAlias()], ['label' => $this->renderView('_block', ['model' => $this->model, 'blockReasons' => $this->blockReasons]), 'encode' => false, 'visible' => Yii::$app->user->can('support') && Yii::$app->user->id !== $this->model->client_id && !$this->model->isAlias()], ['label' => ModalButton::widget(['model' => $this->model, 'scenario' => 'delete', 'button' => ['label' => '<i class="fa fa-fw fa-trash-o"></i> ' . Yii::t('hipanel', 'Delete')], 'modal' => ['header' => Html::tag('h4', Yii::t('hipanel:hosting', 'Confirm domain deleting')), 'headerOptions' => ['class' => 'label-danger'], 'footer' => ['label' => Yii::t('hipanel:hosting', 'Delete domain'), 'data-loading-text' => Yii::t('hipanel', 'Deleting...'), 'class' => 'btn btn-danger']], 'body' => Yii::t('hipanel:hosting', 'Are you sure to delete domain {name}? All files under domain root on the server will stay untouched. You can delete them manually later.', ['name' => $this->model->domain])]), 'encode' => false]];
 }
 public function items()
 {
     return [['label' => Yii::t('hipanel', 'Update'), 'icon' => 'fa-pencil', 'url' => ['@tariff/update', 'id' => $this->model->id]], ['label' => ModalButton::widget(['model' => $this->model->getTariff(), 'scenario' => 'delete', 'button' => ['label' => '<i class="fa fa-fw fa-trash-o"></i>' . Yii::t('hipanel', 'Delete')], 'body' => Yii::t('hipanel:finance:tariff', 'Tariff must be unlinked form all objects before. Are you sure you want to delete tariff {name}?', ['name' => $model->name]), 'modal' => ['header' => Html::tag('h4', Yii::t('hipanel:finance:tariff', 'Confirm tariff deleting')), 'headerOptions' => ['class' => 'label-danger'], 'footer' => ['label' => Yii::t('hipanel:finance:tariff', 'Delete tariff'), 'data-loading-text' => Yii::t('hipanel:finance:tariff', 'Deleting tariff...'), 'class' => 'btn btn-danger']]]), 'encode' => false]];
 }