Eco-$mart Manufacturers - Edit Manufacturer
$dnum = date(Ymd)*11; $from = $_GET['fr']; if($from == ""){ $from = $_POST['fr']; } if($from != $dnum){ echo("<<<<Restricted Area>>>>" .
"
Sorry, you must Log In to view this Page
<<<<Restricted Area>>>>" .
"
Problem with your username. Please Log In again.
Cannot continue. No Company Name Provided.
"); exit(); } $dtnum=date(Ymd); $pageback = "mfg_edit.php"; mysql_select_db('ecosmar_products', $dbcnx); $getcats=mysql_query("SELECT item_start FROM cats ORDER BY item_start"); if(!$getcats){ echo("Could not get category list."); //echo mysql_error(); }else{ while($row=mysql_fetch_array($getcats)){ $itemstart[]= $row[0]; }//while getting cats }//got cats ///////////////////////changey mfg table $changey = $_POST['changey']; if($changey == "yes"){ $ID=$_POST['ID']; $co_name=stripslashes($_POST['co_name']); if($co_name != $co){ $namechange="on"; } $co_rep=stripslashes($_POST['co_rep']); $email=$_POST['email']; $order_email=$_POST['order_email']; $reg=$_POST['reg']; $address=stripslashes($_POST['address']); $city=stripslashes($_POST['city']); $state=$_POST['state']; $ZipCode=$_POST['ZipCode']; $country=$_POST['country']; $phone=$_POST['phone']; $FAX=$_POST['FAX']; $website=$_POST['website']; $co_name = htmlspecialchars($co_name, ENT_QUOTES, 'utf-8'); $co_rep = htmlspecialchars($co_rep, ENT_QUOTES, 'utf-8'); $address = htmlspecialchars($address, ENT_QUOTES, 'utf-8'); $city = htmlspecialchars($city, ENT_QUOTES, 'utf-8'); $changem = mysql_query("UPDATE mfg SET co_name='$co_name',co_rep='$co_rep',email='$email',order_email='$order_email',reg='$reg',address='$address',city='$city',state='$state',ZipCode='$ZipCode',country='$country',phone='$phone',FAX='$FAX',website='$website' WHERE ID='$ID'"); if(!$changem){ echo("Could not update MFG information. Error:
".mysql_error()."
$co_name Updated"); if($namechange=="on"){ $getchprods=mysql_query("SELECT item FROM price WHERE MFG='$co'"); if(!$getchprods){ $air[]="Could not get price info for Company change. Error: ".mysql_error(); }else{ while($row=mysql_fetch_array($getchprods)){ $pch[]=$row['item']; }//while fetchin rows foreach($pch as $value){ $chprods=mysql_query("UPDATE price SET MFG='$co_name' WHERE item='$value'"); if(!$chprods){ $air[]="Could not update company name for: ".$value.". Error: ".mysql_error(); }else{ $suc[]=$value." Updated."; } }//4each }//got products for name change $co=$co_name; }//namechange is on }//updated mgf }//changey is yes ////////////////////////////////////////////////////////newly if($newly == "yes"){ $co = $_POST['co']; $newitems = $_POST[newitems]; $newskus = $_POST[newskus]; $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(in_array($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]; $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]; $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]; $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='$co',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 Prefix"; $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 /////////Edit newylot here /////////////////////////////////////////////////////////////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(in_array($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[] = "Dealer 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 Prefix"; } }//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]; $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',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 ///////////////////////shippy ////////////////////////////// $shippy=$_POST['shippy']; if($shippy=="yes"){ $allshipitems=$_POST[allshipitems]; $shipoutitems=$_POST[shipoutitems]; $shipchangeitems=$_POST[shipchangeitems]; if(!empty($shipoutitems)){ foreach($shipoutitems as $value){ $outit=mysql_query("DELETE FROM ship WHERE item='$value' LIMIT 1"); if(!$outit){ $air[]="Could not delete ".$value.". Error: ".mysql_error(); }else{ $suc[]=$value." Deleted."; } }//4each out item }//there are ship out items to delete $skus=$_POST[skus]; $upcs=$_POST[upcs]; $carriers=$_POST[carriers]; $crr_phones=$_POST[crr_phones]; $crr_accounts=$_POST[crr_accounts]; $classs=$_POST[classs]; $o_citys=$_POST[o_citys]; $o_countrys=$_POST[o_countrys]; $o_codes=$_POST[o_codes]; $units=$_POST[units]; $weight_lbss=$_POST[weight_lbss]; $height_ins=$_POST[height_ins]; $width_ins=$_POST[width_ins]; $length_ins=$_POST[length_ins]; $minimums=$_POST[minimums]; $handlings=$_POST[handlings]; $flats=$_POST[flats]; $rate_1s=$_POST[rate_1s]; $rate_wgt_1s=$_POST[rate_wgt_1s]; $rate_2s=$_POST[rate_2s]; $rate_wgt_2s=$_POST[rate_wgt_2s]; $rate_3s=$_POST[rate_3s]; $rate_wgt_3s=$_POST[rate_wgt_3s]; $i=0; $countem=count($allshipitems); while($i<$countem){ if(in_array($allshipitems[$i],$shipchangeitems)){ $upship=mysql_query("UPDATE ship SET sku='$skus[$i]',upc='$upcs[$i]',carrier='$carriers[$i]',crr_phone='$crr_phones[$i]',crr_account='$crr_accounts[$i]',class='$classs[$i]',o_city='$o_citys[$i]',o_country='$o_countrys[$i]',o_code='$o_codes[$i]',unit='$units[$i]',weight_lbs='$weight_lbss[$i]',height_in='$height_ins[$i]',width_in='$width_ins[$i]',length_in='$length_ins[$i]',minimum='$minimums[$i]',handling='$handlings[$i]',flat='$flats[$i]',rate_1='$rate_1s[$i]',rate_wgt_1='$rate_wgt_1s[$i]',rate_2='$rate_2s[$i]',rate_wgt_2='$rate_wgt_2s[$i]',rate_3='$rate_3s[$i]',rate_wgt_3='$rate_wgt_3s[$i]',up_date='$dtnum' WHERE item='$allshipitems[$i]'"); if(!$upship){ $air[]="Could not update ".$allshipitems[$i]." Error: ".mysql_error(); }else{ $suc[]=$allshipitems[$i]." Updated."; } }//item is in item change array $i=$i+1; }//while counting down all ship items }//shippy is yes ////////////////shipnew//////////////////////////// $newship=$_POST['newship']; if($newship=="yes"){ $newsID=$_POST['newsID']; $newsdesc=$_POST['newsdesc']; $sku=$_POST['sku']; $upc=$_POST['upc']; $carrier=$_POST['carrier']; $crr_phone=$_POST['crr_phone']; $crr_account=$_POST['crr_account']; $class=$_POST['class']; $o_city=$_POST['o_city']; $o_country=$_POST['o_country']; $o_code=$_POST['o_code']; $unit=$_POST['unit']; $weight_lbs=$_POST['weight_lbs']; $height_in=$_POST['height_in']; $width_in=$_POST['width_in']; $length_in=$_POST['length_in']; $minimum=$_POST['minimum']; $handling=$_POST['handling']; $flat=$_POST['flat']; $rate_1=$_POST['rate_1']; $rate_wgt_1=$_POST['rate_wgt_1']; $rate_2=$_POST['rate_2']; $rate_wgt_2=$_POST['rate_wgt_2']; $rate_3=$_POST['rate_3']; $rate_wgt_3=$_POST['rate_wgt_3']; $inny=mysql_query("INSERT INTO ship SET item='$newsID',sku='$sku',upc='$upc',carrier='$carrier',crr_phone='$crr_phone',crr_account='$crr_account',class='$class',o_city='$o_city',o_country='$o_country',o_code='$o_code',unit='$unit',weight_lbs='$weight_lbs',height_in='$height_in',width_in='$width_in',length_in='$length_in',minimum='$minimum',handling='$handling',flat='$flat',rate_1='$rate_1',rate_wgt_1='$rate_wgt_1',rate_2='$rate_2',rate_wgt_2='$rate_wgt_2',rate_3='$rate_3',rate_wgt_3='$rate_wgt_3',up_date='$dtnum',description='$newsdesc'"); if(!$inny){ $air[]="Could not insert ".$newsID.". Error: ".mysql_error(); }else{ $suc[]=$newsID." Inserted."; }///inserted }//newship is yes ///////////////get MFG info////////////////////////// $getem = mysql_query("SELECT ID,co_name,co_rep,email,order_email,reg,address,city,state,ZipCode,country,phone,FAX,website FROM mfg WHERE co_name='$co'"); if(!$getem){ echo("Could not retrieve Manufacturer Information. Error:
".mysql_error()."
Error: "); foreach($air as $value){ echo("$value ¦¦ "); }//4eachair }//air is not empty if(!empty($suc)){ echo("
Completed: "); foreach($suc as $value){ echo("$value ¦¦ "); }//4eachsuc }//success not empty ?>
Product ListAdd to Product List | |||||||||||||||
$getit = mysql_query("SELECT item,sku,list,retail,special,dealer,dealer_lo,distributor,cost,unit,lo_units,cs,min,up_date,description FROM price WHERE MFG='$co'");
if(!$getit){
echo(" Could not Get Item List No Items Designated for this Manufacturer. "); }else{ echo(""); }//there are products in numrows }//gotit ?> |
Shipping ListAdd to Shipping List | |||||||||||||||
© 2010 Eco-$mart, Inc. eco-smart.com Administration Eco-$mart Products Add Manufacturer Trash Bin |