Your IP : 216.73.216.79


Current Path : /var/www/html/persada/backend/modules/contentStatistics/views/content-statistics/
Upload File :
Current File : /var/www/html/persada/backend/modules/contentStatistics/views/content-statistics/_form.php

<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use mihaildev\ckeditor\CKEditor;
use mihaildev\elfinder\ElFinder;
use backend\modules\contentStatistics\models\ContentStatistics;
use kartik\file\FileInput;
use common\assets\AceEditorAsset;

AceEditorAsset::register($this);

$this->registerJs(
        <<<JS
var textarea = $('#contentstatistics-stats_chart').hide();
var editor = ace.edit('editorContent');
    editor.setOptions({maxLines: Infinity,});
    editor.setTheme("ace/theme/monokai");
    editor.getSession().setMode("ace/mode/php");
    editor.getSession().setValue(textarea.val());
    editor.getSession().on('change', function () {
        textarea.val(editor.getSession().getValue());
    });
JS
);

$this->registerCssFile('@web/plugins/summernote/summernote.min.css');
$this->registerJsFile('@web/plugins/summernote/summernote.min.js', ['depends' => [\yii\web\JqueryAsset::className()]]);
$this->registerJs(
        <<<JS
    $('.summernote').summernote({
		height: 300,
		toolbar: [
			['style', ['style']],
			['font', ['bold', 'italic', 'underline', 'clear']],
			['fontname', ['fontname']],
			['color', ['color']],
			['para', ['ul', 'ol', 'paragraph']],
			['height', ['height']],
			['table', ['table']],
			['insert', ['link', 'picture', 'hr']],
			['view', ['fullscreen', 'codeview']],
			['help', ['help']]
		],
	});
JS
);
$this->registerCss(".note-editor{border:1px solid #e5e6e7 !important}");
?>
<style type="text/css" media="screen">
    .ace_editor  { min-height:300px; z-index:9999; }
    .ace_text-input{  position:absolute!important }
    #editorContent{margin-bottom:2em;}
    .field-contentstatistics-stats_chart{margin:0 !important;}
    .field-contentstatistics-stats_chart .help-block{margin:0 !important;}
    .kv-file-remove, .kv-file-zoom {
        display:none;
    }
</style>
<?php $form = ActiveForm::begin(); ?>
<div class="wrapper wrapper-content animated fadeInRight" style="padding: 20px 10px 20px;">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <div class="col-sm-3">
                    <?=
                    $form->field($model, 'stats_status')->dropdownList(
                            ArrayHelper::map(
                                    (new \yii\db\Query())->select(['code', 'descr'])
                                            ->from('ref')
                                            ->where(['=', 'cat', 'CONTENT_STATUS'])
                                            ->orderBy(['sort' => SORT_ASC])
                                            ->all(), 'code', 'descr'), [
                        'maxlength' => true, 'prompt' => '-- Please Choose --'])
                    ?>
                </div>
                <div class="col-sm-9">
                    <?= $form->field($model, 'stats_code')->textInput(['maxlength' => true, 'placeholder' => 'statistics-piagam-pelanggan']) ?>
                </div>
            </div>
            <?php
            if (!empty($model->stats_img)) {
                echo $form->field($model, 'stats_img')->widget(FileInput::classname(), [
                    'options' => ['accept' => 'image/*'],
                    'pluginOptions' => [
                        'showUpload' => false,
                        'showCaption' => false,
                        'showRemove' => false,
                        'showUpload' => false,
                        'browseClass' => 'btn btn-warning btn-block',
                        'browseIcon' => '<i class="glyphicon glyphicon-camera"></i>&nbsp;&nbsp;',
                        'browseLabel' => 'Select Image',
                        'initialPreview' => ['<img style="max-width:100%" src="' . Yii::getAlias('@web') . '/' . $model->stats_img . '"/>'],
                    ]
                ]);
            } else {
                echo $form->field($model, 'stats_img')->widget(FileInput::classname(), [
                    'options' => ['accept' => 'image/*'],
                    'pluginOptions' => [
                        'showUpload' => false,
                        'showCaption' => false,
                        'showRemove' => false,
                        'showUpload' => false,
                        'browseClass' => 'btn btn-warning btn-block',
                        'browseIcon' => '<i class="glyphicon glyphicon-camera"></i>&nbsp;&nbsp;',
                        'browseLabel' => 'Select Image'
                    ],
                ]);
            }
            ?>
            <div class="row">
                <div class="col-sm-3">
                    <?=
                    $form->field($model, 'stats_language')->dropdownList(
                            ArrayHelper::map(
                                    (new \yii\db\Query())->select(['code', 'descr'])
                                            ->from('ref')
                                            ->where(['=', 'cat', 'CONTENT_LANGUAGE'])
                                            ->orderBy(['sort' => SORT_ASC])
                                            ->all(), 'code', 'descr'), [
                        'maxlength' => true, 'prompt' => '-- Please Choose --'])
                    ?>
                </div>
                <div class="col-sm-9">
                    <?= $form->field($model, 'stats_title')->textInput(['maxlength' => true]) ?>
                </div>
            </div>
            <?= $form->field($model, 'stats_content')->textarea(['class' => 'summernote']) ?>
            <?= $form->field($model, 'stats_chart')->textarea() ?>
            <div id="editorContent"></div>
        </div>
    </div>

    <?php
    $modeltranslation = ContentStatistics::find()
                    ->where(['=', 'stats_parent_id', $model->stats_id])
                    ->andwhere(['=', 'stats_main', '0'])
                    ->orderBy(['stats_id' => SORT_ASC])->all();
    if (!empty($modeltranslation)) {
        foreach ($modeltranslation as $rowtranslation) {
            echo '<div class="ibox float-e-margins" id="old-translation-' . $rowtranslation->stats_id . '">
            <input type="hidden" name="oldtranslation[]" value="' . $rowtranslation->stats_id . '" class="translation_id">
            <div class="ibox-title">
                <button type="button" class="btn btn-primary btn-sm" onclick="deleteoldtranslation(' . $rowtranslation->stats_id . ')">Delete</button>&nbsp;&nbsp;&nbsp;
                Statistics Translation
            </div>
            <div class="ibox-content">
                <div class="row">
                    <div class="col-sm-3">
                        <div class="form-group">
                            <label>Language</label>
                            ' . Html::dropDownList('old_language_' . $rowtranslation->stats_id, $rowtranslation->stats_language, ArrayHelper::map(
                            (new \yii\db\Query())->select(['code', 'descr'])
                                    ->from('ref')
                                    ->where(['=', 'cat', 'CONTENT_LANGUAGE'])
                                    ->orderBy(['sort' => SORT_ASC])
                                    ->all(), 'code', 'descr'), [
                'class' => 'form-control',]) . '
                        </div>
                    </div>
                    <div class="col-sm-9">
                        <div class="form-group">
                            <label>Title</label>
                            <input type="text" class="form-control" name="old_title_' . $rowtranslation->stats_id . '" value="' . $rowtranslation->stats_title . '">
                        </div>
                    </div>
                </div>
                <label>Description</label>
                <textarea class="summernote" name="old_content_' . $rowtranslation->stats_id . '">' . $rowtranslation->stats_content . '</textarea>
            </div>
        </div>';
        }
    }
    ?>

    <div class="form-group">
        <?= Html::a(Yii::t('app', 'Back'), ['index'], ['class' => 'btn btn-primary']) ?>
        <?= Html::submitButton(Yii::t('app', 'Save'), ['class' => 'btn btn-success']) ?>
    </div>
</div>
<?php ActiveForm::end(); ?>

<script>
    function deleteoldtranslation(id) {
        var r = confirm("Are you sure to delete this data?");
        if (r == true) {
            $.ajax({
                url: "deletetranslation?id=" + id,
                method: "GET",
                success: function (response) {
                    $('#old-translation-' + id).remove();
                },
            });
        }
    }
</script>