<?php

Model::sessionInit();

$username1 = Model::sessionGet('username1');

$assistance = Model::sessionGet('assistance');

$accesslevel = Model::sessionGet('accesslevel');

if (isset($username1) and !empty($username1)) {

// print_r($paln);
//  $_SERVER['SCRIPT_URI'];
// $url="$_SERVER[HTTP_HOST]"."$_SERVER[REQUEST_URI]";
// echo $url;
//     Model::sessionSet('url', $url);
?>

<?php require('views/navigation/index.php');?>

    
<section>
    <div class="container-fluid">
        
        <div class="titr-box row">
            <div class="titr">
                <h4>
                    گزارش گیری
                </h4>
            </div>
            
        </div>
            
        <?php require('views/mainsearch/index.php'); ?>
        

        <div class="row">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">

                <div class="table-responsive items-container">
                    <table class="table table-striped table-responsive pre-scrollable table-condensed table-bordered">
                        
                        <thead>
                            <tr>
                                <th>
                                    ردیف
                                </th>
                                
                                <th>
                                    شماره طرح
                                </th>
                                
                                <th>
                                    عنوان طرح
                                </th>
                                
                                <th>
                                    تاریخ ثبت
                                </th>
                                <th>
                                    وضعیت
                                </th>
                                <th>
                                    عملکرد
                                </th>
                                <th>
                                    جزییات طرح
                                </th>
                                <th>
                                    فایل طرح
                                </th>
                                <th>
                                    فایل صورت جلسه
                                </th>
                               
                                
                                

                            </tr>
                        </thead>

                        <tbody class="bodytr">
                            <?php
                            $plan=$data[0];
                            $k=0;
                             foreach ($plan as $item) {
                                ?>
                                <tr class="rowtr item item-visible">
                                    <td><?= ++$k; ?></td>

                                    <?php

                                    foreach ($item as $key => $row) {
                                        if($key=="plan_id" OR $key=="plan_name" OR $key=="present_date" ){
                        ?>
                                         <td><?= $row ?></td>
                          <?php
                                    }}
// echo $item['id'];
                                        // $id=$item['id'];
                                         $meeting=$this->model->selectmeetingbyid($item['plan_id']);
                                        
                                        // وضعیت
                                        if($meeting[0]['state']==1){
                                            $state="مصوب";
                                        }
                                        elseif($meeting[0]['state']==2){
                                            $state="مشروط";
                                        }
                                        elseif($meeting[0]['state']==3){
                                            $state="مردود";
                                        }
                                    else{
                                            $state="---";
                                    }
                                    // عملکرد
                                     if($meeting[0]['operation']==1){
                                            $operation="درحال انجام";
                                        }
                                        elseif($meeting[0]['operation']==2){
                                            $operation="ناتمام";
                                        }
                                        elseif($meeting[0]['operation']==3){
                                            $operation="اتمام";
                                        }
                                    else{
                                            $operation="---";
                                    }
                                    
                                    ?>
                                        <td><?= $state ?></td>
                                        <td><?= $operation ?></td>

                                        <?php
                                    
                                    ?>
                              
                                <td>
                                    <a href="<?= URL ?>plan_detail?id=<?=$item['plan_id']?>"> <i class="fa fa-eye"></i> </a>
                                </td>
                                <td>
                                    <a href="<?= $item['discription_file'] ?>" class="fa fa-download" download></a>
                                </td>
                                <td>
                                   <?php
                                    $meeting=$this->model->selectmeetingbyid($item['plan_id']);
                                    if($item['plan_id']==$meeting[0]['plan_id']){
                                    ?>
                                    <a href="<?= $meeting[0]['mit_file'] ?>" class="fa fa-download" download></a>
                                    <?php
                                    }
                                    else{
                                    ?>
                                    <span>---</span>
                                    <?php
                                    }
                                    ?>
                                </td>
                                
                                
                                

                                
                            </tr>
                            <?php }
                               echo "<div class=\"case\"><i class=\"fa fa-hand-o-left\"></i><div class=\"cases\">".$k." مورد وجود دارد " ."</div></div>";
                                echo "</br>";                            ?>
                        </tbody>

                    </table>

                </div><!-- table-risponsive -->
                
                <ul class="pagination-container"></ul>
                 
            </div><!-- end of col-lg-12 -->
        </div><!-- end of row-->


    </div><!-- end of container-fluid-->

</section>



<script>
    function stsv(elem) {
//            alert(elem);

        if (elem == "") {

            document.getElementById("overlay-content").innerHTML = "";
            return;
        }
        if (window.XMLHttpRequest) {
            // code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        } else { // code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function () {
            if (this.readyState == 4 && this.status == 200) {
                document.getElementById("overlay-content").innerHTML = this.responseText;
            }
        }
        xmlhttp.open("POST", "<?= URL ?>edit/index.php?getide=" + elem, true);
        xmlhttp.send();


    }


</script>


<?php

} else {
    echo "<script>window.location.replace('index');</script>";
}
?>