global $bagid; $row = 1; if (($handle = fopen("bagdb.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); echo "<p> {$num} fields in line {$row}: <br /></p>\n"; $row++; // Skip blank rows if ($data[0] == '') { continue; } // Get title from CSV and Create Bag if ($row == 3) { $name = $data[0]; echo "Create Bag: " . $name . "<br/>"; $bagid = create_bag($name); if (!$bagid) { $bag = get_bag_by_name($name); $bagid = $bag['bagid']; } } // Skip Title Row if ($row < 4) { continue; } // Add Product to Bag (Create or Find Existing Product from inventory) import_bag_content($bagid, $data[0], $data[2], $data[3]); echo "Product: " . $data[0] . " | Quantity: " . $data[2] . " | Notes: " . $data[3] . "<br/>"; /* for ($c=0; $c < $num; $c++) { echo $data[$c] . "<br />\n";
<pre> <?php include_once 'include/config.inc.php'; include_once 'library/mysql.lib.php'; include_once 'library/inventory.lib.php'; include_once 'library/bag.lib.php'; include_once 'library/util.lib.php'; sql_wrap(); global $bagid; // Create Bags for Family Size 1 through 10 $bag_names = array('1' => 'Family of One', '2' => 'Family of Two', '3' => 'Family of Three', '4' => 'Family of Four', '5' => 'Family of Five', '6' => 'Family of Six', '7' => 'Family of Seven', '8' => 'Family of Eight', '9' => 'Family of Nine', '10' => 'Family of Ten'); $bag_ids = array(); for ($i = 1; $i <= 10; $i++) { $bag_id = create_bag($bag_names[$i], 'none'); // Create bag if (!$bag_id) { // if bag alreadt exists get its bag_id $bag = get_bag_by_name($bag_names[$i]); $bag_id = $bag['bagid']; } $bag_ids[$i] = $bag_id; // Store bagids } // Read in Every row from Distribution.csv // 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";
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; case 'bag': if (isset($action_command)) { switch ($action_command) { case 'new': create_bag(post('name')); exit; break; case 'save': edit_bag(post('bagid'), post('name')); //print_r($_POST); exit; break; default: redirect($g["abs_url"] . '/error/invalid-page'); } } else { redirect($g["abs_url"] . '/error/invalid-page'); } break; default:
$handle = opendir("bags/"); while (false != ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo "<a href='load_RD_bag.php?bagfile=" . $file . "'>" . $file . "</a><br/>"; } } exit; return; } echo "Import bagfile: " . $_GET['bagfile'] . "<br/>"; echo "Bag Name: " . substr($_GET['bagfile'], 0, -4) . "<br/>"; $path = 'bags/'; $filename = $_GET['bagfile']; //$filename = "Ristricted Diet Request family of three.csv"; // Get title from CSV filename and Create Bag $bagid = create_bag(substr($filename, 0, -4), 'none'); if (!$bagid) { $bag = get_bag_by_name($name); $bagid = $bag['bagid']; } $row = 1; if (($handle = fopen($path . $filename, "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); echo "<p> {$num} fields in line {$row}: <br /></p>\n"; $row++; // Skip Heads Rows if ($row < 4) { continue; } // Skip blank Product rows