<?php


function removeNonletters($subject) {
    $input = preg_replace("/[^a-z0-9]/i", "", $subject);
    return $input;
}

function totalEbayAuctionItems($conn){
    $total = 0;
    try {

        $sqlQuery = "select count(item.id) as totalcount from products item where DATEDIFF(now(), item.listing_date) >=90 and item.destination=1 and item.is_listed='yes' and is_sold='no' ;";
        $stmt = $conn->prepare($sqlQuery);
        $stmt->execute();
        $row = $stmt->fetch();
        if ($row) {
            $total = $row['totalcount'];
        }
    } catch (Exception $exc) {
       
    }
    return $total;
}

// function totalClientListings($conn){
//     $clientid = $_SESSION["userid_brand"];
//     $total = 0;
//     try {
        
//         $sqlQuery = "select count(item.id) as totalcount from products item where Month(listing_date) = Month(now()) and item.destination=1 and item.is_listed='yes' and is_sold='no' and item.clientid=$clientid;";
//         $stmt = $conn->prepare($sqlQuery);
//         $stmt->execute();
//         $row = $stmt->fetch();
//         if ($row) {
//             $total = $row['totalcount'];
//         }
//     } catch (Exception $exc) {
       
//     }
//     return $total;
// }
// function totalClientSold($conn){
//     $clientid = $_SESSION["userid_brand"];
//     $total = 0;
//     try {
        
//         $sqlQuery = "select count(item.id) as totalcount from products item where Month(sale_date) = Month(now()) and item.destination=1 and item.is_listed='yes' and is_sold='yes' and item.clientid=$clientid;";
//         $stmt = $conn->prepare($sqlQuery);
//         $stmt->execute();
//         $row = $stmt->fetch();
//         if ($row) {
//             $total = $row['totalcount'];
//         }
//     } catch (Exception $exc) {
       
//     }
//     return $total;
// }
function totalUnlistedItems($conn)
    {
        $total = 0;
    try {

        $sqlQuery = "select count(item.id) as totalcount from products item where item.is_listed='no' and item.destination=1 ;";
        $stmt = $conn->prepare($sqlQuery);
        $stmt->execute();
        $row = $stmt->fetch();
        if ($row) {
            $total = $row['totalcount'];
        }
    } catch (Exception $exc) {
      
    }
    return $total;
    }
function totalNewTickets($conn){
    $total = 0;
    try {

        $sqlQuery = "select count(item.id) as totalcount from support item where status='' or status is null;";
        $stmt = $conn->prepare($sqlQuery);
        $stmt->execute();
        $row = $stmt->fetch();
        if ($row) {
            $total = $row['totalcount'];
        }
    } catch (Exception $exc) {
      
    }
    return $total;
}