<?php
    require_once "../include/config.php";
    require_once GLOBAL_INCLUDE_PATH."include/startup.php";
    $alltable = new AllTables();
    
    if(!adminchecklogin('', '', '', $G_userid)){
        $redirect = ADMIN_DIR."auth/login.php";
        header("location:".$redirect);
        exit();
    }

    if($G_userid > 0 && $G_userid != null && $G_userid != ''){
        $sql = "select * from ".PRESSRELEAS_TABLE." order by pressreleasesid DESC";
        $data = $alltable->getInfo('', $sql);
        // echo"<pre>";
        // print_r($data);
        // die();
        $count = count($data);              
        
        $record = '';
      
        if($count > 0){
            for($i=0;$i<$count;$i++){
                
                $pressreleasesid = $data[$i]['pressreleasesid'];
                $pressreleasestitle = $data[$i]['pressreleasestitle'];
                $pressreleasesdesc = $data[$i]['pressreleasesdesc'];
                $status = $data[$i]['status'];
                
                             
                if($status == 1){
                    $displaystatus = "<span class='text text-success'>Active</span>";
                }else{
                    $displaystatus = "<span class='text text-danger'>Inactive</span>";
                }
                  
                //$pageurl    =   cleanURL($blogtitle);                     
                $record .= "<tr>";          
                    $record .= "<td>".($i+1)."</td>";          
                    $record .= "<td>".$pressreleasestitle."</td>";   
                    $record .= "<td>".$displaystatus."</td>";
                    $record .= "<td><a href='add-press-releases.php?pressreleasesid=".$pressreleasesid."'><i class='fa fa-pencil'></i> Edit </a></td>";
                    //$record .= "<td><a href='".DOC_ROOT."blog/".$blogurl.".html' target='_blank'> <i class='fa fa-eye'></i> View </a></td>";
                   // $record .= "<td><a href='".DOC_ROOT."".$presscoverageurl.".htm' target='_blank'> <i class='fa fa-eye'></i> View </a></td>";
                $record .= "</tr>";         
            }           
        }else{
            $record .= "<tr>";
                $record .= "<td colspan='6'>No Record Found..!</td>";
            $record .= "</tr>";             
        }
        require_once "view-press-releases1.html";    
    }else{
        $redirect = ADMIN_DIR."auth/login.php";
        header("location:".$redirect);
        exit();
    }   
?>