<?php
    require_once "../include/config.php";
    require_once GLOBAL_INCLUDE_PATH."include/startup.php";
    
    $contact = new contactus();
    $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 ".CONTACTSDETAILS_TABLE." order by contactid DESC";
        $data = $contact->getcontactus('','', $sql);
        $count = count($data);
        
        $record = '';
        
        if($count > 0){
            for($i=0;$i<$count;$i++){
                
                $contactid = $data[$i]['contactid'];
                $company_name = $data[$i]['company_name'];
                $receipt_name = $data[$i]['recipientname'];
               
               /* if($status == 1){
                    $displaystatus = "<span class='text text-success'>Active</span>";
                }else{
                    $displaystatus = "<span class='text text-danger'>Inactive</span>";
                }
                
                if($isparentpage == 1 && $parentpageid == 0){
                    $displaypagestatus = "<span class='text text-success'>Yes</span>";
                }else{
                    $displaypagestatus = "<span class='text text-danger'>No</span>";
                } */
                
                $record .= "<tr>";
                    $record .= "<td>".($i+1)."</td>";
                    $record .= "<td>".$company_name."</td>";   
                    $record .= "<td>".$receipt_name."</td>";
                    $record .= "<td><a href='".DOC_ROOT."admin/contact_details.php?contactid=$contactid' 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_contact1.html";    
    }
    else
    {
        $redirect = ADMIN_DIR."auth/login.php";
        header("location:".$redirect);
        exit();
    }   
?>