$name = "HVAC"; ?>
Eco-$mart Product List -
$newly = $_POST['newly']; $newlylot = $_POST['newlylot']; $uppy = $_POST['uppy']; $dtnum = date(Ymd); $dnum = date(Ymd)*11; $from = $_GET['fr']; if($from == ""){ $from = $_POST['fr']; } $usrn = $_POST['usrn']; if($usrn == ""){ $usrn = $_GET['usrn']; } $users[] = "Kent Grubbs"; $users[] = "Matt Ross"; if( !in_array($usrn,$users) and $from != $dnum ){ echo(""); exit(); }else{ $dbcnx = @mysql_connect('mysql.plainhost.com', 'ecosmar_ecosmart', 'ecoman1'); mysql_select_db('ecosmar_products', $dbcnx); $itemstart = "AC"; $catalogpage = "http://www.ecosmartinc.com/catac.php"; $page = $name; $pageback = "catac.php"; }//logged in $bglo_units = "white"; $bgcase = "white"; $bgdescript = "white"; $bgitem = "white"; $newheadbg = "white"; $newheadcolor = "green"; ////////////////////////////////////////////////////////////newly if($newly == "yes"){ $newitems = $_POST[newitems]; $newskus = $_POST[newskus]; $newMFGs = $_POST[newMFGs]; $newlists = $_POST[newlists]; $newretails = $_POST[newretails]; $newspecials = $_POST[newspecials]; $newdealers = $_POST[newdealers]; $newdealer_los = $_POST[newdealer_los]; $newdistributors = $_POST[newdistributors]; $newcosts = $_POST[newcosts]; $newunits = $_POST[newunits]; $newlo_unitss = $_POST[newlo_unitss]; $newcss = $_POST[newcss]; $newmins = $_POST[newmins]; $newup_dates = $_POST[newup_dates]; $newdescriptions = $_POST[newdescriptions]; $newcount = count($newitems); $i = 0; while($i < $newcount){ $item = $newitems[$i]; if($newitems[$i] != ""){ $whatif = substr($newitems[$i],0,2); if($whatif == $itemstart){ $check = mysql_query("SELECT sku FROM price WHERE item='$item'"); if(!$check){ echo("Could not check for duplicate item numbers. Error: ".mysql_error()."
"); }else{ $numbrows = mysql_num_rows($check); if($numbrows > 0){ $stop = "on"; $airitem[] = $item; $air[] = "Item already exists. Edit below."; }//number of rows is greater than 0 }//checked $sku = $newskus[$i]; $MFG = $newMFGs[$i]; $list = sprintf("%01.2f", $newlists[$i]); $retail = sprintf("%01.2f", $newretails[$i]); $special = sprintf("%01.2f", $newspecials[$i]); $dealer = sprintf("%01.2f", $newdealers[$i]); $dealer_lo = sprintf("%01.2f", $newdealer_los[$i]); $distributor = sprintf("%01.2f", $newdistributors[$i]); $cost = sprintf("%01.2f", $newcosts[$i]); $unit = $newunits[$i]; $lo_units = $newlo_unitss[$i]; $cs = $newcss[$i]; $min = $newmins[$i]; /////testing input if($dealer_lo > 0 and $lo_units == ""){ $stop = "on"; $airitem[] = $item; $air[] = "Dealer Low price, but no Low units."; $bglo_units = "yellow"; $airsku[] = $newskus[$i]; $airMFG[] = $newMFGs[$i]; $airlist[] = sprintf("%01.2f", $newlists[$i]); $airretail[] = sprintf("%01.2f", $newretails[$i]); $airspecial[] = sprintf("%01.2f", $newspecials[$i]); $airdealer[] = sprintf("%01.2f", $newdealers[$i]); $airdealer_lo[] = sprintf("%01.2f", $newdealer_los[$i]); $airdistributor[] = sprintf("%01.2f", $newdistributors[$i]); $aircost[] = sprintf("%01.2f", $newcosts[$i]); $airunit[] = $newunits[$i]; $airlo_units[] = $newlo_unitss[$i]; $aircs[] = $newcss[$i]; $airmin[] = $newmins[$i]; $airdescript[] = stripslashes($newdescriptions[$i]); }//no lo units for dealer lo if($unit == "CS" and $cs == ""){ $stop = "on"; $air[] = "Units = CS, but no case lot specified."; $bgcase = "yellow"; if(!in_array($item, $airitem)){ $airitem[] = $item; $airsku[] = $newskus[$i]; $airMFG[] = $newMFGs[$i]; $airlist[] = sprintf("%01.2f", $newlists[$i]); $airretail[] = sprintf("%01.2f", $newretails[$i]); $airspecial[] = sprintf("%01.2f", $newspecials[$i]); $airdealer[] = sprintf("%01.2f", $newdealers[$i]); $airdealer_lo[] = sprintf("%01.2f", $newdealer_los[$i]); $airdistributor[] = sprintf("%01.2f", $newdistributors[$i]); $aircost[] = sprintf("%01.2f", $newcosts[$i]); $airunit[] = $newunits[$i]; $airlo_units[] = $newlo_unitss[$i]; $aircs[] = $newcss[$i]; $airmin[] = $newmins[$i]; $airdescript[] = stripslashes($newdescriptions[$i]); }//not already in air array }//no lot for cases $descript = stripslashes($newdescriptions[$i]); $description = htmlspecialchars($descript, ENT_QUOTES, 'utf-8'); if($stop != "on"){ if($description != ""){ $newup = mysql_query("INSERT INTO price SET item='$item',sku='$sku',MFG='$MFG',list='$list',retail='$retail',special='$special',dealer='$dealer',dealer_lo='$dealer_lo',distributor='$distributor',cost='$cost',unit='$unit',lo_units='$lo_units',cs='$cs',min='$min',up_date='$dtnum',description='$description' "); if(!$newup){ echo("Could not insert $item. Error: ".mysql_error()."
"); }else{ $inned[] = $item; } }//there is a description else{ $air[] = "No Product Description"; $bgdescript = "yellow"; if(!in_array($item, $airitem)){ $airitem[] = $item; $airsku[] = $newskus[$i]; $airMFG[] = $newMFGs[$i]; $airlist[] = sprintf("%01.2f", $newlists[$i]); $airretail[] = sprintf("%01.2f", $newretails[$i]); $airspecial[] = sprintf("%01.2f", $newspecials[$i]); $airdealer[] = sprintf("%01.2f", $newdealers[$i]); $airdealer_lo[] = sprintf("%01.2f", $newdealer_los[$i]); $airdistributor[] = sprintf("%01.2f", $newdistributors[$i]); $aircost[] = sprintf("%01.2f", $newcosts[$i]); $airunit[] = $newunits[$i]; $airlo_units[] = $newlo_unitss[$i]; $aircs[] = $newcss[$i]; $airmin[] = $newmins[$i]; $airdescript[] = stripslashes($newdescriptions[$i]); }//not already in air array } }//stop is not on }//item number has correct prefix else{ $air[] = "Incorrect Item Number"; $bgitem = "yellow"; if(!in_array($item, $airitem)){ $airitem[] = $item; $airsku[] = $newskus[$i]; $airMFG[] = $newMFGs[$i]; $airlist[] = sprintf("%01.2f", $newlists[$i]); $airretail[] = sprintf("%01.2f", $newretails[$i]); $airspecial[] = sprintf("%01.2f", $newspecials[$i]); $airdealer[] = sprintf("%01.2f", $newdealers[$i]); $airdealer_lo[] = sprintf("%01.2f", $newdealer_los[$i]); $airdistributor[] = sprintf("%01.2f", $newdistributors[$i]); $aircost[] = sprintf("%01.2f", $newcosts[$i]); $airunit[] = $newunits[$i]; $airlo_units[] = $newlo_unitss[$i]; $aircs[] = $newcss[$i]; $airmin[] = $newmins[$i]; $airdescript[] = stripslashes($newdescriptions[$i]); }//not already in air array } }//item number is present $i=$i+1; }//while counting newitems if(!empty($airitem)){ $newheadbg = "maroon"; $newheadcolor = "yellow"; echo("Some items not inserted:");
$aircount = count($airitem);
$a=0;
while($a < $aircount){
echo("
$airitem[$a] : $air[$a]");
$a=$a+1;
}//while counting air items
echo("
INSERTED: "); foreach($inned as $value){ echo("$value ¦¦ "); } } }//newly is yes /////////////////////////////////////////////////////////////newlylot if($newlylot == "yes"){ $stop = "off"; $inputer = $_POST['inputer']; $detail = rtrim($inputer, "\r\n"); $excol = explode("\r\n", $detail); $excount = count($excol); echo("
Processing $excount rows...
"); foreach($excol as $value){ $overwrite = "off"; $splits = explode("\t", $value); $countem = count($splits); if($countem == 16){ $whatif = substr($splits[0],0,2); if($whatif == $itemstart){ $item = $splits[0]; $check = mysql_query("SELECT sku FROM price WHERE item='$item'"); if(!$check){ echo("Could not check for duplicate item numbers. Error: ".mysql_error()."
"); }else{ $numbrows = mysql_num_rows($check); if($numbrows > 0){ $overwrite = "on"; $overitem[] = $item; }//there are dupes }//checked $sku = $splits[1]; $MFG = $splits[2]; $list = sprintf("%01.2f", $splits[3]); $retail = sprintf("%01.2f", $splits[4]); $special = sprintf("%01.2f", $splits[5]); $dealer = sprintf("%01.2f", $splits[6]); $dealer_lo = sprintf("%01.2f", $splits[7]); $distributor = sprintf("%01.2f", $splits[8]); $cost = sprintf("%01.2f", $splits[9]); $unit = $splits[10]; $lo_units = $splits[11]; $cs = $splits[12]; $min = $splits[13]; /////testing input if($dealer_lo > 0 and $lo_units == ""){ $stop = "on"; $airitem[] = $item; $air[] = "Wholesale Low price, but no Low units."; } if($unit == "CS" and $cs == ""){ $stop = "on"; $airitem[] = $item; $air[] = "Units = CS, but no case lot specified."; } $descript = stripslashes($splits[15]); $description = htmlspecialchars($descript, ENT_QUOTES, 'utf-8'); if($stop != "on"){ if($overwrite != "on"){ if($description != ""){ $newup = mysql_query("INSERT INTO price SET item='$item',sku='$sku',MFG='$MFG',list='$list',retail='$retail',special='$special',dealer='$dealer',dealer_lo='$dealer_lo',distributor='$distributor',cost='$cost',unit='$unit',lo_units='$lo_units',cs='$cs',min='$min',up_date='$dtnum',description='$description' "); if(!$newup){ echo("Could not insert $item. Error: ".mysql_error()."
"); }else{ $inned[] = $item; } }//there is a description else{ $airitem[] = $item; $air[] = "No Product Description"; } }//overwrite is not on else{ $oitem[] = $splits[0]; $osku[] = $splits[1]; $oMFG[] = $splits[2]; $olist[] = sprintf("%01.2f", $splits[3]); $oretail[] = sprintf("%01.2f", $splits[4]); $ospecial[] = sprintf("%01.2f", $splits[5]); $odealer[] = sprintf("%01.2f", $splits[6]); $odealer_lo[] = sprintf("%01.2f", $splits[7]); $odistributor[] = sprintf("%01.2f", $splits[8]); $ocost[] = sprintf("%01.2f", $splits[9]); $ounit[] = $splits[10]; $olo_units[] = $splits[11]; $ocs[] = $splits[12]; $omin[] = $splits[13]; $odescript[] = stripslashes($splits[15]); }//overwrite is on }//stop is not on }else{ $airitem[] = $item; $air[] = "Incorrect Item Number"; } }//15 columns else{ $airitem[] = $item; $air[] = "Column Mismatch"; } }//4each row if(!empty($airitem)){ echo("Some items not inserted:");
$aircount = count($airitem);
$a=0;
while($a < $aircount){
echo("
$airitem[$a] : $air[$a]");
$a=$a+1;
}//while counting air items
echo("
INSERTED: "); foreach($inned as $value){ echo("$value ¦¦ "); } }//products inned if(!empty($oitem)){ echo("
"); }//overwrite is on }//newlylot is yes ////////////////////////////////////////////////uppy if($uppy == "yes"){ $outitems = $_POST[outitems]; if(!empty($outitems)){ echo("REMOVED: "); foreach($outitems as $value){ $newitem = "9".$value; $hide = mysql_query("UPDATE price SET item='$newitem' WHERE item='$value' "); if(!$hide){ echo("
Could not trash $value. Error: ".mysql_error()."
"); }else{ echo("$value ¦¦ "); } }//4each echo("No changes made. You must check the box next to the item you wish to edit.
"); }else{ $i=0; while($i < $itemcount){ if(in_array($items[$i], $changeitems)){ $item = $items[$i]; $sku = $skus[$i]; $MFG = $MFGs[$i]; $list = sprintf("%01.2f", $lists[$i]); $retail = sprintf("%01.2f", $retails[$i]); $special = sprintf("%01.2f", $specials[$i]); $dealer = sprintf("%01.2f", $dealers[$i]); $dealer_lo = sprintf("%01.2f", $dealer_los[$i]); $distributor = sprintf("%01.2f", $distributors[$i]); $cost = sprintf("%01.2f", $costs[$i]); $unit = $units[$i]; $lo_units = $lo_unitss[$i]; $cs = $css[$i]; $min = $mins[$i]; $descript = stripslashes($descriptions[$i]); $description = htmlspecialchars($descript, ENT_QUOTES, 'utf-8'); $uppit = mysql_query("UPDATE price SET sku='$sku',MFG='$MFG',list='$list',retail='$retail',special='$special',dealer='$dealer',dealer_lo='$dealer_los[$i]',distributor='$distributor',cost='$cost',unit='$unit',lo_units='$lo_units',cs='$cs',min='$min',up_date='$dtnum',description='$description' WHERE item='$item'"); if(!$uppit){ echo("Unable to update $item[$i]. Error: ".mysql_error()."
"); }else{//add items to list of successful changes $upped[] = $item; } }//if item is in changeitems array $i = $i + 1; }//while counting items }//there are items checked to be changed if(!empty($upped)){ echo("EDITED: "); foreach($upped as $value){ echo("$value ¦¦ "); } echo("
"); }//upped is not empty }//uppyisyes /////////////////////////////////////START DISPLAY $getmfgs = mysql_query("SELECT co_name FROM mfg ORDER BY co_name"); if(!$getmfgs){ echo("Could not Get Manufacturers List
".mysql_error()."
Could not Get Item List
".mysql_error()."
No Items Available with prefix $itemstart.
"); }else{ echo(""); }//there are products in numrows }//gotit ?>MUST READ:
IMPORTANT: The Item Number is the key in the Product Data Base. This is why the Item Number cannot be Duplicated or Edited in this program. If a product requires a new Item Number, it must be Added like a new product. Then the old Item Number should be removed. Notification of the change to applicable parties is recommended. • Item Numbers must begin with to be accepted. If they do not, you will receive a message telling you so, and the item will not be added. • When adding rows from a spread sheet, you must select the CONTENT of the rows to be added.
• Rows from a spread sheet must match columns in the data base.
1. Right Click in the text area and click "Select All".
2. Right Click and Click "Copy" (Ctrl+C).
3. Select the first cell of the row where you are pasting in Excel.
• Errors: There are several reasons that a row of data may be rejected:
• PRICE DISPLAY: There are two areas where prices effect display.:
|
© 2010 Eco-$mart, Inc. eco-smart.com Administration Eco-$mart Products Add Manufacturer Print List Web Page Trash Bin |