コード例 #1
0
ファイル: bag.mod.php プロジェクト: mwcs01/openpantry
     switch ($action_command) {
         case 'new':
             create_bag_product(post('bid'), post('pid'), post('quantity'), post('choice'), post('notes'));
             exit;
             break;
         case 'save':
             edit_bag_content(post('bid'), post('pid'), post('quantity'), post('choice'), post('notes'));
             //print_r($_POST);
             exit;
             break;
         case 'delete':
             delete_bag_content(post('bagid'), post('productid'));
             exit;
             break;
         case 'add':
             $product = get_product_by_name(post('product_name'));
             if (!isset($product['productid'])) {
                 echo "NOT_SET";
             } else {
                 echo "SET";
                 create_bag_content(post('bagid'), $product['productid'], "0", '0', "");
             }
             exit;
             break;
         default:
             redirect($g["abs_url"] . '/error/invalid-page');
     }
 } else {
     redirect($g["abs_url"] . '/error/invalid-page');
 }
 break;
コード例 #2
0
ファイル: index.php プロジェクト: bonnyfrances/cit336
<?php

require 'util/main.php';
require 'model/database.php';
require 'model/product_db.php';
/*********************************************
 * Select some products
 **********************************************/
// Sample data
$product_name = 'Fender Telecaster';
// Sample data
$cat_id = 1;
// Get the products
$products = get_products_by_category($cat_id);
// Get a product by name
$product_by_name = get_product_by_name($product_name);
/***************************************
 * Delete a product
 ****************************************/
//print_r($product_by_name);
delete_product($product_by_name['productID']);
// Delete the product and display an appropriate messge
$delete_message = "No rows were deleted.";
/***************************************
 * Insert a product
 ****************************************/
// Sample data
$category_id = 1;
$code = 'hgjh';
$name = 'Blahblah';
$description = 'NA';
コード例 #3
0
// Create Products in Inventory
// Add their Quantity to Each Family Size Bag
$row = 1;
if (($handle = fopen("distribution.csv", "r")) !== FALSE) {
    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
        $num = count($data);
        echo "<p> {$num} fields in line {$row}: <br /></p>\n";
        $row++;
        // Skip title rows
        if ($row < 4) {
            continue;
        }
        echo "Create Product: " . $data[0] . "<br/>";
        $product_id = create_product($data[0], '0');
        if (!$product_id) {
            $product = get_product_by_name($data[0]);
            $product_id = $product['productid'];
        }
        for ($i = 1; $i <= 10; $i++) {
            $bag_id = $bag_ids[$i];
            $quantity = $data[$i];
            $choice = $data[11] == 'Y' ? '1' : '0';
            if ($quantity != '') {
                echo "Bag Name: " . $bag_names[$i] . " | BagID: " . $bag_id . " | Quantity: " . $quantity . "<br/>";
                create_bag_content($bag_id, $product_id, $quantity, $choice, '');
            }
        }
        /*
        		for ($c=0; $c < $num; $c++) {
                    echo $data[$c] . "<br />\n";
                }*/
コード例 #4
0
ファイル: bag.lib.php プロジェクト: mwcs01/openpantry
/** import bag information from csv version of the excel bag contents
 */
function import_bag_content($bagid, $name, $quantity, $notes, $choice)
{
    // Create product in inventory
    $productid = create_product($name, '');
    if (!$productid) {
        $product = get_product_by_name($name);
        $productid = $product['productid'];
    }
    echo "bag: " . $bagid . " product: " . $productid . " <br/>";
    create_bag_content($bagid, $productid, $quantity, $choice, $notes);
}