Пример #1
0
$app->get('/shiningfloor/sizes', function () use($app, $db) {
    $product_sizes = array();
    $query = $db->products()->group('product_size');
    foreach ($query as $product) {
        if ($product['product_size'] != "") {
            $product_sizes[] = $product['product_size'];
        }
    }
    $app->response()->header('content-type', 'application/json');
    echo json_encode(array('sizes' => $product_sizes));
});
$app->get('/shiningfloor/products/allsellers(/:product_id)', function ($product_id = null) use($app, $db) {
    $data = array();
    $minimum_price_per_item = 1000000000;
    $minimum_price_seller = 0;
    $minimum_bill = 0;
    $sellers = array();
    foreach ($db->sellers_products()->where('products_id', $product_id) as $p) {
        # code...
        $sellers[] = array('seller_id' => $p['sellers_id'], 'seller_price' => $p['price'], 'seller_minimum_boxes' => $p['minimum_boxes'], 'seller_price_per_item' => $p['price'] / $p['items_per_box'], 'seller_minimum_accept_bill' => $p['price'] * $p['minimum_boxes']);
        if ($p['price'] / $p['items_per_box'] < $minimum_price_per_item) {
            $minimum_price_seller = $p['sellers_id'];
            $minimum_price_per_item = $p['price'] / $p['items_per_box'];
            $seller_minimum_accept_bill = $p['price'] * $p['minimum_boxes'];
        }
    }
    $app->response()->header('content-type', 'application/json');
    echo json_encode(array('minimum_price_seller_id' => $minimum_price_seller, 'minimum_price_per_item' => $minimum_price_per_item, 'seller_minimum_accept_bill' => $seller_minimum_accept_bill, 'product_sellers' => $sellers));
    //    echo $minimum_price_seller .' '.$minimum_price_per_item;
});
$app->run();
Пример #2
0
     $colorFilters = explode(',', $_GET['color']);
 }
 if (isset($_GET['price_range'])) {
     $priceFilters = explode(',', $_GET['price_range']);
 }
 if (isset($_GET['brand_name'])) {
     $brandFilters = explode(',', $_GET['brand_name']);
 }
 if (isset($_GET['finish_types'])) {
     $finishTypeFilters = explode(',', $_GET['finish_types']);
 }
 if (isset($_GET['applications'])) {
     $applicationFilters = explode(',', $_GET['applications']);
 }
 $query = '';
 $query = $db->products()->where("NOT id", $db->sellers_products()->where('sellers_id', $id)->select('products_id'));
 if (isset($_GET['category'])) {
     $type_id = $db->types()->where('type_name', $_GET['category'])->select('id');
     $query = $query->where('type_id', $type_id);
     //            echo $query;
 }
 if (isset($_GET['query'])) {
     $query = $query->where('product_name LIKE ?', "%" . $_GET['query'] . "%");
 }
 if (isset($_GET['price_range'])) {
     $q = '';
     for ($i = 0; $i < sizeof($priceFilters); $i++) {
         if ($i > 0) {
             $q .= ' OR ';
         }
         if ($priceFilters[$i] == 'below-100') {
Пример #3
0
            //          'status' => $p->deposits["status"]
            //     );
            // }
            $data = array('product_id' => $products['id'], 'product_name' => $products['name'], 'product_category' => $products['category'], 'product_brand' => $products['brand'], 'product_applicationarea' => $products['applicationarea'], 'product_image' => $products['image'], 'product_finish' => $products['finish'], 'product_size' => $products['size'], 'product_url' => $products['productpageurl']);
        }
    }
    $products = array('aaData' => array('data' => $data, 'totalresults' => $count));
    $app->response()->header('content-type', 'application/json');
    echo json_encode($products);
});
$app->get('/selectedproducts(/:id)', function ($id = null) use($app, $db) {
    $per_page = 30;
    //define how many games for a page
    $page = $_GET['page'];
    $data = array();
    $query = $db->sellers_products()->where('sellers_id', $id);
    $count = count($query);
    $start = ($page - 1) * $per_page;
    $query = $query->limit($per_page, $start);
    foreach ($query as $products) {
        $data[] = array('product_id' => $products->products['id'], 'product_name' => $products->products['name'], 'product_category' => $products->products['category'], 'product_brand' => $products->products['brand'], 'product_applicationarea' => $products->products['applicationarea'], 'product_image' => $products->products['image'], 'product_finish' => $products->products['finish'], 'product_size' => $products->products['size'], 'product_url' => $products->products['productpageurl'], 'product_price' => $products['price'], 'product_comments' => $products['comments']);
    }
    $products = array('aaData' => array('data' => $data, 'totalresults' => $count));
    $app->response()->header('content-type', 'application/json');
    echo json_encode($products);
});
$app->get('/chooseproducts(/:id)', function ($id = null) use($app, $db) {
    global $connection;
    $per_page = 30;
    //define how many games for a page
    $page = $_GET['page'];