Your IP : 216.73.216.79


Current Path : /var/www/html/slaas/backend/modules/
Upload File :
Current File : /var/www/html/slaas/backend/modules/update-viva-state.php

<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use backend\modules\participation\models\ParticipationCriteria;
use backend\modules\participation\models\ParticipationCycle;

$this->params['breadcrumbs'][] = ['label' => 'Penunjuk Boleh Ukur (PBU)', 'url' => ['viva-state']];
$this->title = 'PBU VIVA Negeri';
$this->params['breadcrumbs'][] = $this->title;
?>
<?php $form = ActiveForm::begin(); ?>
<div class="wrapper wrapper-content animated fadeInRight" style="padding: 20px 10px 20px;">
    <?php
    $component_arr[1] = 'Kriteria VIVA';
    
    if (!empty($component_arr)) {
        foreach ($component_arr as $componentno => $componentname) {
            echo '<div class="ibox">
                <div class="ibox-content">
                    <div class="row" style="margin-bottom:1em;">
                        <div class="col-sm-12"><button type="button" class="btn btn-primary" onclick="addcriteria(' . $componentno . ')">Tambah Data</button></div>
                    </div>
                    <table class="table table-bordered" id="table-criteria-' . $componentno . '">
                        <thead>
                            <tr>
                                <th style="text-align:center;">Kriteria</th>
                                <th style="text-align:center;">Penunjuk Boleh Ukur (PBU)</th>
                                <th style="text-align:center;" width="20%">Markah Maksimum</th>
                                <th style="text-align:center;" width="10%">Tindakan</th>
                            </tr>
                        </thead>
                        <tbody>';

            $modelCriteria = ParticipationCriteria::find()
                            ->where(['=', 'criteria_cycle_id', $id])
                            ->andwhere(['=', 'criteria_component', $componentno])
                            ->andwhere(['=', 'criteria_type', 'viva'])
                            ->andwhere(['=', 'criteria_level', 'state'])
                            ->orderby(['criteria_sort' => SORT_ASC])->all();
            if (!empty($modelCriteria)) {
                foreach ($modelCriteria as $rowCriteria) {
                    echo '<tr id="update_criteria_row_' . $rowCriteria->criteria_id . '">
                        <td><input type="text" class="form-control" name="update_criteria_parent_' . $rowCriteria->criteria_id . '" value="' . $rowCriteria->criteria_parent . '"></td>
                        <td>
                            <input type="hidden" class="form-control" name="delete_criteria_status_' . $rowCriteria->criteria_id . '" value="0" id="delete_criteria_status_' . $rowCriteria->criteria_id . '">
                            <input type="hidden" value="' . $rowCriteria->criteria_id . '" name="update_criteria_component_id_' . $componentno . '[]">
                            <input type="text" class="form-control" name="update_criteria_label_' . $rowCriteria->criteria_id . '" value="' . $rowCriteria->criteria_label . '">
                        </td>
                        <td><input type="text" class="form-control" name="update_criteria_marks_' . $rowCriteria->criteria_id . '" value="' . $rowCriteria->criteria_marks . '"></td>
                        <td style="text-align:center;"><button class="btn btn-danger" type="button" onclick="deleteupdatecriteria(' . $rowCriteria->criteria_id . ')"><i class="fa fa-trash" aria-hidden="true"></i></button></td>
                    </tr>';
                }
            }

            echo '</tbody>
                    </table>
                </div>
            </div>';
        }
    }
    ?>
    <div class="form-group" style="margin-top:2em;">
        <?= Html::a(Yii::t('app', 'Kembali'), ['viva-state'], ['class' => 'btn btn-primary']) ?>
        <?= Html::submitButton(Yii::t('app', 'Simpan'), ['class' => 'btn btn-primary']) ?>
    </div>
</div>
<?php ActiveForm::end(); ?>
<script>
    var countcriteria = 0;
    function addcriteria(id) {
        var output = '<tr id="new_criteria_row_' + countcriteria + '">\n\
            <td><input type="text" class="form-control" name="new_criteria_parent_' + countcriteria + '"></td>\n\
            <td>\n\
                <input type="hidden" value="' + countcriteria + '" name="criteria_component_id_' + id + '[]">\n\
                <input type="text" class="form-control" name="new_criteria_label_' + countcriteria + '">\n\
            </td>\n\
            <td><input type="text" class="form-control" name="new_criteria_marks_' + countcriteria + '"></td>\n\
            <td style="text-align:center;"><button class="btn btn-danger" type="button" onclick="deletenewcriteria(' + countcriteria + ')"><i class="fa fa-trash" aria-hidden="true"></i></button></td>\n\
        </tr>';
        $('#table-criteria-' + id).append(output);
        countcriteria++;
    }

    function deletenewcriteria(no) {
        $('#new_criteria_row_' + no).remove();
    }

    function deleteupdatecriteria(no) {
        $('#delete_criteria_status_' + no).val(1);
        $('#update_criteria_row_' + no).hide();
    }
</script>