Your IP : 216.73.216.79


Current Path : /var/www/html/project/views/phase/
Upload File :
Current File : /var/www/html/project/views/phase/index.php

<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\ActiveForm;
use app\models\Step;
use app\models\ParamList;

/* @var $this yii\web\View */
/* @var $searchModel app\models\PhaseSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Phases';
$this->params['breadcrumbs'][] = $this->title;
$this->registerJs("");
$ParamList = new ParamList();
?>
<?php $form = ActiveForm::begin(['action' => ['index'], 'method' => 'get', 'options' => ['class' => 'form-inline form-search']]); ?>
<?php ActiveForm::end(); ?>
<div class="kt-subheader   kt-grid__item" id="kt_subheader">
    <div class="kt-container ">
        <div class="kt-subheader__main">
            <h3 class="kt-subheader__title">Manage Workflow</h3>
            <div class="kt-subheader__breadcrumbs">
                <span class="kt-subheader__breadcrumbs-separator"></span>
                <span class="kt-subheader__breadcrumbs-link">Settings </span>
                <span class="kt-subheader__breadcrumbs-separator"></span>
                <span class="kt-subheader__breadcrumbs-link"> Manage Workflow</span>
                <span class="kt-subheader__breadcrumbs-separator"></span>
                <span class="kt-subheader__breadcrumbs-link"> Workflow List</span>
            </div>
        </div>
        <div class="kt-subheader__toolbar">
            <div class="kt-subheader__wrapper">
                <a href="index.php?r=templates/index" class="btn btn-warning kt-subheader__btn-options">
                    <i class="fa fa-arrow-left"></i> Back to Template
                </a>
                <a href="index.php?r=phase/create&template_id=<?= $template_id ?>" class="btn btn-danger kt-subheader__btn-options">
                    <i class="fas fa-plus"></i> Add Phase
                </a>
            </div>
        </div>
    </div>
</div>
<div class="phase-index">
    <div class="kt-container  kt-grid__item kt-grid__item--fluid">
        <?php
        if (!empty($model)) {
            foreach ($model as $row) {
                ?>
                <div class="kt-portlet" data-ktportlet="true">
                    <div class="kt-portlet__head">
                        <div class="kt-portlet__head-label">
                            <h3 class="kt-portlet__head-title">

                                Phase <?= $row->sort ?> : <?= $row->name ?> 
                                <!--<span class="btn btn-label-primary btn-sm ml-2"><?php //= $row->duration ?> days</span>-->
                                <a href="index.php?r=phase/update&id=<?= $row->id ?>">
                                    <span class="btn btn-sm btn-icon btn-label-success" style="cursor: pointer;">
                                        <i class="flaticon-edit"></i>
                                    </span>
                                </a>
                                <button class="btn btn-sm btn-icon btn-label-danger" type="button" onclick="deletedata(<?= $row->id ?>)">
                                    <i class="flaticon-delete"></i>
                                </button>
                            </h3>
                        </div>
                        <div class="kt-portlet__head-toolbar">
                            <div class="kt-portlet__head-group">
                                <a href="index.php?r=step/create&phase_id=<?= $row->id ?>" class="btn btn-sm btn-success">
                                    Add Step
                                </a>
                                <a href="#" data-ktportlet-tool="toggle" class="btn btn-sm btn-icon btn-clean btn-icon-md" aria-describedby="tooltip_mtpb3la6ln"><i class="la la-angle-down"></i></a>
                                <div class="tooltip tooltip-portlet tooltip bs-tooltip-top" role="tooltip" id="tooltip_mtpb3la6ln" aria-hidden="true" x-placement="top" style="position: absolute; will-change: transform; visibility: hidden; top: 0px; left: 0px; transform: translate3d(440px, -39px, 0px);">
                                    <div class="tooltip-arrow arrow" style="left: 34px;"></div>
                                    <div class="tooltip-inner">Collapse</div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="kt-portlet__body p-0">
                        <?php
                        $model2 = Step::find()->where(['phase_id' => $row->id])->andwhere(['status' => '1'])->orderBy(['sort' => SORT_ASC])->all();
                        if (!empty($model2)) {
                            $countdays = 0;
                            echo '<table class="table mb-0 table-borderless table-striped">
                            <thead>
                                <tr>
                                    <th scope="col" width="5%" class="text-center">Step</th>
                                    
                                    <th scope="col">Name</th>
                                    <th scope="col" width="20%">Assign To</th>
                                    <th scope="col" width="10%">Track Progress</th>
                                    <th scope="col" width="10%">Duration</th>
                                    <th scope="col" width="7%" class="text-center"></th>
                                </tr>
                            </thead>
                            <tbody>';
                            foreach ($model2 as $row2) {
                                $countdays += (float) $row2->duration;
                                echo '<tr>
                                        <td class="text-center">' . $row2->getstepno($row2->id) . '</td>
                                        
                                        <td>' . $row2->name . '</td>
                                        <td>' . $ParamList->getlabel(2, $row2->assignto) . '</td>
                                        <td>' . $ParamList->getlabel(35, $row2->track) . '</td>
                                        <td>' . $row2->duration . ' days</td>
                                        <td>
                                            <a href="index.php?r=step/update&id=' . $row2->id . '"><span class="kt-font-success icon-custom"><i class="far fa-edit fa-lg"></i></span></a>&nbsp;&nbsp;
                                            <span class="kt-font-danger" title="Delete"><i class="far fa-trash-alt fa-lg" style="cursor:pointer;" onclick="deletedata2(' . $row2->id . ')"></i></span>
                                        </td>
                                    </tr>';
                            }
                            echo '</tbody><tfoot><tr><th colspan="4"></th><th>Total</th><th colspan="2">' . $countdays . ' days</th></tr></tfoot></table>';
                        }
                        ?>
                    </div>
                </div>    
                <?php
            }
        }
        ?>
    </div>
</div>
<script>
    function deletedata(id) {
        Swal.fire({
            title: 'Are you sure to delete this data?',
            text: "You won't be able to revert this!",
            icon: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: 'Yes, delete it!'
        }).then((result) => {
            if (result.value) {
                $.ajax({
                    url: "index.php?r=phase/delete",
                    method: "POST",
                    data: {"id": id},
                    success: function (response) {
                        if (response === 'success') {
                            swal.fire({
                                position: 'center-center',
                                type: 'success',
                                title: 'Data has been deleted',
                                showConfirmButton: false,
                                timer: 1500, }).then(function (result) {
                                location.reload();
                            });
                        }
                    },
                });
            }
        });
    }

    function deletedata2(id) {
        Swal.fire({
            title: 'Are you sure to delete this data?',
            text: "You won't be able to revert this!",
            icon: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: 'Yes, delete it!'
        }).then((result) => {
            if (result.value) {
                $.ajax({
                    url: "index.php?r=step/delete",
                    method: "POST",
                    data: {"id": id},
                    success: function (response) {
                        if (response === 'success') {
                            swal.fire({
                                position: 'center-center',
                                type: 'success',
                                title: 'Data has been deleted',
                                showConfirmButton: false,
                                timer: 1500, }).then(function (result) {
                                location.reload();
                            });
                        }
                    },
                });
            }
        });
    }
</script>