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 static function defaultColumns() { return ['bill' => ['class' => MainColumn::class, 'attribute' => 'bill', 'filterAttribute' => 'bill_like'], 'time' => ['format' => 'html', 'filter' => false, 'contentOptions' => ['class' => 'text-nowrap'], 'value' => function ($model) { list($date, $time) = explode(' ', $model->time, 2); return $time === '00:00:00' ? Yii::$app->formatter->asDate($date) : Yii::$app->formatter->asDateTime($model->time); }], 'sum' => ['class' => CurrencyColumn::class, 'attribute' => 'sum', 'colors' => ['danger' => 'warning'], 'headerOptions' => ['class' => 'text-right'], 'contentOptions' => function ($model) { return ['class' => 'text-right' . ($model->sum > 0 ? ' text-bold' : '')]; }], 'sum_editable' => ['class' => CurrencyColumn::class, 'attribute' => 'sum', 'colors' => ['danger' => 'warning'], 'headerOptions' => ['class' => 'text-right'], 'urlCallback' => function ($model, $key) { return Url::to(['bill/update', 'id' => $model->id]); }, 'contentOptions' => function ($model) { return ['class' => 'text-right' . ($model->sum > 0 ? ' text-bold' : '')]; }], 'balance' => ['class' => CurrencyColumn::class, 'headerOptions' => ['class' => 'text-right'], 'contentOptions' => function ($model, $key, $index) { return ['class' => 'text-right' . ($index ? '' : ' text-bold')]; }], 'gtype' => ['attribute' => 'gtype'], 'type_label' => ['class' => RefColumn::class, 'i18nDictionary' => 'hipanel:finance', 'format' => 'raw', 'gtype' => Yii::$app->user->can('support') ? 'type,bill' : 'type,bill,deposit', 'filterAttribute' => 'gtype', 'headerOptions' => ['class' => 'text-right'], 'filterOptions' => ['class' => 'text-right'], 'contentOptions' => function ($model) { return ['class' => 'text-right']; }, 'value' => function ($model) { static $colors = ['correction' => 'normal', 'exchange' => 'warning', 'deposit' => 'success']; $color = $colors[$model->gtype] ?: 'muted'; return Html::tag('b', Yii::t('hipanel:finance', $model->type_label), ['class' => "text-{$color}"]); }], 'description' => ['attribute' => 'descr', 'format' => 'raw', 'value' => function ($model) { $descr = $model->descr ?: $model->label; $text = mb_strlen($descr) > 70 ? ArraySpoiler::widget(['data' => $descr]) : $descr; $tariff = $model->tariff ? Html::tag('span', Yii::t('hipanel', 'Tariff') . ': ' . Html::a($model->tariff, ['@tariff/view', 'id' => $model->tariff_id]), ['class' => 'pull-right']) : ''; $amount = static::billQuantity($model); $object = $model->object ? implode(': ', [$model->class_label, static::objectLink($model)]) : ''; return $tariff . $amount . ' ' . implode('<br>', array_filter([$object, $text])); }], 'tariff' => ['attribute' => 'tariff']]; }
public static function defaultColumns() { return ['ip' => ['class' => MainColumn::class, 'filterAttribute' => 'ip_like'], 'tags' => ['format' => 'raw', 'attribute' => 'tag', 'header' => Yii::t('hipanel:hosting', 'Tags'), 'visible' => Yii::$app->user->can('admin'), 'filter' => function ($column, $model) { return Html::activeDropDownList($model, 'tag_in', array_merge(['' => Yii::t('hipanel', '---')], static::$ipTags), ['class' => 'form-control']); }, 'value' => function ($model) { $labels = []; foreach ($model->tags as $tag) { $labels[] = IpTag::widget(['tag' => $tag]); } return implode(' ', $labels); }], 'counters' => ['format' => 'html', 'header' => Yii::t('hipanel:hosting', 'Counters'), 'value' => function ($model) { $html = ''; foreach ($model->objects_count as $count) { if ($count['type'] === 'hdomain') { $url['ok'] = ['@hdomain', (new HdomainSearch())->formName() => ['ip_like' => $model->ip]]; $url['deleted'] = ['@hdomain', (new HdomainSearch())->formName() => ['ip_like' => $model->ip, 'state' => 'deleted']]; $type = function ($count) { return Yii::t('hipanel:hosting', '{0, plural, one{domain} other{domains}}', (int) $count); }; } else { throw new InvalidParamException('The object type is not supported', $model); } if ($count['ok']) { $html .= Html::a((int) $count['ok'] . ' ' . FontIcon::i('fa-check') . ' ' . $type($count['ok']), $url['ok'], ['class' => 'btn btn-success btn-xs']); } $html .= ' '; if ($count['deleted'] > 0) { $html .= Html::a((int) $count['deleted'] . ' ' . FontIcon::i('fa-trash') . ' ' . $type($count['deleted']), $url['deleted'], ['class' => 'btn btn-xs btn-warning']); } } return $html; }], 'links' => ['format' => 'html', 'value' => function ($model) { $items = []; foreach ($model->links as $link) { $item = Html::a($link->device, ['@server/view', 'id' => $link->device_id]); if ($link->service_id) { $item .= ' ' . FontIcon::i('fa-long-arrow-right'); $item .= ' ' . Html::a($link->service ?: $link->soft, ['@service/view', 'id' => $link->service_id]); } $items[] = $item; } return ArraySpoiler::widget(['data' => $items, 'visibleCount' => 3]); }], 'services' => ['attribute' => 'links', 'format' => 'html', 'label' => Yii::t('hipanel:server', 'Services'), 'value' => function ($model) { return ArraySpoiler::widget(['data' => $model->links, 'formatter' => function ($link) { if (Yii::$app->user->can('support') && Yii::getAlias('@service', false)) { return Html::a($link->service, ['@service/view', 'id' => $link->service_id]); } return $link->service; }]); }], 'actions' => ['class' => MenuColumn::class, 'menuClass' => IpActionsMenu::class], 'ptr' => ['options' => ['style' => 'width: 40%'], 'format' => 'raw', 'value' => function ($model) { if ($model->canSetPtr()) { return XEditable::widget(['model' => $model, 'attribute' => 'ptr', 'pluginOptions' => ['url' => Url::to('@ip/set-ptr')]]); } return null; }]]; }
public function actions() { return ['set-orientation' => ['class' => OrientationAction::class, 'allowedRoutes' => ['@client/index']], 'index' => ['class' => IndexAction::class, 'on beforePerform' => function ($event) { if (!Yii::$app->user->can('support')) { Yii::$app->response->redirect(Url::to(['@client/view', 'id' => Yii::$app->user->id]))->send(); } }, 'data' => function ($action) { return ['types' => $this->getRefs('type,client', 'hipanel:client'), 'states' => $this->getRefs('state,client', 'hipanel:client')]; }, 'filterStorageMap' => ['login_like' => 'client.client.login_like', 'state' => 'client.client.state', 'type' => 'client.client.type', 'seller' => 'client.client.seller']], 'search' => ['class' => SearchAction::class], 'create' => ['class' => SmartCreateAction::class, 'success' => Yii::t('hipanel:client', 'Client was created')], 'update' => ['class' => SmartUpdateAction::class, 'success' => Yii::t('hipanel:client', 'Client was updated')], 'delete' => ['class' => SmartDeleteAction::class, 'success' => Yii::t('hipanel:client', 'Client was deleted')], 'enable-block' => ['class' => SmartPerformAction::class, 'success' => 'Client was blocked successfully', 'error' => 'Error during the client account blocking'], 'disable-block' => ['class' => SmartPerformAction::class, 'success' => 'Client was unblocked successfully', 'error' => 'Error during the client account unblocking'], 'change-password' => ['class' => SmartUpdateAction::class, 'view' => '_changePasswordModal', 'POST' => ['save' => true, 'success' => ['class' => RenderJsonAction::class, 'return' => function ($action) { return ['success' => !$action->collection->hasErrors()]; }]]], 'set-tmp-password' => ['class' => SmartUpdateAction::class, 'view' => '_setTmpPasswordModal', 'success' => Yii::t('hipanel:client', 'Temporary password was sent on your email'), 'error' => Yii::t('hipanel:client', 'Error during temporary password setting')], 'view' => ['class' => ViewAction::class, 'on beforePerform' => function ($event) { $action = $event->sender; $action->getDataProvider()->query->addSelect(array_filter(['last_seen', 'contacts_count', Yii::getAlias('@domain', false) ? 'domains_count' : null, Yii::getAlias('@ticket', false) ? 'tickets_count' : null, Yii::getAlias('@server', false) ? 'servers_count' : null, Yii::getAlias('@hosting', false) ? 'hosting_count' : null]))->joinWith('contact')->joinWith(['purses' => function ($query) { $query->joinWith('contact')->joinWith('requisite')->joinWith('files'); }]); }], 'validate-form' => ['class' => ValidateFormAction::class], 'set-credit' => ['class' => SmartUpdateAction::class, 'success' => Yii::t('hipanel:client', 'Credit changed')], 'set-note' => ['class' => SmartUpdateAction::class, 'success' => Yii::t('hipanel:client', 'Note changed'), 'error' => Yii::t('hipanel:client', 'Failed to change note')], 'bulk-enable-block' => ['class' => SmartUpdateAction::class, 'scenario' => 'enable-block', 'success' => Yii::t('hipanel:client', 'Clients were blocked successfully'), 'error' => Yii::t('hipanel:client', 'Error during the clients blocking'), 'POST html' => ['save' => true, 'success' => ['class' => RedirectAction::class]], 'on beforeSave' => function (Event $event) { /** @var \hipanel\actions\Action $action */ $action = $event->sender; $type = Yii::$app->request->post('type'); $comment = Yii::$app->request->post('comment'); if (!empty($type)) { foreach ($action->collection->models as $model) { $model->setAttributes(['type' => $type, 'comment' => $comment]); } } }], 'bulk-enable-block-modal' => ['class' => PrepareBulkAction::class, 'scenario' => 'enable-block', 'view' => '_bulkEnableBlock', 'data' => function ($action, $data) { return array_merge($data, ['blockReasons' => $this->getBlockReasons()]); }], 'bulk-disable-block' => ['class' => SmartUpdateAction::class, 'scenario' => 'disable-block', 'success' => Yii::t('hipanel:client', 'Clients were unblocked successfully'), 'error' => Yii::t('hipanel:client', 'Error during the clients unblocking'), 'POST html' => ['save' => true, 'success' => ['class' => RedirectAction::class]], 'on beforeSave' => function (Event $event) { /** @var \hipanel\actions\Action $action */ $action = $event->sender; $comment = Yii::$app->request->post('comment'); if (!empty($type)) { foreach ($action->collection->models as $model) { $model->setAttribute('comment', $comment); } } }], 'bulk-disable-block-modal' => ['class' => PrepareBulkAction::class, 'scenario' => 'disable-block', 'view' => '_bulkDisableBlock'], 'ip-restrictions' => ['class' => ClassValuesAction::class, 'valuesClass' => 'client,access', 'view' => '_ipRestrictionsModal'], 'domain-settings' => ['class' => ClassValuesAction::class, 'valuesClass' => 'client,domain_defaults', 'view' => '_domainSettingsModal', 'on beforePerform' => function (Event $event) { $action = $event->sender; foreach (['registrant', 'admin', 'billing', 'tech'] as $key) { if (!$action->model->{$key}) { unset($action->model->{$key}); } } }], 'mailing-settings' => ['class' => ClassValuesAction::class, 'valuesClass' => 'client,mailing', 'view' => '_mailingSettingsModal'], 'ticket-settings' => ['class' => ClassValuesAction::class, 'valuesClass' => 'client,ticket_settings', 'view' => '_ticketSettingsModal'], 'pincode-settings' => ['class' => SmartUpdateAction::class, 'view' => '_pincodeSettingsModal', 'on beforeFetch' => function ($event) { /** @var \hipanel\actions\SearchAction $action */ $action = $event->sender; $dataProvider = $action->getDataProvider(); $dataProvider->query->addSelect('pincode_enabled'); }, 'data' => function ($action, $data) { $apiData = $this->getRefs('type,question', 'hipanel:client'); $questionList = array_merge(Client::makeTranslateQuestionList($apiData), ['own' => Yii::t('hipanel:client', 'Own question')]); return array_merge(['questionList' => $questionList], $data); }]]; }
public static function defaultColumns() { return ['hdomain' => ['class' => MainColumn::class, 'filterAttribute' => 'domain_like', 'attribute' => 'domain'], 'hdomain_with_aliases' => ['format' => 'raw', 'attribute' => 'domain', 'filterAttribute' => 'domain_like', 'value' => function ($model) { $aliases = (array) $model->getAttribute('aliases'); $html = Html::a($model->domain, ['view', 'id' => $model->id], ['class' => 'bold']) . ' '; $html .= ArraySpoiler::widget(['data' => $aliases, 'visibleCount' => 0, 'delimiter' => '<br />', 'button' => ['label' => Yii::t('hipanel', '+{0, plural, one{# alias} other{# aliases}}', count($aliases)), 'class' => 'badge progress-bar-info', 'popoverOptions' => ['html' => true]], 'formatter' => function ($value, $key) { return Html::a($value, ['view', 'id' => $key]); }]); return $html; }], 'account' => ['class' => AccountColumn::class], 'server' => ['class' => ServerColumn::class], 'ip' => ['enableSorting' => false, 'filter' => false, 'format' => 'raw', 'value' => function ($model) { $vhost = $model->getAttribute('vhost'); $html = $vhost['ip']; if (isset($vhost['port']) && $vhost['port'] !== 80) { $html .= ':' . $vhost['port']; } if ($model->isProxied) { $backend = $vhost['backend']; $html .= ' ' . Html::tag('i', '', ['class' => 'fa fa-long-arrow-right']) . ' ' . $backend['ip']; if ($backend['port'] !== 80) { $html .= ':' . $backend['port']; } } return $html; }], 'service' => ['label' => Yii::t('hipanel', 'Service'), 'value' => function ($model) { return $model->getAttribute('vhost')['service']; }], 'state' => ['class' => RefColumn::class, 'i18nDictionary' => 'hipanel:hosting', 'format' => 'raw', 'value' => function ($model) { $html = ''; if ($model->dns_on && empty($model->dns_hdomain_id)) { $html .= Label::widget(['color' => 'success', 'label' => Yii::t('hipanel', 'DNS'), 'tag' => 'span', 'labelOptions' => ['title' => Yii::t('hipanel:hosting', 'DNS is enabled')]]); } $html .= ' ' . State::widget(compact('model')); return $html; }, 'gtype' => 'state,hdomain'], 'dns_on' => ['format' => 'raw', 'value' => function ($model) { return $model->dns_on ? Yii::t('hipanel', 'Enabled') : Yii::t('hipanel', 'Disabled'); }], 'dns_switch' => ['attribute' => 'dns_on', 'label' => Yii::t('hipanel:hosting', 'DNS'), 'format' => 'raw', 'value' => function ($model) { if (empty($model->dns_hdomain_id)) { return XEditable::widget(['model' => $model, 'attribute' => 'dns_on', 'pluginOptions' => ['type' => 'select', 'title' => Yii::t('hipanel:hosting', 'Toggles DNS records upload on NS server'), 'source' => ['' => Yii::t('hipanel', 'Disabled'), '1' => Yii::t('hipanel', 'Enabled')], 'url' => Url::to('set-dns-on'), 'placement' => 'bottom'], 'linkOptions' => ['style' => ['word-break' => 'break-all']]]); } else { return Yii::t('hipanel:hosting', 'Belongs to {link}', ['link' => Html::a($model->dns_hdomain_domain, Url::to(['@hdomain/view', 'id' => $model->dns_hdomain_id]))]); } }], 'aliases' => ['label' => Yii::t('hipanel', 'Aliases'), 'format' => 'raw', 'value' => function ($model) { return ArraySpoiler::widget(['data' => (array) $model->getAttribute('aliases'), 'delimiter' => '<br />', 'button' => ['popoverOptions' => ['html' => true]]]); }], 'backups_widget' => ['label' => Yii::t('hipanel:hosting', 'Backups'), 'format' => 'raw', 'value' => function ($model) { return BackupGridRow::widget(['model' => $model]); }], 'actions' => ['class' => ActionColumn::class, 'template' => '{view} {delete}']]; }
public static function defaultColumns() { $typeOptions = self::$typeOptions; return ['name' => ['class' => MainColumn::class, 'filterAttribute' => 'name_like', 'format' => 'html', 'value' => function ($model) { return Html::a($model->name, ['@' . $model->object . '/view', 'id' => $model->id], ['class' => 'bold']); }], 'main' => ['attribute' => 'name', 'filterAttribute' => 'name_like', 'format' => 'raw', 'value' => function ($model) { return Html::a($model->name, ['@backuping/view', 'id' => $model->id], ['class' => 'bold']) . ' ' . Html::a(ObjectLabelWidget::widget(compact('model')), ['@' . $model->object . '/view', 'id' => $model->id]); }], 'account' => ['attribute' => 'account_id', 'class' => AccountColumn::class], 'server' => ['attribute' => 'server_id', 'class' => ServerColumn::class], 'object' => ['filter' => false, 'format' => 'raw', 'value' => function ($model) { return ObjectLabelWidget::widget(compact('model')); }], 'backup_count' => ['filter' => false], 'type' => ['attribute' => 'type', 'format' => 'raw', 'filter' => false, 'enableSorting' => false, 'value' => function ($model) use($typeOptions) { return XEditable::widget(['model' => $model, 'attribute' => 'type', 'pluginOptions' => ['type' => 'select', 'source' => $typeOptions, 'url' => Url::to('update')]]); }], 'state_label' => ['filter' => false, 'enableSorting' => false], 'backup_last' => ['filter' => false, 'format' => 'raw', 'value' => function ($model) { return Html::tag('nobr', Yii::$app->formatter->asDate($model->backup_last)) . ' ' . Html::tag('nobr', Yii::$app->formatter->asTime($model->backup_last)); }], 'total_du' => ['filter' => false, 'format' => 'html', 'value' => function ($model) { return Yii::$app->formatter->asShortSize($model->total_du, 2); }]]; }
<div class="alert alert-warning alert-dismissible fade in" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> <strong><?php echo Yii::t('hipanel/domainchecker', 'There are no available domain zones'); ?> !</strong> </div> <?php } ?> <div class="box box-solid"> <!-- /.box-header --> <div class="box-body"> <?php $form = ActiveForm::begin(['id' => 'check-domain', 'action' => Url::to(['@domainchecker/check-domain']), 'method' => 'get', 'options' => ['data-pjax' => false], 'fieldConfig' => ['template' => "{beginWrapper}\n{input}\n{hint}\n{error}\n{endWrapper}"]]); ?> <div class="row"> <div class="col-md-6"> <div class="form-group"> <?php echo $form->field($model, 'domain')->textInput(['placeholder' => Yii::t('hipanel/domainchecker', 'Domain name'), 'class' => 'form-control input-lg', 'name' => 'domain']); ?> </div> </div> <!-- /.col-md-8 --> <div class="col-md-4"> <div class="form-group"> <?php echo $form->field($model, 'zone')->widget(StaticCombo::classname(), ['data' => $dropDownZonesOptions, 'hasId' => true, 'inputOptions' => ['value' => $model->zone !== null ? $model->zone : $model::DEFAULT_ZONE, 'class' => 'form-control input-lg', 'name' => 'zone']]); ?>
/** * @var View */ use hipanel\helpers\Url; use yii\web\View; $this->title = Yii::t('merchant', 'Payment result'); ?> <h1 class="text-center"> <i class="fa fa-refresh fa-spin"></i> <?php echo Yii::t('merchant', 'Waiting for confirmation from the payment system...'); ?> </h1> <?php $options = \yii\helpers\Json::encode(['url' => Url::to('check-return'), 'data' => ['transactionId' => $transactionId]]); $this->registerJs(<<<JS function checkPaymentStatus(options) { \$.ajax({ type: 'get', dataType: 'json', url: options.url, data: options.data, success: function (result) { if (result.status !== null) { window.location = result.url; } else { setTimeout(function() { checkPaymentStatus(options); }, 1000); }
?> <?php if ($model->isRelationPopulated('answers')) { ?> <hr class="no-panel-padding-h panel-wide padding-bottom"> <div class="widget-article-comments tab-pane panel no-padding no-border fade in active"> <?php echo $this->render('_comments', ['model' => $model, 'client' => $client]); ?> </div> <?php if ($model->isRelationPopulated('answers')) { ?> <hr class="no-panel-padding-h panel-wide padding-bottom md-mb-0"> <?php echo Html::button(Yii::t('hipanel:ticket', 'Answer'), ['class' => 'message-block-move-btn btn btn-default']); ?> <?php } ?> <?php } ?> <?php $actionUrl = Json::encode(Url::to(['update-answer-modal'])); echo AjaxModal::widget(['id' => 'update-answer-modal', 'header' => Html::tag('h4', Yii::t('hipanel:ticket', 'Message editing'), ['class' => 'modal-title']), 'scenario' => 'update-answer', 'actionUrl' => ['update-answer-modal'], 'size' => Modal::SIZE_LARGE, 'toggleButton' => false, 'clientEvents' => ['show.bs.modal' => new JsExpression("function(e) {\n var button = e.relatedTarget;\n var id = \$(button).attr('data-thread-id');\n var answer_id = \$(button).attr('data-answer-id');\n \$.ajax({\n url: {$actionUrl},\n data: {id: id, answer_id: answer_id},\n success: function (data) {\n \$('#update-answer-modal .modal-body').html(data);\n }\n });\n }")]]); ?> <?php $box->end();
public static function resolveConfig() { return Yii::$app->user->can('manage') ? ['class' => XEditableColumn::class, 'filter' => false, 'contentOptions' => ['class' => 'text-right'], 'widgetOptions' => ['class' => RemoteFormatXEditable::class, 'linkOptions' => ['data-currency' => 'usd']], 'pluginOptions' => ['url' => '@client/set-credit', 'title' => Yii::t('hipanel:finance', 'Set credit'), 'ajaxUrl' => Url::to('/format/currency'), 'data-display-value' => function ($column, $options) { return Yii::$app->formatter->format(array_shift($column->pluginOptions['value']), ['currency', 'USD']); }, 'ajaxDataOptions' => ['currency' => 'currency']]] : ['class' => CurrencyColumn::class, 'contentOptions' => ['class' => 'text-right']]; }
<?php use hipanel\helpers\Url; use hipanel\modules\stock\widgets\combo\ModelProfileCombo; use hipanel\modules\stock\widgets\combo\UsertagCombo; use hipanel\widgets\Box; use hipanel\widgets\DynamicFormWidget; use hiqdev\combo\StaticCombo; use yii\bootstrap\ActiveForm; use yii\helpers\Html; use yii\web\JsExpression; use yii\web\View; if (reset($models)->isNewRecord) { $dynamicUrl = Url::to('@model/subform'); $this->registerJs(<<<JS // Ajax form by type jQuery( document ).on('change', 'input.type-element', function(event) { var anchorItem = jQuery(this).closest('.item'); var subFornName = jQuery(this).val(); var itemNumber = jQuery(this).attr('id').charAt(6); var loadingHtml = '<div class="overlay"><i class="fa fa-refresh fa-spin"></i></div>'; anchorItem.find('.l-box').append(loadingHtml); anchorItem.find( ".my-dynamic-content" ).load( '{$dynamicUrl}', {'subFormName': subFornName, 'itemNumber': itemNumber}, function (response, status, xhr) { anchorItem.find('.overlay').remove(); if ( status == "error" ) { var msg = "Sorry but there was an error"; console.log(msg); } }); }); JS
public static function defaultColumns() { return ['id' => ['class' => ClientColumn::class, 'attribute' => 'id', 'nameAttribute' => 'login', 'label' => Yii::t('hipanel', 'Client')], 'login' => ['class' => MainColumn::class, 'attribute' => 'login', 'filterAttribute' => 'login_like', 'format' => 'raw', 'note' => Yii::$app->user->can('manage') ? 'note' : null, 'noteOptions' => ['url' => Url::to('set-note')]], 'note' => ['class' => XEditableColumn::class, 'pluginOptions' => ['url' => Url::to('set-note')], 'widgetOptions' => ['linkOptions' => ['data-type' => 'textarea']], 'visible' => Yii::$app->user->can('manage')], 'name' => ['filterAttribute' => 'name_like'], 'state' => ['class' => RefColumn::class, 'filterAttribute' => 'states', 'format' => 'raw', 'gtype' => 'state,client', 'i18nDictionary' => 'hipanel:client', 'value' => function ($model) { return ClientState::widget(compact('model')); }], 'type' => ['class' => RefColumn::class, 'filterAttribute' => 'types', 'format' => 'raw', 'gtype' => 'type,client', 'i18nDictionary' => 'hipanel:client', 'value' => function ($model) { return ClientType::widget(compact('model')); }], 'balance' => ['class' => BalanceColumn::class], 'credit' => CreditColumn::resolveConfig(), 'country' => ['attribute' => 'contact', 'label' => Yii::t('hipanel:client', 'Country'), 'format' => 'html', 'value' => function ($model) { return Html::tag('span', '', ['class' => 'flag-icon flag-icon-' . $model->contact['country']]) . ' ' . $model->contact['country_name']; }], 'create_date' => ['attribute' => 'create_time', 'format' => 'date', 'filter' => false, 'contentOptions' => ['class' => 'text-nowrap']], 'create_time' => ['attribute' => 'create_time', 'format' => 'datetime', 'filter' => false], 'update_date' => ['attribute' => 'update_time', 'format' => 'date', 'filter' => false, 'contentOptions' => ['class' => 'text-nowrap']], 'update_time' => ['attribute' => 'update_time', 'format' => 'datetime', 'filter' => false], 'last_seen' => ['attribute' => 'last_seen', 'format' => 'date', 'filter' => false, 'contentOptions' => ['class' => 'text-nowrap'], 'value' => ''], 'tickets' => ['format' => 'html', 'label' => Yii::t('hipanel', 'Tickets'), 'value' => function ($model) { $num = $model->count['tickets']; $url = Url::toSearch('ticket', ['client_id' => $model->id]); return $num ? Html::a(Yii::t('hipanel', '{0, plural, one{# ticket} other{# tickets}}', $num), $url) : ''; }], 'servers' => ['format' => 'raw', 'visible' => Yii::getAlias('@server', false) !== false, 'label' => Yii::t('hipanel', 'Servers'), 'value' => function ($model) { /** @var Client $model */ $num = $model->count['servers']; $url = Url::toSearch('server', ['client_id' => $model->id]); return $num ? Html::a(Yii::t('hipanel', '{0, plural, one{# server} other{# servers}}', $num), $url) : ''; }], 'domains' => ['format' => 'html', 'visible' => Yii::getAlias('@domain', false) !== false, 'label' => Yii::t('hipanel', 'Domains'), 'value' => function ($model) { /** @var Client $model */ $num = $model->count['domains']; $url = Url::toSearch('domain', ['client_id' => $model->id]); return $num ? Html::a(Yii::t('hipanel', '{0, plural, one{# domain} other{# domains}}', $num), $url) : ''; }], 'domains_spoiler' => ['format' => 'raw', 'visible' => Yii::getAlias('@domain', false) !== false, 'label' => Yii::t('hipanel', 'Domains'), 'value' => function ($model) { /** @var Client $model */ return ArraySpoiler::widget(['data' => $model->domains, 'visibleCount' => 1, 'button' => ['label' => '+' . ($model->count['domains'] - 1), 'popoverOptions' => ['html' => true]], 'formatter' => function ($item, $key) use($model) { static $index = 0; ++$index; $value = Html::a($item->domain, ['@domain/view', 'id' => $item->id]); if ($model->count['domains'] > count($model->domains) && $index === count($model->domains)) { $text = Yii::t('hipanel:client', 'and {n} more', ['n' => $model->count['domains'] - count($model->domains)]); $value .= ' ' . Html::a($text, Url::toSearch('domain', ['client_id' => $model->id]), ['class' => 'border-bottom-dashed']); } return $value; }]); }], 'servers_spoiler' => ['format' => 'raw', 'label' => Yii::t('hipanel', 'Servers'), 'value' => function ($model) { return ArraySpoiler::widget(['data' => $model->servers, 'visibleCount' => 1, 'button' => ['label' => '+' . ($model->count['servers'] - 1), 'popoverOptions' => ['html' => true]], 'formatter' => function ($item, $key) use($model) { static $index; ++$index; $value = Html::a($item->name, ['@server/view', 'id' => $item->id]); if ($model->count['servers'] > count($model->servers) && $index === count($model->servers)) { $text = Yii::t('hipanel:client', 'and {n} more', ['n' => $model->count['servers'] - count($model->servers)]); $value .= ' ' . Html::a($text, Url::toSearch('server', ['client_id' => $model->id]), ['class' => 'border-bottom-dashed']); } return $value; }]); }], 'contacts' => ['format' => 'html', 'label' => Yii::t('hipanel', 'Contacts'), 'value' => function ($model) { $num = $model->count['contacts']; $url = Url::toSearch('contact', ['client_id' => $model->id]); return $num ? Html::a(Yii::t('hipanel', '{0, plural, one{# contact} other{# contacts}}', $num), $url) : ''; }], 'hosting' => ['format' => 'html', 'label' => Yii::t('hipanel', 'Hosting'), 'value' => function ($model) { $res = ''; $num = $model->count['accounts']; $url = Url::toSearch('account', ['client_id' => $model->id]); $res .= $num ? Html::a(Yii::t('hipanel', '{0, plural, one{# account} other{# accounts}}', $num), $url) : ''; $num = $model->count['hdomains']; $url = Url::toSearch('hdomain', ['client_id' => $model->id]); $res .= $num ? Html::a(Yii::t('hipanel', '{0, plural, one{# domain} other{# domains}}', $num), $url) : ''; $num = $model->count['dbs']; $url = Url::toSearch('db', ['client_id' => $model->id]); $res .= $num ? Html::a(Yii::t('hipanel', '{0, plural, one{# database} other{# databases}}', $num), $url) : ''; return $res; }], 'actions' => ['class' => MenuColumn::class, 'menuClass' => ClientActionsMenu::class]]; }
public static function defaultColumns() { $osImages = self::$osImages; return ['server' => ['class' => MainColumn::class, 'attribute' => 'name', 'filterAttribute' => 'name_like', 'note' => Yii::$app->user->can('support') ? 'label' : 'note', 'noteOptions' => ['url' => Yii::$app->user->can('support') ? Url::to('set-label') : Url::to('set-note')], 'badges' => function ($model) { $badges = ''; if (Yii::$app->user->can('support')) { if ($model->wizzarded) { $badges .= Label::widget(['label' => 'W', 'tag' => 'sup', 'color' => 'success']); } /*if ($model->state === 'disabled') { $badges .= ' ' . Label::widget(['label' => 'Panel OFF', 'tag' => 'sup', 'color' => 'danger', 'type' => 'text']); }*/ } return $badges; }], 'dc' => ['attribute' => 'dc', 'filter' => false], 'state' => ['class' => RefColumn::class, 'i18nDictionary' => 'hipanel:server', 'format' => 'raw', 'gtype' => 'state,device', 'value' => function ($model) { $html = State::widget(compact('model')); if ($model->status_time) { $html .= ' ' . Html::tag('nobr', Yii::t('hipanel:server', 'since {date}', ['date' => Yii::$app->formatter->asDate($model->status_time)])); } return $html; }], 'panel' => ['attribute' => 'panel', 'format' => 'text', 'contentOptions' => ['class' => 'text-uppercase'], 'value' => function ($model) { return $model->panel ? Yii::t('hipanel:server:panel', $model->panel) : Yii::t('hipanel:server:panel', 'No control panel'); }], 'os' => ['attribute' => 'os', 'format' => 'raw', 'value' => function ($model) use($osImages) { return OSFormatter::widget(['osimages' => $osImages, 'imageName' => $model->osimage]); }], 'os_and_panel' => ['attribute' => 'os', 'format' => 'raw', 'value' => function ($model) use($osImages) { $html = OSFormatter::widget(['osimages' => $osImages, 'imageName' => $model->osimage]); $html .= ' ' . $model->panel ?: ''; return $html; }], 'discount' => ['attribute' => 'discount', 'label' => Yii::t('hipanel:server', 'Discount'), 'format' => 'raw', 'headerOptions' => ['style' => 'width: 1em'], 'value' => function ($model) { return DiscountFormatter::widget(['current' => $model->discounts['fee']['current'], 'next' => $model->discounts['fee']['next']]); }], 'expires' => ['filter' => false, 'format' => 'raw', 'headerOptions' => ['style' => 'width: 1em'], 'value' => function ($model) { return Expires::widget(compact('model')); }], 'tariff' => ['format' => 'raw', 'filterAttribute' => 'tariff_like', 'value' => function ($model) { return self::formatTariff($model); }], 'tariff_and_discount' => ['attribute' => 'tariff', 'filterAttribute' => 'tariff_like', 'format' => 'raw', 'value' => function ($model) { return self::formatTariff($model) . ' ' . DiscountFormatter::widget(['current' => $model->discounts['fee']['current'], 'next' => $model->discounts['fee']['next']]); }], 'ip' => ['filter' => false], 'mac' => ['filter' => false], 'ips' => ['format' => 'raw', 'attribute' => 'ips', 'filter' => false, 'value' => function ($model) { return ArraySpoiler::widget(['data' => ArrayHelper::getColumn($model->ips, 'ip'), 'delimiter' => '<br />', 'visibleCount' => 3, 'button' => ['popoverOptions' => ['html' => true]]]); }], 'sale_time' => ['attribute' => 'sale_time', 'format' => 'datetime'], 'note' => ['class' => XEditableColumn::class, 'pluginOptions' => ['url' => Url::to('set-note')], 'widgetOptions' => ['linkOptions' => ['data-type' => 'textarea']]], 'label' => ['class' => XEditableColumn::class, 'visible' => Yii::$app->user->can('support'), 'pluginOptions' => ['url' => Url::to('set-label')], 'widgetOptions' => ['linkOptions' => ['data-type' => 'textarea']]], 'type' => ['format' => 'html', 'filter' => false, 'value' => function ($model) { return $model->type_label; }], 'rack' => ['format' => 'html', 'filter' => false, 'value' => function ($model) { return $model->switches['rack']['switch']; }], 'net' => ['format' => 'html', 'filter' => false, 'value' => function ($model) { return static::renderSwitchPort($model->switches['net']); }], 'kvm' => ['format' => 'html', 'filter' => false, 'value' => function ($model) { return static::renderSwitchPort($model->switches['kvm']); }], 'pdu' => ['format' => 'html', 'filter' => false, 'value' => function ($model) { return static::renderSwitchPort($model->switches['pdu']); }], 'ipmi' => ['format' => 'raw', 'filter' => false, 'value' => function ($model) { $ipmi = $model->switches['ipmi']['device_ip']; $link = $ipmi ? Html::a($ipmi, "http://{$ipmi}/", ['target' => '_blank']) . ' ' : ''; return $link . static::renderSwitchPort($model->switches['ipmi']); }], 'nums' => ['label' => '', 'format' => 'raw', 'value' => function ($model) { $ips_num = $model->ips_num; $ips = $ips_num ? Html::a("{$ips_num} ips", IpController::getSearchUrl(['server' => $model->name])) : 'no ips'; $act_acs_num = $model->acs_num - $model->del_acs_num; $del_acs_num = $model->del_acs_num; $acs_num = $act_acs_num . ($del_acs_num ? "+{$del_acs_num}" : ''); $acs = $acs_num ? Html::a("{$acs_num} acc", AccountController::getSearchUrl(['server' => $model->name])) : 'no acc'; return Html::tag('nobr', $ips) . ' ' . Html::tag('nobr', $acs); }], 'actions' => ['class' => ActionColumn::class, 'template' => '{view} {rrd} {switch-graph}', 'buttons' => ['switch-graph' => function ($url, $model) { return Html::a('<i class="fa fa-fw fa-area-chart"></i>' . Yii::t('hipanel:server', 'Switch graphs'), ['@switch-graph/view', 'id' => $model->id]); }, 'rrd' => function ($url, $model) { return Html::a('<i class="fa fa-fw fa-signal"></i>' . Yii::t('hipanel:server', 'Resources usage graphs'), ['@rrd/view', 'id' => $model->id]); }]]]; }