Your IP : 216.73.216.79


Current Path : /var/www/html/dyna-project/views/dashboard/
Upload File :
Current File : /var/www/html/dyna-project/views/dashboard/details.php

<?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\TasksLog;
use app\models\Pic;

$ParamList = new ParamList();
$Tasks = new Tasks();
$User = new User();

$this->registerJs("");
$listModule = '';
?>
<style>
    .table tbody td{vertical-align: middle;}
    .card-custom .kt-user-card-v2{float:left;}
</style>
<div class="kt-subheader   kt-grid__item" id="kt_subheader">
    <div class="kt-container ">
        <div class="kt-subheader__main">
            <h3 class="kt-subheader__title">Projects Details</h3>
            <div class="kt-subheader__breadcrumbs">
                <span class="kt-subheader__breadcrumbs-separator"></span>
                <span class="kt-subheader__breadcrumbs-link"> Dashboard</span>
                <span class="kt-subheader__breadcrumbs-separator"></span>
                <span class="kt-subheader__breadcrumbs-link"> Projects Details</span>
            </div>
        </div>
    </div>
</div>

<div class="kt-container kt-grid__item kt-grid__item--fluid">

    <div class="row">
        <div class="col-sm-3">
            <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 p-0">
                    <div class="kt-portlet__content">
                        <table class="table table-striped table-borderless">
                            <tbody>
                                <tr>
                                    <td>
                                        Project Name<br>
                                        <b><?= $modelProject->name; ?></b>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Category<br>
                                        <b><?= $ParamList->getlabel(37, $modelProject->cat); ?></b>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Start Date<br>
                                        <b><?= date("d M Y", strtotime($modelProject->start_dt)) ?></b>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Due Date<br>
                                        <b><?= date("d M Y", strtotime($modelProject->end_dt)) ?></b>
                                    </td>
                                </tr>


                                <?php
                                if ($modelProject->progress != 'complete') {
                                    ?>
                                    <tr>
                                        <td>
                                            Due Days<br>
                                            <b><?= strip_tags($modelProject->getduedays($modelProject->end_dt)); ?></b>
                                        </td>
                                    </tr>
                                <?php } ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-3">
            <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">Person In-Charge</h3>
                    </div>
                </div>
                <div class="kt-portlet__body p-0">
                    <div class="kt-portlet__content">
                        <table class="table table-striped table-borderless">
                            <tbody>
                                <?php
                                $modelPic = Pic::find()->where(['project_id' => $modelProject->id])->andwhere(['status' => '1'])->orderBy(['id' => SORT_ASC])->all();
                                if (!empty($modelPic)) {
                                    foreach ($modelPic as $rowPic) {
                                        if (($modelUser = User::findOne($rowPic->user_id)) !== null) {
                                            $img_url = $modelUser->getfirstletter2($modelUser->name);
                                            if (!empty($modelUser->img_url))
                                                $img_url = '<img src="' . $modelUser->img_url . '">';
                                        }

                                        echo '<tr>
                                            <td>
                                                <div class="kt-user-card-v2">								
                                                    <div class="kt-user-card-v2__pic"><div class="kt-badge kt-badge--xl kt-badge--warning">' . $img_url . '</div></div>
                                                    <div class="kt-user-card-v2__details">									
                                                        <span class="kt-user-card-v2__name">' . $User->getusername($rowPic->user_id) . '</span>									
                                                        <span class="kt-user-card-v2__desc">' . $ParamList->getlabel(2, $rowPic->role) . '</span>								
                                                    </div>							
                                                </div>
                                            </td>
                                        </tr>';
                                    }
                                }
                                ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>

        <div class="col-sm-6">
            <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">Task Details</h3>
                    </div>
                </div>
                <div class="kt-portlet__body p-0">
                    <div class="kt-portlet__content">
                        <table class="table table-striped table-borderless">
                            <thead>
                                <tr>
                                    <th>Phase</th>
                                    <th width="20%" class="text-center">Total Task</th>
                                    <th width="20%" class="text-center">Task Complete</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                $output = '';
                                $modelPhase = Tasks::find()
                                        ->where(['project_id' => $modelProject->id])
                                        ->andwhere(['task_type' => 'phase'])
                                        ->andwhere(['deleted_status' => '0'])
                                        ->orderBy(['task_full_no' => SORT_ASC])
                                        ->all();
                                if (!empty($modelPhase)) {
                                    foreach ($modelPhase as $rowPhase) {
                                        $totalcomplete = Tasks::find()
                                                ->where(['project_id' => $modelProject->id])
                                                ->andwhere(['=', 'parent_id', $rowPhase->id])
                                                ->andwhere(['deleted_status' => '0'])
                                                ->andwhere(['OR', ['=', 'task_type', 'step'], ['=', 'task_type', 'product']])
                                                ->andwhere(['=', 'task_status', 'complete'])
                                                ->count();
                                        $totalall = Tasks::find()
                                                ->where(['project_id' => $modelProject->id])
                                                ->andwhere(['=', 'parent_id', $rowPhase->id])
                                                ->andwhere(['deleted_status' => '0'])
                                                ->andwhere(['OR', ['=', 'task_type', 'step'], ['=', 'task_type', 'product']])
                                                ->count();
                                        echo '<tr>
                                            <td>' . $rowPhase->task_name . '</td>
                                            <td class="text-center">' . $totalall . '</td>
                                            <td class="text-center">' . $totalcomplete . '</td>
                                            </tr>';
                                    }
                                }

                                $totalcompleteAdhoc = Tasks::find()
                                        ->where(['project_id' => $modelProject->id])
                                        ->andwhere(['deleted_status' => '0'])
                                        ->andwhere(['=', 'task_type', 'adhoc'])
                                        ->andwhere(['=', 'task_status', 'complete'])
                                        ->count();
                                $totalallAdhoc = Tasks::find()
                                        ->where(['project_id' => $modelProject->id])
                                        ->andwhere(['deleted_status' => '0'])
                                        ->andwhere(['=', 'task_type', 'adhoc'])
                                        ->count();
                                if (!empty($totalallAdhoc)) {
                                    $output .= '<tr><td>Adhoc Task</td><td class="text-center">' . $totalallAdhoc . '</td><td class="text-center">' . $totalcompleteAdhoc . '</td></tr>';
                                }
                                echo $output;
                                ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="kt-portlet">
        <div class="kt-portlet__body p-0">
            <table class="table table-bordered table-striped mb-0">
                <thead>
                    <tr>
                        <th width="20%">Phase</th>
                        <th width="20%">Task</th>
                        <th width="35%">Log</th>
                        <th class="text-nowrap text-center">Status</th>
                        <th width="15%">Assign To</th>
                        <th class="text-nowrap text-center">Date Task</th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    $modelTasks = Tasks::find()
                                    ->where(['project_id' => $modelProject->id])
                                    ->andwhere(['deleted_status' => '0'])
                                    ->andwhere(['task_type' => 'step'])->orderBy(['task_full_no' => SORT_ASC])->all();
                    if (!empty($modelTasks)) {
                        foreach ($modelTasks as $rowTasks) {

                            $assign_to = '';
                            $assign_to_arr = explode(',', $rowTasks->assign_to);
                            if (!empty($assign_to_arr)) {
                                foreach ($assign_to_arr as $assignID) {
                                    $assign_to .= $User->getuserdetails2($assignID);
                                }
                            }

                            $log = '';
                            $modelLog = TasksLog::find()->where(['task_id' => $rowTasks->id])->orderBy(['created_dt' => SORT_ASC])->all();
                            if (!empty($modelLog)) {
                                $countlog = 0;
                                foreach ($modelLog as $rowLog) {

                                    if ($countlog != 0)
                                        $log .= '<div style="border-bottom: 0.07rem dashed #ebedf2;margin-bottom:1em;"></div>';

                                    $log .= '<div style="float:left;">' . $User->getuserdetails2($rowLog->created_by) . '</div>';
                                    $log .= date("d M Y", strtotime($rowLog->created_dt));
                                    if (!empty($rowLog->file_url))
                                        $log .= '&nbsp;&nbsp;&nbsp;<a href="' . $rowLog->file_url . '" target="_blank">Attachment</a>';
                                    $log .= $rowLog->remarks;

                                    $countlog++;
                                }
                            }

                            $countModule = 0;
                            $totalPercentage = 0;
                            $calcTotalPercentage = 0;

                            $modelModule = Tasks::find()->where(['task_type' => 'module'])->andwhere(['parent_id' => $rowTasks->id])->orderBy(['sort' => SORT_ASC])->all();
                            if (!empty($modelModule)) {
                                $listModule .= '<div class="modal fade" id="modalProgress' . $rowTasks->id . '" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                                    <div class="modal-dialog modal-dialog-centered modal-lg" role="document">
                                        <div class="modal-content">
                                          <div class="modal-header">
                                            <h4 class="modal-title" id="myModalLabel">' . $rowTasks->task_name . ' Progress</h4>
                                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                          </div>
                                          <div class="modal-body">
                                            <table class="table table-bordered table-striped">
                                                <thead>
                                                    <tr>
                                                        <th class="text-nowrap" width="1%">No.</th>
                                                        <th>Module Name</th>
                                                        <th>Status</th>
                                                        <th width="1%">Percentage Complete</th>
                                                        <th>Remarks</th>
                                                    </tr>
                                                </thead>
                                                <tbody>';
                                foreach ($modelModule as $rowModule) {
                                    $countModule++;
                                    $listModule .= '<tr>
                                        <td>' . $countModule . '</td>
                                        <td>' . $rowModule->task_name . '</td>
                                        <td>' . ucwords($rowModule->task_status) . '</td>
                                        <td>' . $rowModule->percentage_complete . ' %</td>
                                        <td>' . $rowModule->remarks . '</td>
                                    </tr>';
                                    $totalPercentage += (float) $rowModule->percentage_complete;
                                }
                                if ($countModule != 0)
                                    $calcTotalPercentage = (float)((float)$totalPercentage / ($countModule * 100)) * 100;
                                $listModule .= '</tbody>
                                                <tfoot><tr><th colspan="3" class="text-right">Total Percentage</th><th colspan="2">' . round($calcTotalPercentage) . ' %</th></tr></tfoot>
                                            </table>
                                          </div>
                                        </div>
                                    </div>
                                </div>';
                            }

                            $popupModule = '';
                            if ($countModule != 0) {
                                $popupModule = '<a href="#" data-toggle="modal" data-target="#modalProgress' . $rowTasks->id . '">
                                    View task progress here
                                </a>';
                            }

                            echo '<tr>
                                <td>' . $Tasks->gettaskno($rowTasks->parent_id) . '. ' . $Tasks->getname($rowTasks->parent_id) . '</td>
                                <td>' . $rowTasks->task_name . $popupModule . '</td>
                                <td>' . $log . '</td>                                
                                <td>' . $rowTasks->displaytaskstatus($rowTasks->task_status) . '</td>
                                <td class="card-custom">' . $assign_to . '</td>
                                <td class="text-nowrap text-center">' . date("d M Y", strtotime($rowTasks->start_dt)) . '<br>until<br>' . date("d M Y", strtotime($rowTasks->end_dt)) . '</td>
                            </tr>';
                        }
                    }

                    $modelTasks = Tasks::find()
                                    ->where(['project_id' => $modelProject->id])
                                    ->andwhere(['deleted_status' => '0'])
                                    ->andwhere(['task_type' => 'adhoc'])->orderBy(['start_dt' => SORT_ASC])->all();
                    if (!empty($modelTasks)) {
                        foreach ($modelTasks as $rowTasks) {

                            $assign_to = '';
                            $assign_to_arr = explode(',', $rowTasks->assign_to);
                            if (!empty($assign_to_arr)) {
                                foreach ($assign_to_arr as $assignID) {
                                    $assign_to .= $User->getuserdetails2($assignID);
                                }
                            }

                            $log = '';
                            $modelLog = TasksLog::find()->where(['task_id' => $rowTasks->id])->orderBy(['id' => SORT_ASC])->all();
                            if (!empty($modelLog)) {
                                $countlog = 0;
                                foreach ($modelLog as $rowLog) {

                                    if ($countlog != 0)
                                        $log .= '<div style="border-bottom: 0.07rem dashed #ebedf2;margin-bottom:1em;"></div>';

                                    $log .= '<div style="float:left;">' . $User->getuserdetails2($rowLog->created_by) . '</div>';
                                    $log .= date("d M Y", strtotime($rowLog->created_dt));
                                    if (!empty($rowLog->file_url))
                                        $log .= '&nbsp;&nbsp;&nbsp;<a href="' . $rowLog->file_url . '" target="_blank">Attachment</a>';
                                    $log .= $rowLog->remarks;

                                    $countlog++;
                                }
                            }
                            
                            $countModule = 0;
                            $totalPercentage = 0;
                            $calcTotalPercentage = 0;

                            $modelModule = Tasks::find()->where(['task_type' => 'module'])->andwhere(['parent_id' => $rowTasks->id])->orderBy(['sort' => SORT_ASC])->all();
                            if (!empty($modelModule)) {
                                $listModule .= '<div class="modal fade" id="modalProgress' . $rowTasks->id . '" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                                    <div class="modal-dialog modal-dialog-centered modal-lg" role="document">
                                        <div class="modal-content">
                                          <div class="modal-header">
                                            <h4 class="modal-title" id="myModalLabel">' . $rowTasks->task_name . ' Progress</h4>
                                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                          </div>
                                          <div class="modal-body">
                                            <table class="table table-bordered table-striped">
                                                <thead>
                                                    <tr>
                                                        <th class="text-nowrap" width="1%">No.</th>
                                                        <th>Module Name</th>
                                                        <th>Status</th>
                                                        <th width="1%">Percentage Complete</th>
                                                        <th>Remarks</th>
                                                    </tr>
                                                </thead>
                                                <tbody>';
                                foreach ($modelModule as $rowModule) {
                                    $countModule++;
                                    $listModule .= '<tr>
                                        <td>' . $countModule . '</td>
                                        <td>' . $rowModule->task_name . '</td>
                                        <td>' . ucwords($rowModule->task_status) . '</td>
                                        <td>' . $rowModule->percentage_complete . ' %</td>
                                        <td>' . $rowModule->remarks . '</td>
                                    </tr>';
                                    $totalPercentage += (float) $rowModule->percentage_complete;
                                }
                                if ($countModule != 0)
                                    $calcTotalPercentage = (float)((float)$totalPercentage / ($countModule * 100)) * 100;
                                $listModule .= '</tbody>
                                                <tfoot><tr><th colspan="3" class="text-right">Total Percentage</th><th colspan="2">' . round($calcTotalPercentage) . ' %</th></tr></tfoot>
                                            </table>
                                          </div>
                                        </div>
                                    </div>
                                </div>';
                            }

                            $popupModule = '';
                            if ($countModule != 0) {
                                $popupModule = '<a href="#" data-toggle="modal" data-target="#modalProgress' . $rowTasks->id . '">
                                    View task progress here
                                </a>';
                            }

                            echo '<tr>
                                <td>Adhoc</td>
                                <td>' . $rowTasks->task_name .$popupModule. '</td>
                                <td>' . $log . '</td>                                
                                <td>' . $rowTasks->displaytaskstatus($rowTasks->task_status) . '</td>
                                <td class="card-custom">' . $assign_to . '</td>
                                <td class="text-nowrap text-center">' . date("d M Y", strtotime($rowTasks->start_dt)) . '<br>until<br>' . date("d M Y", strtotime($rowTasks->end_dt)) . '</td>
                                
                            </tr>';
                        }
                    }
                    ?>
                </tbody>
            </table>
        </div>
    </div>
</div>
<?= $listModule; ?>