Example #1
0
 public function testGetProducts()
 {
     $params = array('title' => 'My test post is here', 'content_type' => 'post', 'subtype' => 'product', 'is_active' => 1);
     //saving
     $new_page_id = save_content($params);
     $get_pages = get_products($params);
     $page_found = false;
     if (is_array($get_pages)) {
         foreach ($get_pages as $page) {
             if ($page['id'] == $new_page_id) {
                 $page_found = true;
                 $this->assertEquals('post', $page['content_type']);
                 $this->assertEquals('product', $page['subtype']);
             }
             //PHPUnit
             $this->assertEquals(true, intval($page['id']) > 0);
         }
     }
     //clean
     $delete_sub_page = delete_content($new_page_id);
     //PHPUnit
     $this->assertEquals(true, $page_found);
     $this->assertEquals(true, intval($new_page_id) > 0);
     $this->assertEquals(true, is_array($get_pages));
     $this->assertEquals(true, is_array($delete_sub_page));
 }
function get_table()
{
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    $conn = mysqli_connect("localhost", "root", "", "consimentweb_sql");
    if (!$conn) {
        echo "Error: ";
    }
    //create table
    $table_str = '<table id="product_table">';
    $table_str .= "<tr>";
    $table_str .= '<th>Image</th><th>Name</th><th>Price</th><th>Date</th><th>Detail</th>';
    $table_str .= "</tr>";
    $products = get_products();
    $pic = "";
    $class = "article current";
    $all = count($products);
    $pad = ceil($all / 4);
    foreach ($products as $product) {
        $query = "select * from con_photo where {$product->P_ID}=con_photo.p_id limit 1";
        $data = mysqli_query($conn, $query);
        $pic = mysqli_fetch_array($data, MYSQLI_ASSOC);
        $table_str .= "<tr>";
        $table_str .= '<td width="20%" height="100px"><center><img src="images/' . $pic["PHOTO"] . '"></center></td>
					<td><center>' . $product->P_NAME . '</center></td>
					<td><center>' . $product->PRICE . '<center></td>
					<td><center>' . $product->START_DATE . '<center></td>
					<td><div style="cursor: pointer;" class="' . $class . '"><center>View detail</center></div>
		<div class="pop">
			<div style="position:absolute; width:50%; height:100%; left:0px; top:0px;";>
    			<div style="position:relative; top:25%; left:10%; border-style: solid; border-width: 1px; width:80%; height:50%;">
					<img src="#" style="width:100%; height:100%;">
				</div>
			</div>
    		<div style="position:absolute; width:50%; height:100%; right:0px; top:0px;">
            	<div style="height:15%; width:200%; border-style:solid; border-width:1px; margin-left:-100%;">' . $product->P_ID . '
            	</div>
            	<div style="height:30%; width:100%; border-style: solid; border-width: 1px;">
                	<div style="margin:5%; border-style: solid; border-width:1px; word-wrap:break-word;">' . $product->P_NAME . $product->PRICE . $product->START_DATE . $pic["PHOTO"] . '</div>		
				</div>
            	<div style="height:55%; width:100%; border-style: solid; border-width: 1px;">
                	<div style="margin:5%; border-style: solid; border-width:1px; word-wrap:break-word;">' . $product->DETAIL . '</div>
					
				  <div style="position:absolute; bottom: 2vh;right: 2vw;"><a href="create_transaction.php?P_ID=' . $product->P_ID . '">BUY</a></div>
				</div>
			</div>
    	</div>
		</td>';
        $table_str .= '</tr>';
        $class = "article";
    }
    $table_str .= '</table><div class="padding">';
    for ($b = 1; $b <= $pad; $b++) {
        $table_str .= '<a href="show_list_product_sql.php?page=' . $b . '" style="text-decoration:none ">' . $b . ' </a>';
    }
    $table_str .= '</div><div id="pop_close">X</div>';
    ////////////////////////////////////////////////////////////////////////////////////////////////////////
    mysqli_close($conn);
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////
    return $table_str;
}
Example #3
0
function get_table()
{
    $table_str = '';
    $Product = get_products();
    foreach ($Product as $product) {
        $table_str .= '' . $product->product_name;
    }
    return $table_str;
}
Example #4
0
function save_page_data($page, $sort, $per_page)
{
    $cache_key = build_cache_key($page, $sort);
    $result = get_cache($cache_key);
    if (!$result) {
        $data = get_products($page, $per_page, true);
        $ids = '';
        foreach ($data as $product) {
            $ids .= $product[0] . ',';
        }
        set_cache($cache_key, substr($ids, 0, -1));
    }
}
Example #5
0
function get_page_data()
{
    if (isset($_GET['page'])) {
        $page = $_GET['page'] - 1;
    } else {
        $page = 0;
    }
    $data['products'] = get_products($page, PER_PAGE);
    $data['pagination']['total'] = ceil(get_count_product() / PER_PAGE);
    $data['pagination']['page'] = $page + 1;
    prepare_response($data);
    return $data;
}
Example #6
0
function normalView()
{
    echo '<p>Click on some of the filters to alter your query.</p>';
    echo '<table width="100%">
		<tr>
			<td style="width:20%;vertical-align:top;">';
    get_questions();
    echo '</td>
			<td style="vertical-align:top;">';
    get_products();
    echo '</td>
		</tr>
	</table>';
}
Example #7
0
function get_table()
{
    //create table
    $products = get_products();
    $table_str = '<table id="t1">';
    $table_str .= '<thead>';
    $table_str .= '<tr>';
    $table_str .= '<th>Nombre del Evento</th>';
    $table_str .= '<th>Descripción</th>';
    $table_str .= '<th>Lugar</th>';
    $table_str .= '<th>Fecha de Inicio</th>';
    $table_str .= '<th>Fecha de Final</th>';
    $table_str .= '<th id="thButtons">Crear Evento</th>';
    $table_str .= '<th id="thButtons"><a href="CrearEvento.php"><button class="addButton"></button></a></td>';
    $table_str .= '</tr>';
    $table_str .= '</thead>';
    $table_str .= '<tbody>';
    foreach ($products as $product) {
        $table_str .= '<tr>';
        $table_str .= '<td>' . $product->Nombre . '</td>';
        $table_str .= '<td>' . $product->Descripcion . '</td>';
        $table_str .= '<td>' . $product->Lugar . '</td>';
        $table_str .= '<td>' . $product->FechaInicio . '</td>';
        $table_str .= '<td>' . $product->FechaFinal . '</td>';
        $table_str .= '<td id="tdButtons"><button class="editButton"></button></td>';
        $table_str .= '<td id="tdButtons"><button class="deleteButton onclick="deleteFromDB()"></button></td>';
        $table_str .= '</tr>';
    }
    $table_str .= '</tbody>';
    $table_str .= '<tfoot>';
    $table_str .= '<tr>';
    $table_str .= '</tr>';
    $table_str .= '</tfoot>';
    $table_str .= '</table>';
    return $table_str;
}
function get_table()
{
    //create table in HTML
    $table_str = '<table id=product_table>';
    $products = get_products();
    $i = 1;
    $table_str .= '<tr class="head_table">';
    $table_str .= '<th>DeviceId</th><th>TimeStamp</th><th>Action</th><th>Value</th>';
    $table_str .= '</tr>';
    foreach ($products as $product) {
        $class = '';
        if ($i % 2 == 0) {
            $class = 'row_even';
        } else {
            $class = 'row_odd';
        }
        $table_str .= '<tr class="' . $class . '">';
        $table_str .= '<td width=30>' . $product['My_DeviceId'] . '</td><td>' . $product['My_TimeStamp'] . '</td><td>' . $product['My_Action'] . '</td><td>' . $product['My_Value'] . '</td>';
        $table_str .= '</tr>';
        $i++;
    }
    $table_str .= '</table>';
    return $table_str;
}
Example #9
0
/**
 * Looks for products using a keyword
 */
function find_products($keyword)
{
    return get_products();
}
Example #10
0
<?php

//type of request
//1: get description of product
//2: delete product
//3: edit price
$cmd = $_REQUEST['cmd'];
switch ($cmd) {
    case 1:
        get_products($_REQUEST['id']);
        break;
    case 2:
        delete_product($_REQUEST['id']);
        break;
    default:
}
function get_products($id)
{
    include "products.php";
    $obj = new products();
    $row = $obj->get_product($id);
    //return a JSON string to browser when request comes to get description
    echo '{"result":1,"desc":"' . $row['description'] . '"}';
}
function delete_product($id)
{
    include "products.php";
    $obj = new products();
    if ($obj->delete($id)) {
        echo '{"result":1,"message": "deleted"}';
    } else {
            if (preg_match('#\\d{7}#', $match[1], $matches)) {
                if (array_key_exists('0', $matches)) {
                    $skus[] = $matches[0];
                }
            }
        }
    }
    return $skus;
}
// Include the library.
require 'scraperwiki/simple_html_dom.php';
// The base URL.
$base_url = "http://techmanual.yakima.com/";
$allowed_tags = "<br>,<strong>,<b>";
$active_skus = get_products("active");
$discontinued_skus = get_products("discontinued");
process_data($active_skus, 1);
process_data($discontinued_skus, 0);
// To process the data.
function process_data($skus, $avail = 1)
{
    global $allowed_tags;
    if (!empty($skus) && is_array($skus)) {
        foreach ($skus as $sku) {
            // Get the description.
            $description = strip_tags(get_description($sku), $allowed_tags);
            // Add it to an array.
            $record = array('sku' => $sku, 'avail' => $avail, 'desc' => $description);
            // Add it to the table.
            scraperwiki::save_sqlite(array('sku'), array($record), "techmanual", 2);
        }
Example #12
0
<?php

include_once 'db.php';
if (isset($_GET['id']) && count($_POST) > 0) {
    $changes = $_POST;
    foreach ($changes as $key => $value) {
        $changes[$key] = htmlspecialchars($value);
    }
    $changes['id'] = $_GET['id'];
    change_product($db, $changes);
}
$items = get_products($db);
include_once 'table.php';
if (isset($_GET['id'])) {
    $item = get_product($db, $_GET['id']);
    include_once 'form.php';
}
Example #13
0
<?php

$products = get_products($db);
include_once 'views/head.php';
include_once 'views/header.php';
?>
<main>
    <div class="container">
        <div class="banner"></div>
        <div class="row clearfix">
            <!-- боковое меню -->
            <?php 
include_once 'views/category_menu.php';
?>
            <div class="column column9">
                <div class="catalog">
                    <div class="row clearfix">
                    <!-- элементы каталога -->
                        <?php 
foreach ($products as $product) {
    include 'views/_product.php';
}
?>
                    </div>
                </div>
            </div>
        </div>
    </div>
</main>
<?php 
include_once 'views/footer.php';
Example #14
0
        $result['gebinde_dreiviertel'] = $gebinde_dreiviertel;
        $result['gebinde_liter'] = $gebinde_liter;
        $results[] = $result;
        $result = array();
    }
    if (count($results) == 0) {
        $results = False;
    }
    $stmt->free_result();
    $db->close();
    return $results;
}
$results = get_products();
if ($results == False) {
    $_GET['kategorie'] = "rotwein";
    $results = get_products();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/default.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="Das Weinhaus Michel ist eine gemütliche Weinstube mit Gewölbekeller und Straßenterrasse mitten in der Altstadt von Mainz." />
<meta name="keywords" content="Weinhaus, Weinstube, Michel, Stefan, Weingut in Weinolsheim, Mainz, Altstadt, Weinanbau, Weinverkauf, Essen und Trinken, Warme K&uuml;che, Rheinhessische Spezialit&auml;ten, Gew&ouml;lbekeller, Veranstaltungen, Gesellschaften, Stra&szlig;enlokal, Terrasse, Raummiete, Weihnachtsfeier, Reservierungen, Weinbestellung, Fastnacht" />
<meta name="robots" content="index,follow" />
<meta name="language" content="de" />
<meta name="city" content="Mainz" />
<meta name="country" content="DE, Deutschland, Germany" />
<title>Weinhaus Michel – Seitentitel</title>
<link href="../style/default.css" rel="stylesheet" type="text/css" />
<link href="../favicon.ico" rel="shortcut icon" />
Example #15
0
<?php

require_once 'Slim/Slim.php';
require_once 'Lite/Lite.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
$app->get('/api/products', function () {
    echo json_encode(get_products());
});
$app->get('/api/products/:pids', function ($pids) {
    echo json_encode(get_products($pids));
});
$app->post('/api/sync', function () {
    echo json_encode(sync_products());
});
$app->post('/api/sync/vendor/:vid', function ($vid) {
    echo json_encode(sync_products($vid, NULL));
});
$app->post('/api/sync/channel/:cid', function ($cid) {
    echo json_encode(sync_products(NULL, $cid));
});
$app->post('/api/sync/vendor/:vid/channel/:cid', function ($vid, $cid) {
    echo json_encode(sync_products($vid, $cid));
});
$app->run();
Example #16
0
    $function = $_GET['function'];
    $values = $_GET;
} else {
    $values = file_get_contents('php://input');
    $values = (array) json_decode($values);
    $function = $values['function'];
}
switch ($function) {
    case 'add_product':
        include_once __DIR__ . '/products/add_product.php';
        $responseArray['response'] = add_product($values);
        $responseArray['message'] = 'Successfully added product';
        break;
    case 'get_products':
        include_once __DIR__ . '/products/get_products.php';
        $responseArray['response'] = get_products($values);
        $responseArray['message'] = 'Products successfully read';
        break;
    case 'update_product':
        include_once __DIR__ . '/products/update_product.php';
        update_product($values);
        $responseArray['message'] = 'Product successfully updated';
        break;
    case 'add_product_class':
        include_once __DIR__ . '/products/add_product_class.php';
        add_product_class($values);
        $responseArray['message'] = 'Class successfully added';
        break;
    case 'get_product_classes':
        include_once __DIR__ . '/products/get_product_classes.php';
        $responseArray['response'] = get_product_classes($values);
function get_term_children_num($tax, $term)
{
    $products = get_products($tax, $term, -1);
    return $products->post_count;
}
Example #18
0
<?php

include 'view_block/header.php';
include 'data/data.php';
//var_dump(get_products());
$catalogue = get_products();
?>
<div class="container">
    <div class="col-md-12">

        <div class="center-block text-center">
            <h1>AFRICANSTYLE</h1>
            <p class="lead">VENTE DE VETEMENTS</p>
        </div>

        <div class="container">
            <div class="menu row">
                <div class="product col-sm-12">

                    <div class="product col-lg-12"></div>
                        <div class="product col-lg-12 text-center">
                            <hr>
                            <h2>AFRICAN STYLE</h2>
                            <p></p>
                            <hr>
                            <h2 class="text-right"></h2>
                        </div>

                        <div class="product col-lg-12">
                            <?php 
foreach ($catalogue as $k => $list) {
$ids = !$ids ? $id : $ids . $id;
/*=========Пагинация==========*/
// кол-во товаров на страницу
$perpage = isset($_COOKIE['per_page']) && (int) $_COOKIE['per_page'] ? $_COOKIE['per_page'] : PERPAGE;
// общее кол-во товаров
$count_goods = count_goods($ids);
// необходимое кол-во страниц
$count_pages = ceil($count_goods / $perpage);
// минимум 1 страница
if (!$count_pages) {
    $count_pages = 1;
}
// получение текущей страницы
if (isset($_GET['page'])) {
    $page = (int) $_GET['page'];
    if ($page < 1) {
        $page = 1;
    }
} else {
    $page = 1;
}
// если запрошенная страница больше максимума
if ($page > $count_pages) {
    $page = $count_pages;
}
// начальная позиция для запроса
$start_pos = ($page - 1) * $perpage;
$pagination = pagination($page, $count_pages);
/*=========Пагинация==========*/
$products = get_products($ids, $start_pos, $perpage);
include VIEW . "{$view}.php";
<?php

if (!isset($_GET['cmd'])) {
    exit;
}
switch ($_GET['cmd']) {
    case 0:
        get_products();
        break;
    case 1:
        transaction();
        break;
    default:
        break;
}
function get_products()
{
    include_once 'product.php';
    $obj = new product();
    if (!$obj->connect()) {
        $json = '{"status":2, "products":{}}';
        echo $json;
        exit;
    }
    if ($obj->get_products()) {
        $row = $obj->fetch();
        $length = $obj->get_num_rows();
        //            Products as a set
        $json = '{"status":0, "products":{';
        for ($i = 0; $i < $length; $i++) {
            $bcode = $row['PRODUCT_BARCODE'];
<?php

session_start();
if (!isset($_SESSION['imonggo_api_token'])) {
    header('Location:login.php');
}
include 'post_get.php';
//Gets products available on-hand
$inventories = array_filter(get_inventories());
//Gets tags for checkbox creation
$get_output = get_products();
$response = $get_output[0];
$tags = $get_output[1];
if (isset($_GET['post_products'])) {
    if (!empty($inventories)) {
        $post_tags = $_GET['checkbox_name'];
        post_products($response, $post_tags, $inventories);
    } else {
        $error_msg = "Error: No product available";
        echo $error_msg;
    }
    if (isset($_GET['post_all_products'])) {
        if (!empty($inventories)) {
            get_all_products($inventories);
        } else {
            $error_msg = "Error: No product available";
            echo $error_msg;
        }
    }
} elseif (isset($_GET['pull_customers'])) {
    get_customers();
Example #22
0
				dol_syslog("products.inc.php::get_new_products rien � faire", LOG_DEBUG);
				$last = 0;
			}
		}
		else
		{
			dol_syslog("products.inc.php::get_new_products erreur ".$sql, LOG_DEBUG);
			return -1;

		}
		
		// 1. recherche des nouveaux porduits		
		if ($res = get_new_products($siteid,$db, $user, $limit) < 0) print "Erreur traitement des produits �tape 1"."\n";
		else 	print "fin �tape 1 d�but �tape 2"."\n";
		// on fait les deux traitements syst�matiquement
		if ($res = get_products($siteid, $db, $user, $limit, $last)) print "traitement produit r�ussi $last $limit"." \n";
			else print "Erreur traitement des produits $last $limit"."\n";
		
		break;
	case 'prospect':
		print "traitement des prospects\n";
		
		// traitement de la limite
		if (! isset($argv[3])) $limit = 0;
		elseif ($argv[3] > 0 ) $limit = $argv[3];
		else $limit = 100; // on limite
		
		// pour ne pas re-traiter les prospects 
		$sql = "SELECT max(ecom_customer) last FROM ".MAIN_DB_PREFIX."ecom_customer ec ";
		$sql .= "WHERE ec.siteid = '".$siteid."' AND ec.site_cust_status = 'P'";
	
Example #23
0
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    $product_list = array();
    $sql = "SELECT name, price, description, category FROM products";
    $result = $conn->query($sql);
    echo $conn->error;
    if ($result->num_rows > 0) {
        while ($row = $result->fetch_assoc()) {
            $product = array("Name" => $row["name"], "Price" => $row["price"], "Desc" => $row["description"], "Category" => $row["category"]);
            array_push($product_list, $product);
        }
    }
    return $product_list;
}
$products = get_products();
?>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta charset="utf-8" />
    <link rel="stylesheet" type="text/css" href="style.css" />
    <title>cs3140 Final Project</title>
  </head>
  <body>
    <div id="header">
      <h1>ROASTED</h1>
    </div>
    <?php 
include 'navbar.php';
?>
    <div id="main">
Example #24
0
require '../model/registration_db.php';
require '../model/product_db.php';
$action = filter_input(INPUT_POST, 'action');
if ($action == 'login') {
    $email = filter_input(INPUT_POST, 'email');
    if ($email == NULL || $email == FALSE) {
        include '../product_register/customer_login.php';
    } else {
        $login = get_customer_by_email($email);
        if ($login['customerID'] == NULL || $login['customerID'] == FALSE) {
            $message = 'Invalid Username';
            include '../product_register/product_register.php';
        } else {
            $first = $login['firstName'];
            $last = $login['lastName'];
            $list = get_products();
            include '../product_register/product_register.php';
        }
    }
} else {
    if ($action == 'add_registration') {
        $product_code = filter_input(INPUT_POST, 'product_code');
    }
}
/* 
 * What you will need
 *   1. The product_register application should default to the customer_login view
 *   2. If the email address is not provided, make them enter one
 *   3. Check if the email entered is valid, if so get the user information from 
 *       the database
 *   4. Send the logged-in user to the product registration page
Example #25
0
<?php

include 'model.php';
include 'functions.php';
echo embed('tpl/home.tpl.php', array('header' => embed('tpl/header.tpl.php', array()), 'sidebar_first' => embed('tpl/category.tpl.php', array('result' => get_category())), 'body' => embed('tpl/allproduct.tpl.php', array('result' => get_products())), 'sidebar_second' => embed('tpl/top_last_added.tpl.php', array('result' => last_added()))));
Example #26
0
<?php

require '../model/database.php';
require '../model/product_db.php';
if (isset($_POST['action'])) {
    $action = $_POST['action'];
} else {
    if (isset($_GET['action'])) {
        $action = $_GET['action'];
    } else {
        $action = 'display_all';
    }
}
if ($action == 'display_all') {
    $all_products = get_products();
    include 'product_list.php';
} else {
    if ($action == 'delete_record') {
        $product_item = $_POST['product_item'];
        delete_product($product_item);
        header('Location: .');
    } else {
        if ($action == 'add_record') {
            $product_item = $_POST['product_item'];
            $name = $_POST['name'];
            $version = $_POST['version'];
            $release_date = $_POST['release_date'];
            if (empty($product_item) || empty($name) || empty($version) || empty($release_date)) {
                $error = "Invalid product data. Check all fields and try again.";
                header("Location: .?error={$error}");
            } else {
Example #27
0
						<form id="addproduct-form" onsubmit="return submitCreateProduct()" method="post">
							code: <input type="text" name="code" id="code"><br>
							description: <input type="text" name="description" id="description">
							price: <input type="number" name="price" id="price">
							type: <input type="text" name="type" id="type">
							<input type="submit" id="login-btn">
						</form>
					</div>
					<div id="login-info">
						<p>Products:</p>
					</div>
<div>
<?php 
include "../controllers/get_products.php";
$products = array();
$products = (array) get_products();
echo "<table border=\"1\">";
echo "<tr>";
echo "<th>Code</th>";
echo "<th>Description</th>";
echo "<th>Price</th>";
echo "<th>Unit desc</th>";
echo "<th>Unit abbrev</th>";
echo "<th>Class</th>";
echo "<th>Class desc</th>";
echo "</tr>";
foreach ($products as $p) {
    echo "<script>console.log(" . json_encode($p) . ")</script>";
    echo "<tr>";
    echo "<td>" . $p['prod_code'] . "</td>";
    echo "<td>" . $p['prod_desc'] . "</td>";
Example #28
0
    $result = mysql_fetch_array($query);
    return $result;
}
function get_filtered($post_product_id, $post_filter_id)
{
    $conn = connDB();
    $sql = "SELECT COUNT(*) AS rows FROM tbl_filter_item WHERE `filter_param` = '{$post_filter_id}' AND `product_param` = '{$post_product_id}'";
    $query = mysql_query($sql, $conn);
    $result = mysql_fetch_array($query);
    return $result;
}
// DEFINED VARIABLE
$ajx_alias = $_POST['alias'];
// CALL FUNCTIONS
$filter = get_filter();
$data_product = get_products($ajx_alias);
?>
            <span id="id_filter_container">
            
              <div class="box row">
                <div class="desc col-xs-3">
                  <h3>Filter</h3>
                  <p>Manage filter.</p>
                </div>
                
                <div class="content col-xs-9">
                  <ul class="form-set">
                    <li class="form-group row">
                      
					  <?php 
foreach ($filter as $filter) {
Example #29
0
     echo get_company_review($_GET);
 } else {
     if (strpos($uri, '/add_review_company') !== false) {
         echo add_company_review($_POST);
     } else {
         if (strpos($uri, '/get_account') !== false) {
             echo get_account($_GET);
         } else {
             if (strpos($uri, '/components') !== false) {
                 echo get_components($_GET);
             } else {
                 if (strpos($uri, '/documents') !== false) {
                     echo get_documents($_GET);
                 } else {
                     if (strpos($uri, '/products') !== false) {
                         echo get_products($_GET);
                     } else {
                         if (strpos($uri, '/add_to_project') !== false) {
                             echo add_to_project($_POST);
                         } else {
                             if (strpos($uri, '/remove_from_project') !== false) {
                                 echo remove_from_project($_POST);
                             } else {
                                 if (strpos($uri, '/uploadServiceImage') !== false) {
                                     echo upload_service_image($_POST, $_FILES);
                                 } else {
                                     if (strpos($uri, '/upload') !== false) {
                                         echo upload_document($_POST, $_FILES);
                                     } else {
                                         if (strpos($uri, '/create_discussion') !== false) {
                                             echo create_discussion($_POST);
Example #30
0
function add_item($key, $quantity)
{
    global $db;
    $products = get_products();
    if ($quantity < 1) {
        return;
    }
    // If item already exists in cart, update quantity
    if (isset($_SESSION['cart'][$key])) {
        $quantity += $_SESSION['cart'][$key]['qty'];
        update_item($key, $quantity);
        return;
    }
    $cost = $products[$key]['Price'];
    $total = $cost * $quantity;
    $item = array('Plant_Name' => $products[$key]['Plant_Name'], 'Price' => $cost, 'qty' => $quantity, 'total' => $total);
    $_SESSION['cart'][$key] = $item;
}