<?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 ".ARTICLES_TABLE." order by articleid DESC";
        $data = $alltable->getInfo('', $sql);
        $count = count($data);
        
        $record = '';
        
        if($count > 0){
            for($i=0;$i<$count;$i++){
                
                $articleid = $data[$i]['articleid'];
                $articletitle = $data[$i]['articletitle'];
                $status = $data[$i]['status'];
                
                $articleurl = DOC_ROOT."exhibitor-articles-detail.php?articleid=$articleid";        
                
                if($status == 1){
                    $displaystatus = "<span class='text text-success'>Active</span>";
                }else{
                    $displaystatus = "<span class='text text-danger'>Inactive</span>";
                }
                
                //$pageurl    =   cleanURL($articletitle);
                $record .= "<tr>";
                    $record .= "<td>".($i+1)."</td>";
                    $record .= "<td>".$articletitle."</td>";              
                    $record .= "<td>".$displaystatus."</td>";                
                    $record .= "<td><a href='add-exhibitor-articles.php?articleid=".$articleid."'><i class='fa fa-pencil'></i> Edit </a></td>";
                    //$record .= "<td><a href='".DOC_ROOT."article/".$articleurl.".html' target='_blank'> <i class='fa fa-eye'></i> View </a></td>";
                    $record .= "<td><a href='$articleurl' target='_blank'> <i class='fa fa-eye'></i> View </a></td>";     
                $record .= "</tr>";
            }    
        }else{
            $record .= "<tr>";
                $record .= "<td colspan='4'>No Record Found..!</td>";
            $record .= "</tr>";
        }                   
        require_once "view-exhibitor-articles1.html";    
    }else{
        $redirect = ADMIN_DIR."auth/login.php";
        header("location:".$redirect);
        exit();
    }   
?>