From: Hugo Villeneuve Date: Mon, 20 Jan 2014 17:24:23 +0000 (-0500) Subject: Add option to specify number of cards/kits for digikey BOM submission X-Git-Url: http://gitweb.hugovil.com/?a=commitdiff_plain;h=31c17d4b984b719aa552055cb63f33cfc9af8767;p=eda-utils.git Add option to specify number of cards/kits for digikey BOM submission --- diff --git a/bomgen/Bomgen/digikey.inc.php b/bomgen/Bomgen/digikey.inc.php index 0591315..731dc1d 100644 --- a/bomgen/Bomgen/digikey.inc.php +++ b/bomgen/Bomgen/digikey.inc.php @@ -14,7 +14,7 @@ define("CUSTOMER_REFERENCE_COL_NAME", COMPANY_PN_COL_NAME); /* Exportation BOM digikey. */ function export_bom_digikey(&$data, $num, $col_num_to_id, $col_id_to_num, $filename) { - global $debug; + global $debug, $kits; $handle = fopen($filename, "w"); @@ -24,7 +24,7 @@ function export_bom_digikey(&$data, $num, $col_num_to_id, $col_id_to_num, $filen for ($c = 0; $c < $num; $c++) { if (isset($col_num_to_id[$c])) { if ($col_num_to_id[$c] == QTY_COL_NAME) { - $qty = $row[$c]; + $qty = $kits * $row[$c]; /* Multiply unit cost by number of kits to assemble. */ } else if ($col_num_to_id[$c] == "Part Number") { $pn = $row[$c]; diff --git a/bomgen/bomgen.php b/bomgen/bomgen.php index 927abf0..81c21d6 100755 --- a/bomgen/bomgen.php +++ b/bomgen/bomgen.php @@ -21,6 +21,7 @@ require_once 'Bomgen/digikey.inc.php'; $debug = 0; $digikey_bom = false; +$kits = 1; define("DATA_ROW_START", 3); @@ -60,6 +61,8 @@ $csv_infos = "width" => 0), ); +$short_opts = "hckn:"; + function usage() { echo "Usage: bomgen.php [OPTIONS] [INPUT FILE]\n"; @@ -70,6 +73,7 @@ function usage() echo " -c Add cost information to the BOM\n"; echo " -k Create digikey BOM submission file (tab-separated fields)\n"; echo " -h Display this help and exit\n"; + echo " -n Number of cards/kits for digikey BOM submission\n"; } /* @@ -166,8 +170,6 @@ $add_cost = false; $comp_total = 0; $titre = "BOM"; -$short_opts = "hck"; - $cg = new Console_Getopt(); /* Read the command line. */ @@ -193,6 +195,9 @@ if (sizeof($opts) > 0) { case 'k': $digikey_bom = true; break; + case 'n': + $kits = $o[1]; + break; case 'h': usage(); exit(1);