Skip to content

Commit

Permalink
WEFC item edit #2
Browse files Browse the repository at this point in the history
  • Loading branch information
flathat committed Mar 24, 2013
1 parent 122b259 commit 2215cbc
Show file tree
Hide file tree
Showing 8 changed files with 204 additions and 134 deletions.
2 changes: 2 additions & 0 deletions fannie/item/ajax.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
include('../config.php');

include($FANNIE_ROOT.'src/mysql_connect.php');

if (isset($_REQUEST['action'])){
Expand Down Expand Up @@ -81,4 +82,5 @@ function getSRP($cost,$margin){
return $srp;
}


?>
8 changes: 5 additions & 3 deletions fannie/item/insertItem_WEFC_Toronto.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*********************************************************************************/

/* --FUNCTIONALITY- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* These lines grepped in from this listing: !!grep "^/. [0-9]\." %
* These lines grepped in from this listing: !!grep "^/. [0-9]*\." %
*/
/* 1. Insert or update coop-specific product data */
/* 2. Replace likecode. */
Expand All @@ -31,8 +31,9 @@
/* 5. Insert to prodExtra */
/* 6. Insert to prodUpdate, an audit table. */
/* 7. Insert to scaleItem */
/* 8. Delete and re-add to product-related tables on the lanes. */
/* 9. Display the post-update values and an input for the next edit. */
/* 8. Delete and re-add to product-related tables on the lanes. */
/* 9. Display the post-update values and an input for the next edit. */
/* 10. If requested on the capture form, pop a window for making a shelf tag. */

/* --COMMENTS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
Expand Down Expand Up @@ -463,6 +464,7 @@

echo "</form>";

/* 10. If requested on the capture form, pop a window for making a shelf tag. */
if (isset($_REQUEST['newshelftag'])){
echo "<script type=\"text/javascript\">";
echo "testwindow= window.open (\"addShelfTag.php?upc=$upc\", \"New Shelftag\",\"location=0,status=1,scrollbars=1,width=300,height=220\");";
Expand Down
87 changes: 0 additions & 87 deletions fannie/item/itemMaint.php

This file was deleted.

1 change: 1 addition & 0 deletions fannie/item/itemMaint.php
91 changes: 91 additions & 0 deletions fannie/item/itemMaint_orig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php
/*******************************************************************************
Copyright 2005,2009 Whole Foods Community Co-op
This file is part of Fannie.
Fannie is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Fannie is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
in the file license.txt along with IT CORE; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*********************************************************************************/

include('prodFunction.php');
include('../config.php');
include('../src/mysql_connect.php');
$page_title = 'Fannie - Item Maintanence';
$header = 'Item Maintanence';
include('../src/header.html');

?>
<script type="text/javascript"
src="<?php echo $FANNIE_URL; ?>src/jquery-1.2.6.min.js">
</script>
<script type"text/javascript" src=ajax.js></script>
<script type="text/javascript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- John Munn ([email protected]) -->

function putFocus(formInst, elementInst) {
if (document.forms.length > 0) {
document.forms[formInst].elements[elementInst].focus();
}
}

function setPrice(p){
document.getElementById('price').value = p;
scroll(0,0);
}

<!-- The second number in the "onLoad" command in the body
// tag determines the form's focus. Counting starts with '0'
// End -->
</script>

<?php

if(isset($_POST['submit'])){
$upc = $_POST['upc'];

itemParse($upc);

}elseif(isset($_GET['upc'])){
$upc = $_GET['upc'];
itemParse($upc);

}else{

echo "<head><title>Edit Item</title></head>";
echo "<BODY onLoad='putFocus(0,0);'>";
echo "<form action=../item/itemMaint.php method=post>";
if ( isset($FANNIE_COOP_ID) && $FANNIE_COOP_ID == "WEFC_Toronto" ) {
echo "<p>Please use the <a href='itemMaint_WEFC_Toronto.php'>WEFC Toronto Editor</a></p>";
} else {
echo "<input name=upc type=text id=upc> Enter
<select name=\"ntype\">
<option>UPC</option>
<option>SKU</option>
<option>Brand Prefix</option>
</select> or product name here<br>";

echo "<input name=submit type=submit value=submit> ";
}
echo "</form>";
}

include ('../src/footer.html');

?>
87 changes: 52 additions & 35 deletions fannie/item/prodFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,54 +24,66 @@
*********************************************************************************/
// TODO -- Add javascript for batcher product entry popup window ~joel 2007-08-21

/* --COMMENTS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* 22Feb2013 Eric Lee Add support for editing
* products.quantity, .groupprice, .pricemethod, .mixmatchcode
* products.size, .unitofmeasure
* 10Feb2013 Eric Lee In itemParse add FANNIE_STORE_ID to globals.
*/


include_once('../src/mysql_connect.php');
include_once('../auth/login.php');
include_once('ajax.php');

function itemParse($upc){
global $dbc,$FANNIE_URL;
global $FANNIE_STORE_ID;
global $FANNIE_COOP_ID;

$logged_in = checkLogin();

$queryItem = "";
$numType = (isset($_REQUEST['ntype'])?$_REQUEST['ntype']:'UPC');
if(is_numeric($upc)){
switch($numType){
case 'UPC':
$upc = str_pad($upc,13,0,STR_PAD_LEFT);
$savedUPC = $upc;
$queryItem = "SELECT p.*,x.distributor,x.manufacturer
FROM products as p left join
prodExtra as x on p.upc=x.upc
WHERE (p.upc = '$upc' or x.upc = '$upc')
AND p.store_id=0";
break;
case 'SKU':
$queryItem = "SELECT p.*,x.distributor,x.manufacturer
FROM products as p inner join
vendorItems as v ON p.upc=v.upc
left join prodExtra as x on p.upc=x.upc
WHERE v.sku='$upc'
AND p.store_id=0";
break;
case 'Brand Prefix':
$queryItem = "SELECT p.*,x.distributor,x.manufacturer
FROM products as p left join
prodExtra as x on p.upc=x.upc
WHERE p.upc like '%$upc%'
AND p.store_id=0
ORDER BY p.upc";
break;
}
switch($numType){
case 'UPC':
$upc = str_pad($upc,13,0,STR_PAD_LEFT);
$savedUPC = $upc;
$queryItem = "SELECT p.*,x.distributor,x.manufacturer
FROM products as p left join
prodExtra as x on p.upc=x.upc
WHERE (p.upc = '$upc' or x.upc = '$upc')
AND p.store_id=0";
break;
case 'SKU':
$queryItem = "SELECT p.*,x.distributor,x.manufacturer
FROM products as p inner join
vendorItems as v ON p.upc=v.upc
left join prodExtra as x on p.upc=x.upc
WHERE v.sku='$upc'
AND p.store_id=0";
break;
case 'Brand Prefix':
$queryItem = "SELECT p.*,x.distributor,x.manufacturer
FROM products as p left join
prodExtra as x on p.upc=x.upc
WHERE p.upc like '%$upc%'
AND p.store_id=0
ORDER BY p.upc";
break;
}
}else{
/* note: only search by HQ records (store_id=0) to avoid duplicates */
$queryItem = "SELECT p.*,x.distributor,x.manufacturer
FROM products AS p LEFT JOIN
prodExtra AS x ON p.upc=x.upc
WHERE description LIKE '%$upc%'
AND p.store_id=0
ORDER BY description";
FROM products AS p LEFT JOIN
prodExtra AS x ON p.upc=x.upc
WHERE description LIKE '%$upc%'
AND p.store_id=0
ORDER BY description";
}
/* note: only search by HQ records (store_id=0) to avoid duplicates */
$resultItem = $dbc->query($queryItem);
$num = $dbc->num_rows($resultItem);

Expand Down Expand Up @@ -655,8 +667,13 @@ function itemParse($upc){
echo '</tr></table></fieldset>';

echo "<br /><fieldset id=marginfs>";
echo "<legend>Margin</legend>";
MarginFS($rowItem['upc'],$rowItem['cost'],$rowItem['department']);
if ( isset($FANNIE_COOP_ID) && $FANNIE_COOP_ID == "WEFC_Torontx" ) {
echo "<legend>Markup</legend>";
MarkupFS($rowItem['upc'],$rowItem['cost'],$rowItem['department']);
} else {
echo "<legend>Margin</legend>";
MarginFS($rowItem['upc'],$rowItem['cost'],$rowItem['department']);
}
echo "</fieldset>";

echo '<fieldset id="lanefs">';
Expand Down
12 changes: 7 additions & 5 deletions fannie/item/prodFunction_WEFC_Toronto.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ function itemParse($upc){
echo "testwindow.moveTo(50,50);";
echo "}";
echo "</script>";
echo "<script type='text/javascript' src='${FANNIE_URL}src/CalendarControl.js'></script>";

// 3. No match. Compose form for creation of a new item.
if($num == 0 || !$num){
Expand Down Expand Up @@ -461,10 +462,10 @@ function itemParse($upc){
echo "<table style='margin:0.0em 0.0em 0.0em 0.0em;'>";

echo "<tr><th align-right>Start Date</th>";
echo "<td><input type=text size=6 value='1900-01-01' name=start_date /></td>";
echo "<td><input type=text size=6 value='" . date('Y-m-d') . "' name=start_date onclick='showCalendarControl(this);' /></td>";

echo "</tr><tr><th align-right>End Date</th>";
echo "<td><input type=text size=6 value='1900-01-01' name=end_date /></td>";
echo "<td><input type=text size=6 value='" . date('Y-m-d') . "' name=end_date onclick='showCalendarControl(this);' /></td>";

echo "</tr><tr><th align-right>Sale for</th>";
// This should really be in the db and be per-coop-configurable.
Expand Down Expand Up @@ -885,7 +886,8 @@ function itemParse($upc){
"display:" . (array_search('Operations',$Fannie_Item_Modules) !== False?'block':'none') . ";'>";
echo "<fieldset><legend>Operations</legend>";
echo "<div style=\"float:left;\"><ul style='margin:0.0em 0.0em 0.0em 0.0em;'>";
echo "<li style='margin-left:-2.0em;'><a href=\"javascript:shelftag('$upc');\">New Shelf Tag</a></li>";
echo "<li style='margin-left:-2.0em;'><a href=\"javascript:shelftag('$upc');\" title='Using the un-edited data.' >Current Shelf Tag</a></li>";
echo "<li style='margin-left:-2.0em;'><input type=checkbox name=newshelftag title='Using the edited data, after you click Update.' /> <span title='Using the edited data, after you click Update.'>New Shelf Tag</span></li>";
echo "<li style='margin-left:-2.0em;'><a href=\"../reports/RecentSales/?upc=$upc\" target='_recentsales'>";
echo "Recent Sales<br /> History</a></li>";
//echo "</ul></div>";
Expand Down Expand Up @@ -981,10 +983,10 @@ function itemParse($upc){
echo "<table style='margin:0.0em 0.0em 0.0em 0.0em;'>";

echo "<tr><th align-right>Start Date</th>";
echo "<td><input type=text name=start_date size=6 value=\"{$rowItem['start_date']}\" /></td>";
echo "<td><input type=text name=start_date size=6 value=\"{$rowItem['start_date']}\" onclick='showCalendarControl(this);' /></td>";

echo "</tr><tr><th align-right>End Date</th>";
echo "<td><input type=text name=end_date size=6 value=\"{$rowItem['end_date']}\" /></td>";
echo "<td><input type=text name=end_date size=6 value=\"{$rowItem['end_date']}\" onclick='showCalendarControl(this);' /></td>";

echo "</tr><tr><th align-right>Sale for</th>";
// This should really be in the db and be per-coop-configurable.
Expand Down
Loading

0 comments on commit 2215cbc

Please sign in to comment.