public function actionIndex()
 {
     $allProducts = Product::getAllProducts();
     if (!$allProducts) {
         $allProducts = array();
     }
     require_once ROOT . '/views/admin_product/index.php';
     return true;
 }
 public function viewProducts()
 {
     require_once 'Product.php';
     $obj_product = new Product();
     $obj_product->getAllProducts('yes');
     echo "<option value='' selected='selected'>Select Product</option>";
     for ($i = 0; $i < count($obj_product->product_detail); $i++) {
         $id = $obj_product->product_detail["details{$i}"]["id"];
         $product_name = $obj_product->product_detail["details{$i}"]["name"];
         echo "<option value='{$id}' >{$product_name}</option>";
     }
 }
Example #3
0
         $reply->data = Product::getProductByVendorId($pdo, $vendorId);
     } else {
         if (empty($description) === false) {
             $reply->data = Product::getProductByDescription($pdo, $description);
         } else {
             if (empty($leadTIme) === false) {
                 $reply->data = Product::getProductByLeadTime($pdo, $leadTime);
             } else {
                 if (empty($sku) === false) {
                     $reply->data = Product::getProductBySku($pdo, $sku);
                 } else {
                     if (empty($title) === false) {
                         $reply->data = Product::getProductByTitle($pdo, $title)->toArray();
                     } else {
                         if (is_int($page) === true && $page >= 0) {
                             $allProducts = Product::getAllProducts($pdo, $page);
                             $replyData = [];
                             foreach ($allProducts as $index => $product) {
                                 $replyData[$index] = json_decode(json_encode($product));
                                 $replyData[$index]->quantityOnHand = $product->getQuantityOnHand($pdo);
                             }
                             $reply->data = $replyData;
                         } else {
                             throw new InvalidArgumentException("no parameters given", 405);
                         }
                     }
                 }
             }
         }
     }
 }
Example #4
0
                                    ';
            }
        }
        echo '
                            </div>
                            <div class="next-btn"><i class="mdi-navigation-chevron-right"></i></div>
                            <div class="prev-btn"><i class="mdi-navigation-chevron-left"></i></div>
                        </div>
                    ';
        $i++;
    }
    ?>
        </div>
<?php 
} else {
    $product = Product::getAllProducts(isset($_REQUEST['catid']) ? $_REQUEST['catid'] : Util::getCategoryStr(), isset($_REQUEST['q']) ? $_REQUEST['q'] : null, isset($_REQUEST['p']) ? $_REQUEST['p'] : null, isset($_REQUEST['rt']) ? $_REQUEST['rt'] : null, isset($_REQUEST['ra']) ? $_REQUEST['ra'] : null, isset($_REQUEST['os']) ? $_REQUEST['os'] : null);
    if ($product != null) {
        echo '
                <a href="#" class="cat-title common">';
        if (isset($_REQUEST['q'])) {
            echo '
                        Showing search results for \'' . $_REQUEST['q'] . '\'
                        <span>' . $product['count'] . ' result';
            if ($product['count'] == 1) {
                echo ' found</span>';
            } else {
                echo 's found</span>';
            }
        } else {
            if (isset($product['catname'])) {
                echo $product['catname'];
Example #5
0
<?php

require_once '../autoloader.php';
if (!isset($_SESSION['admin'])) {
    header("Location: admin_log.php");
}
$products = Product::getAllProducts();
?>
<!DOCTYPE html>
<html>
<head>
    <script src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script src="/js/sweetalert.min.js"></script>
    <link rel="stylesheet" type="text/css" href="/styles/sweetalert.css">
</head>
<body>
<div>
    <a href="index.php">Back to Index</a>
    <table>
        <tr>
            <th>Product Id</th>
            <th>Title</th>
            <th>Description</th>
            <th>Language</th>
            <th>Price</th>
            <th></th>
        </tr>
        <?php 
foreach ($products as $product) {
    $pid = $product->getId();
    $title = $product->getTitle();
 public function actionCheckout()
 {
     $products = Product::getAllProducts();
     $this->render('checkout', array('products' => $products));
 }
    // grab the mySQL connection
    $pdo = connectToEncryptedMySql("/etc/apache2/capstone-mysql/invtext.ini");
    $message = <<<EOF
\t\t<h1>Low Inventory Report</h1>
\t\t<p>Dear Customer <br/> This is your low inventory report for the week</p>
\t\t<table id="emailReportTable" class="table table-bordered table-hover table-striped">
\t\t\t\t<thead>
\t\t\t\t\t<tr>
\t\t\t\t\t\t<th>Title</th>
\t\t\t\t\t\t<th>Quantity</th>
\t\t\t\t\t\t<th>Vendor</th>
\t\t\t\t\t</tr>
\t\t\t\t</thead>
\t\t\t\t<tbody>
EOF;
    $allProducts = Product::getAllProducts($pdo, 0);
    foreach ($allProducts as $product) {
        $numberOfProducts = 0;
        // Make an array of product location from the above product
        $productLocations = ProductLocation::getProductLocationByProductId($pdo, $product->getProductId());
        foreach ($productLocations as $productLocation) {
            $numberOfProducts = $numberOfProducts + $productLocation->getQuantity();
        }
        // check if levels trigger notification according to alert operator
        $productAlerts = ProductAlert::getProductAlertByProductId($pdo, $product->getProductId());
        foreach ($productAlerts as $productAlert) {
            $alertLevel = AlertLevel::getAlertLevelByAlertId($pdo, $productAlert->getAlertId());
            if ($alertLevel->getAlertOperator() === "<" && $numberOfProducts < $alertLevel->getAlertPoint() || $alertLevel->getAlertOperator() === ">" && $numberOfProducts > $alertLevel->getAlertPoint()) {
                // give warning
                $productTitle = $product->getTitle();
                $vendor = Vendor::getVendorByVendorId($pdo, $product->getVendorId());