<!DOCTYPE html>

<html>



<head>

    <title>PROJECT SUBMITTED SCHEDULE_<?php echo $id; ?></title>

    <style>

        .table_box {

            width:100%;

            border-collapse: separate !important;

            margin-top: 10px;

            padding: 10px;

            font-size: 16px !important;

            border: 1px solid #0066ff;

            border-radius: 6px;

        }



        div.page {

            page-break-after: auto

        }

    </style>

</head>



<body>

<div class="">

    <!-- <?php //$this->renderPartial("//common/header"); ?> -->

    <div class="col-4">

        <!-- <br> -->

        <?php

        $model = WsProject::model()->findByPk($id);





        ?>





        <!-- <div class="h3" style="margin-top: 0;margin-bottom: 0;"> -->



        <!-- </div> -->





        <div class="input-block">

            <b><?php echo $id; ?></b>

        </div>

        <b><?php echo strtoupper($model->project_name); ?></b><br>



    </div>

    <div class="col-4">

        <div class="h3" style="margin-top: 0;margin-bottom: 0;text-align: center;">

            <?php echo 'PROJECT SUBMITTED SCHEDULE'; ?>

        </div>

    </div>

    <div class="col-4" style="color:#101010;float: right;">

        <?php $this->renderPartial("//common/header"); ?>

    </div>





</div>

<br>

<div class="col-md-12 page" style="width:100%">

    <table class="table" style="width:100%" style="font-size:10px;">
    

        <tr>

            <?php

            ?>

            <td class="bc-tl"><b>Location</b></td>

            <td>

                <?php echo $model->location; ?>

            </td>



            <td><b>Project Date</b></td>

            <td >

                <?php

                if ($model->project_date != '' && $model->project_date != '0000-00-00') {



                    echo date('d/m/Y', STRTOTIME($model->project_date));

                } ?>

            </td>



            <td><b>End Date</b></td>

            <td colspan="3">

                <?php

                if ($model->actual_end_date != '' && $model->actual_end_date != '0000-00-00') {



                    echo date('d/m/Y', STRTOTIME($model->actual_end_date));

                } ?>

            </td>

        </tr>

        <tr>

            <?php

            ?>

            

            <td><b>Submitted Type</b></td>

            <td>

                <?php 



             $SubmittedSheduleType_detils = WsMasterSubmittedSheduleType::model()->findByPk((int)$type_id);

        echo  $SubmittedSheduleType_detils->scheduled_type;  ?>

            </td>



            <td><b>Manager</b></td>

            <td colspan="5">

                <?php 

               echo  $model->employeedetails->employeefullname;  ?>

            </td>

        </tr>
        <tr>
           <td><b>Submitted Schedule</b></td> 
           <td>

                <?php 
                $count_submited_scedules = 0;
                $count_submited_scedules = Yii::app()->db->createCommand('SELECT COUNT(DISTINCT(main_id)) FROM `erp_ws_master_material_submited_scheduled_details` MSD WHERE type_id ='. (int)$type_id.' AND project_id=' . (int) $id)->queryScalar();
                echo  $count_submited_scedules;  ?>

            </td>
            <td><b>Approved</b></td> 
            <td>
        <?php 
             $aproved_count = WsMasterMaterialSubmitedScheduledDetails::model()->count(array('condition' =>'project_id="'.(int) $id.'" AND status="Y" AND type_id ="'.(int)$type_id.'"'));

        echo  $aproved_count;  ?>  
            </td>
            <td><b>Rejected</b></td>
            <td><?php 
             $rejected_count = WsMasterMaterialSubmitedScheduledDetails::model()->count(array('condition' =>'project_id="'.(int) $id.'" AND status="N" AND type_id ="'.(int)$type_id.'"'));

        echo  $rejected_count;  ?>  </td> 
            <td><b>No Answer</b></td>
            <td><?php 
             $noans_count = WsMasterMaterialSubmitedScheduledDetails::model()->count(array('condition' =>'project_id="'.(int) $id.'" AND (status!="Y" AND status!="N") AND type_id ="'.(int)$type_id.'"')); 
             echo $noans_count;?>
                 
             </td> 
        </tr>

    </table>

</div>



<br>

<?php

$order_by = 'main_id ASC';

$condition = 't.project_id ="' . $id . '"';

$condition .= " AND t.type_id = " . $type_id;

$modelmaterialsubmited = WsMasterMaterialSubmitedScheduledDetails::model()->findAll(array('condition' => $condition, 'order' => $order_by));



?>

<h5>Submitted Schedule List</h5>

<div class="col-md-12 page">

    <table id="" class="table" style="font-size:10px;">

        <thead>

        <tr>

            <th class="text-center bc-tl">No</th>

            <!-- <th class="text-center">Type</th> -->

            <th class="text-center"  >Drawing No</th>

            <th class="text-center">Title</th>

            <th class="text-center">Location</th>

            <th class="text-center"  >Reference</th>

            <th class="text-center" >PLNG SUBM Date</th>

            <th class="text-center" >ACT SUBM Date</th>

            <th class="text-center" >RET Date</th>

            <th class="text-center">Status</th>

            <th class="text-center" >Note</th>



        </tr>

        </thead>

        <tbody>



        <?php

        $m = 1;





        if (!empty($modelmaterialsubmited)) {

            $x=0;

            $y=1;

            $z=1;



            foreach ($modelmaterialsubmited as $key => $detail) {



                ?>



                <tr>

                    <?php   if($x!=  $detail->main_id){ ?>

                        <td>

                            <?php echo $y; ?>

                        </td>

                        <!-- <td>

                            <?php //echo $detail->type_det->scheduled_type; ?>

                        </td> -->

                        <td>

                            <?php echo $detail->drawing_no; ?>

                        </td>

                        <td>

                            <?php echo $detail->title; ?>

                        </td>

                        <td>

                            <?php echo $detail->location; ?>

                        </td>

                        <td>

                            <?php echo $detail->reference; ?>

                        </td>

                        <td>

                            <?php

                            if ($detail->planned_submission_date != '' && $detail->planned_submission_date != '0000-00-00') {



                                echo date("d/m/Y", strtotime($detail->planned_submission_date));

                            } ?>

                        </td>

                        <td>

                            <?php

                            if ($detail->actual_submission_date != '' && $detail->actual_submission_date != '0000-00-00') {



                                echo date("d/m/Y", strtotime($detail->actual_submission_date));

                            } ?>

                        </td>

                        <td>

                            <?php

                            if ($detail->returned_date != '' && $detail->returned_date != '0000-00-00') {



                                echo date("d/m/Y", strtotime($detail->returned_date));

                            }

                            ?>

                        </td>

                        <td>

                            <?php

                            if ($detail->status == 'N') {

                                echo 'Rejected';

                            } else if ($detail->status == 'Y') {

                                echo 'Approved';

                            } else {

                                echo '-';

                            }



                            ?>

                        </td>

                        <td>

                            <?php echo $detail->note; ?>

                        </td>

                    <?php  $x=  $detail->main_id ;  

                    $y=$y+1;

                    $z=1;

                    }else{ 

                        

                        $k=$y-1; ?>

                        <td>

                            <?php echo $k.'.'.$z; ?>

                        </td>

                        <!-- <td>

                            <?php // echo $detail->type_det->scheduled_type; ?>

                        </td> -->

                        <td>

                            <?php echo $detail->drawing_no; ?>

                        </td>

                        <td>

                            <?php echo $detail->title; ?>

                        </td>

                        <td>

                            <?php echo $detail->location; ?>

                        </td>

                        <td>

                            <?php echo $detail->reference; ?>

                        </td>

                        <td>

                            <?php

                            if ($detail->planned_submission_date != '' && $detail->planned_submission_date != '0000-00-00') {



                                echo date("d/m/Y", strtotime($detail->planned_submission_date));

                            } ?>

                        </td>

                        <td>

                            <?php

                            if ($detail->actual_submission_date != '' && $detail->actual_submission_date != '0000-00-00') {



                                echo date("d/m/Y", strtotime($detail->actual_submission_date));

                            } ?>

                        </td>

                        <td>

                            <?php

                            if ($detail->returned_date != '' && $detail->returned_date != '0000-00-00') {



                                echo date("d/m/Y", strtotime($detail->returned_date));

                            }

                            ?>

                        </td>

                        <td>

                            <?php

                            if ($detail->status == 'N') {

                                echo 'Rejected';

                            } else if ($detail->status == 'Y') {

                                echo 'Approved';

                            } else {

                                echo '-';

                            }



                            ?>

                        </td>

                        <td>

                            <?php echo $detail->note; ?>

                        </td>



                        <?php 

                        $z=$z+1 ;  

                    } ?>





                </tr>

                <?php

                $m = $m + 1;

                

            

        }} else {

            ?>

            <tr>

                <td colspan="10" class="text-center">No Data Found</td>

            </tr>

        <?php }

        ?>



        </tbody>

    </table>

</div>





</div>





<?php $this->renderPartial("//common/footer"); ?>





</body>



</html>

