Your IP : 216.73.216.79


Current Path : /var/www/html/dyna-project/views/projects/
Upload File :
Current File : /var/www/html/dyna-project/views/projects/update.php.20210225

<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use app\models\User;
use yii\helpers\ArrayHelper;
use app\models\Tasks;
use app\models\ParamList;
use app\models\Pic;
use app\models\Templates;

$ParamList = new ParamList();
?>
<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 Projects</h3>
            <div class="kt-subheader__breadcrumbs">
                <span class="kt-subheader__breadcrumbs-separator"></span>
                <span class="kt-subheader__breadcrumbs-link"> Manage Projects</span>
                <span class="kt-subheader__breadcrumbs-separator"></span>
                <span class="kt-subheader__breadcrumbs-link"> Update Project</span>
            </div>
        </div>
    </div>
</div>
<div class="projects-create">
    <div class="projects-form">
        <div class="kt-container  kt-grid__item kt-grid__item--fluid">
            <?php $form = ActiveForm::begin(); ?>

            <div class="row">
                <div class="col-sm-4">
                    <div class="kt-portlet kt-portlet--height-fluid">
                        <div class="kt-portlet__head">
                            <div class="kt-portlet__head-label">
                                <h3 class="kt-portlet__head-title">Project Details</h3>
                            </div>

                        </div>
                        <div class="kt-portlet__body">
                            <div class="kt-portlet__content">

                                <div class='form-group-custom'>
                                    <?php
                                    echo $form->field($model, 'template_id', ['template' => "{label}
                                    {input}{error}"])
                                            ->dropDownList(ArrayHelper::map(Templates::find()->where(['status' => '1'])->orderBy(['name' => SORT_ASC])->all(), 'id', 'name'), [
                                                'prompt' => '-- Please choose --', 'class' => 'form-control kt-selectpicker', 'disabled' => true]);
                                    ?>
                                </div>

                                <div class='form-group-custom'>
                                    <?=
                                    $form->field($model, 'name', ['template' =>
                                        "{label}<span class='required'>*</span>{input}
                                    <span class='kt-font-danger font-weight-bold'>{error}</span>"])->textInput(['maxlength' => true]);
                                    ?>
                                </div>

                                <div class='form-group-custom'>
                                    <?php
                                    echo $form->field($model, 'cat', ['template' => "{label}
                                    {input}{error}"])
                                            ->dropDownList($ParamList->getparamlist2(37), ['prompt' => '-- Please choose --', 'class' => 'form-control']);
                                    ?>
                                </div>
                                <div class='form-group-custom'>
                                    <?=
                                    $form->field($model, 'start_dt', [
                                        'template' => "{label}<span class='required'>*</span>
                                        <div class='input-group'>
                                            {input}
                                            <div class='input-group-append'><span class='input-group-text'><i class='la la-calendar-check-o'></i></span></div>
                                        </div>
                                        <span class='kt-font-danger font-weight-bold'>{error}</span>"
                                    ])->textInput(['readonly' => true, 'onchange' => 'calcprojectdue()']);
                                    ?>
                                </div>


                                <div class='form-group-custom'>
                                    <?=
                                    $form->field($model, 'end_dt', [
                                        'template' => "{label}<span class='required'>*</span>
                                        <div class='input-group'>
                                            {input}
                                            <div class='input-group-append'><span class='input-group-text'><i class='la la-calendar-check-o'></i></span></div>
                                        </div>
                                        <span class='kt-font-danger font-weight-bold'>{error}</span>"
                                    ])->textInput(['readonly' => true]);
                                    ?>
                                </div>



                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-8">
                    <div class="kt-portlet kt-portlet--height-fluid">
                        <div class="kt-portlet__head">
                            <div class="kt-portlet__head-label">
                                <h3 class="kt-portlet__head-title">Assign To (Staff In-Charge)</h3>
                            </div>

                        </div>
                        <div class="kt-portlet__body">
                            <div class="kt-portlet__content">

                                <div class="row">
                                    <div class="col-5"><div class="form-group mb-0"><label class="control-label">Role</label></div></div>
                                    <div class="col-7"><div class="form-group mb-0"><label class="control-label">Staff Name</label></div></div>
                                </div>
                                <?php
                                $modelPic = Pic::find()->where(['project_id' => $model->id])->andwhere(['status' => '1'])->orderBy(['id' => SORT_ASC])->all();
                                if (!empty($modelPic)) {
                                    foreach ($modelPic as $rowpic) {

                                        echo '<div class="row">
                                                <div class="col-5">
                                                    <input type="hidden" value="' . $rowpic->id . '" name="pic_id[]">
                                                    ' . Html::dropDownList('pic_role_' . $rowpic->id, $rowpic->role, $ParamList->getparamlist2(2), ['class' => 'mb-2 form-control kt-selectpicker', 'id' => 'pic_role_' . $rowpic->id, 'prompt' => '-- Please choose role --', 'onchange' => 'changerole(this.value,' . $rowpic->id . ')']) . '
                                                </div>
                                                <div class="col-7">
                                                    ' . Html::dropDownList('pic_user_' . $rowpic->id, $rowpic->user_id, ArrayHelper::map(User::find()->where(['status' => '1'])->orderBy(['name' => SORT_ASC])->all(), 'id', 'name'), ['class' => 'form-control kt-selectpicker', 'id' => 'pic_user_' . $rowpic->id, 'prompt' => '-- Please choose staff --']) . '
                                                </div>
                                            </div>';
                                    }
                                }
                                ?>


                            </div>
                        </div>
                    </div>
                </div>

            </div>

            <div class="kt-portlet" data-ktportlet="true">
                <div class="kt-portlet__head">
                    <div class="kt-portlet__head-label">
                        <h3 class="kt-portlet__head-title">
                            Tasks Details
                        </h3>
                    </div>
                    <div class="kt-portlet__head-toolbar">
                        <div class="kt-portlet__head-group">
                            <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">

                    <table class="table mb-0 table-borderless table-striped">
                        <thead>
                            <tr>
                                <th scope="col" class="text-center align-middle" width="6%">No.</th>
                                <th scope="col" class="align-middle">Task</th>
                                <th scope="col" class="align-middle" width="25%">Assign To</th>
                                <th scope="col" width="10%" class="align-middle">Duration (days)</th>
                                <th scope="col" width="10%" class="align-middle">Start Date</th>
                                <th scope="col" width="10%" class="align-middle">Due Date</th>
                                <th scope="col" class="text-center align-middle" width="1%"></th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                            $modelPhase = Tasks::find()
                                    ->where(['project_id' => $model->id])
                                    ->andwhere(['deleted_status' => '0'])
                                    ->andwhere(['task_type' => 'phase'])
                                    ->orderBy(['sort' => SORT_ASC])
                                    ->all();
                            if (!empty($modelPhase)) {
                                foreach ($modelPhase as $rowPhase) {
                                    $modelStep = Tasks::find()
                                            ->where(['project_id' => $model->id])
                                            ->andwhere(['deleted_status' => '0'])
                                            ->andwhere(['task_type' => 'step'])
                                            ->andwhere(['parent_id' => $rowPhase->id])
                                            ->orderBy(['sort' => SORT_ASC])
                                            ->all();
                                    if (!empty($modelStep)) {

                                        echo '<tr><th colspan="7" class="align-middle">Phase ' . $rowPhase->sort . ' : ' . $rowPhase->task_name . '</th></tr>';

                                        foreach ($modelStep as $rowStep) {
                                            echo '<tr class="rowtask_' . $rowStep->id . '">
                                                     <input type="hidden" value="' . $rowStep->id . '" name="taskid[]">
                                                     <td><input type="text" class="form-control taskno" value="' . $rowStep->task_no . '" name="task_no_' . $rowStep->id . '"></td>
                                                     <td><input type="text" class="form-control taskname" value="' . $rowStep->task_name . '" name="task_name_' . $rowStep->id . '"></td>
                                                     <td>' . Html::dropDownList('task_assignto_' . $rowStep->id, $rowStep->assign_to, ArrayHelper::map(User::find()->where(['status' => '1'])->orderBy(['name' => SORT_ASC])->all(), 'id', 'name'), [
                                                'class' => 'taskassignto form-control kt-selectpicker', 'prompt' => '- Please choose -']) . '
                                                </td>
                                                    <td><input type="text" value="' . $rowStep->duration . '" onchange="updatetaskenddate(' . $rowStep->id . ')" id="task_duration_' . $rowStep->id . '" name="task_duration_' . $rowStep->id . '" class="form-control task_duration"></td>
                                                    <td><input type="text" value="' . $rowStep->start_dt . '" onchange="updatetaskenddate(' . $rowStep->id . ')" id="task_startdt_' . $rowStep->id . '" name="task_startdt_' . $rowStep->id . '" class="form-control datepicker taskstardt" readonly="" style="width:110px;"></td>
                                                    <td><input type="text" value="' . $rowStep->end_dt . '" id="task_enddt_' . $rowStep->id . '" name="task_enddt_' . $rowStep->id . '" class="form-control taskenddt" readonly=""></td>
                                                    <td>
                                                        <button type="button" class="btn btn-outline-hover-danger btn-icon">
                                                            <i class="far fa-trash-alt kt-font-danger" onclick="deletetask(' . $rowStep->id . ')"></i>
                                                        </button>
                                                    </td>
                                                </tr>';


                                            if ($rowStep->track_type == 'product') {
                                                $modelSubStep = Tasks::find()
                                                        ->where(['project_id' => $model->id])
                                                        ->andwhere(['deleted_status' => '0'])
                                                        ->andwhere(['task_type' => 'product'])
                                                        ->andwhere(['parent_id' => $rowStep->id])
                                                        ->orderBy(['sort' => SORT_ASC])
                                                        ->all();
                                                if (!empty($modelSubStep)) {
                                                    foreach ($modelSubStep as $rowSubStep) {
                                                        echo '<tr class="rowtask_' . $rowStep->id . ' row_product_' . $rowSubStep->data_id . '">
                                                                <td><input type="hidden" value="' . $rowSubStep->id . '" name="taskid[]"></td>
                                                                <td class="align-middle">' . $Products->getname($rowSubStep->data_id) . '</td>
                                                                <td>' . Html::dropDownList('task_assignto_' . $rowSubStep->id, $rowSubStep->assign_to, ArrayHelper::map(User::find()->where(['status' => '1'])->orderBy(['name' => SORT_ASC])->all(), 'id', 'name'), [
                                                            'class' => 'taskassignto form-control kt-selectpicker', 'prompt' => '- Please choose -']) . '
                                                                </td>
                                                                <td><input type="text" value="' . $rowSubStep->duration . '" onchange="updatetaskenddate(' . $rowSubStep->id . ')" id="task_duration_' . $rowSubStep->id . '" name="task_duration_' . $rowSubStep->id . '" class="form-control task_duration"></td>
                                                                <td><input type="text" value="' . $rowSubStep->start_dt . '" onchange="updatetaskenddate(' . $rowSubStep->id . ')" id="task_startdt_' . $rowSubStep->id . '" name="task_startdt_' . $rowSubStep->id . '" class="form-control datepicker taskstardt" readonly="" style="width:110px;"></td>
                                                                <td><input type="text" value="' . $rowSubStep->end_dt . '" id="task_enddt_' . $rowSubStep->id . '" name="task_enddt_' . $rowSubStep->id . '" class="form-control taskenddt" readonly=""></td>
                                                                <td></td>
                                                            </tr>';
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            ?>
                        </tbody>
                    </table>
                </div>
            </div>

            <div class="kt-form__actions">
                <?= Html::a('<i class="fas fa-arrow-left"></i>&nbsp;Back', ['index'], ['class' => 'btn btn-outline-brand']) ?>&nbsp;
                <?= Html::a('<i class="fas fa-sync"></i>&nbsp;Reset', [Yii::$app->controller->action->id, 'id' => Yii::$app->getRequest()->getQueryParam('id')], ['class' => 'btn btn-outline-success']); ?>&nbsp;
                <?= Html::button('<i class="fas fa-pencil-alt"></i>&nbsp;Update Project', ['class' => 'btn btn-info', 'onclick' => 'checkform()']); ?>
            </div>
            <?php ActiveForm::end(); ?>
        </div>
    </div>
</div>
<?php
include 'footer.php';
$this->registerJs("countaddhoc = $('#totaladhoc').val();");
?>
<script>
    function deletetask(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=tasks/delete",
                    method: "POST",
                    data: {"id": id},
                    success: function (response) {
                        $('.rowtask_' + id).remove();
                    },
                });
            }
        });
    }

    function deleteproduct(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=products/delete",
                    method: "POST",
                    data: {"id": id},
                    success: function (response) {
                        $('.row_product_' + id).remove();
                    },
                });
            }
        });
    }

    function changecurrentstaff(old_id, new_id) {
        if (new_id !== '') {
            $('.taskassignto').each(function () {
                var current_staff = $(this).find("option:selected").val();
                if (parseInt(current_staff) === parseInt(old_id)) {
                    //alert(current_staff + ' ' + old_id + ' = match');
                    $(this).val(new_id);
                    $(this).selectpicker('refresh');
                }
            });
        }
    }
</script>