[ic] Why's only the last iteration being updated

Aaron Rubin interchange-users@icdevgroup.org
Thu Nov 21 17:45:01 2002


Hey,

  Using IC 4.86 on a dual processor machine using Linux 2.4.18PIIISMP
  On all checked orders status gets switched to "shipped" but only on
the last order that's checked is the data added to it's orderhistory
(via sql). I also wanted it to email the customer but I've removed that
to simplify the code. The problem occurs even with the emailing the
customer section commented out.
Thanks.

Relevant code:

[set my_lines]0[/set]
[search-list]


<!--
[PERL]
$Scratch->{my_lines}++;
[/PERL]
-->
<TR bgcolor="#ffffff">
<TD>

<input type="checkbox" name="[scratch my_lines]">
<input name="packedby_[scratch my_lines]" SIZE=10>
<input name="order_[scratch my_lines]" type=hidden value=[item-param
code]>


	<INPUT NAME="entered_by" type=hidden value="[value
mv_username]">
	<INPUT NAME="entered_date" type=hidden value="[tag time]%Y%m%d
%H:%M:%S[/tag]">








	[button form=batch bold=1 text="[L]Shipped[/L]"]
	mv_todo=back
	order=[cgi code]
	[tag flag write]orderhistory transactions[/tag]
	[perl tables="orderhistory transactions userdb tracknumbers
__UI_META_TABLE__" interpolate=1]
		my $tdb = $Db{transactions}
			or die "No transactions database!\n";
		my $hdb = $Db{orderhistory}
			or die "No orderhistory database!\n";
		my $udb = $Db{userdb}
			or die "No userdb database!\n";
		my $tndb = $Db{tracknumbers}
			or die "No tracknumbers database!\n";

my $number;
my $onumber;
my $sku;
my $upto;
my $t2;
my $xyz;
my $oxyz;
my $ins;
my $lines_ary;
my $abc;
   my $lower=100;
   my $upper=200000;
my $t2;

while ($Scratch->{my_lines} > 0)
{

$upto = $Scratch->{my_lines};
$xyz = "order_$upto";
$oxyz = "order_$upto";
$number = $CGI->{$xyz};
$abc = "packedby_$upto";
$t2 = int(rand( $upper-$lower+1 ) ) + $lower;
if ($CGI->{$upto})
{



	$tdb->set_field($number, 'status', 'shipped');
#		my $user       = $tdb->field($number, 'username');
#		my $wants_copy = $udb->field($user, 'email_copy');
#        my $tnumber = $tndb->field($number, 'tracknumber');
#		delete $Scratch->{ship_notice_username};
#		delete $Scratch->{ship_notice_email};
#


#		if($wants_copy) {
#					$Scratch->{ship_now_complete} =
'1';
#			$Scratch->{ship_notice_username} = $user;
#			$Scratch->{ship_notice_email} =
$tdb->field($number, 'email');
#		}

my $ins = "insert into orderhistory
(code,order_number,information,updated_by,update_date) values
('$number-$t2','$number','Order shipped with track number <a
href=http://wwwapps.ups.com/etracking/tracking.cgi?tracknum=$tnumber
target=#top>$tnumber</a>. Packed by
$CGI->{$abc}','$CGI->{entered_by}','$CGI->{entered_date}')";
my $lines_ary =  $hdb->query($ins);
>> or 
$hdb->query({sql => "insert into orderhistory
(code,store_id,order_number,session,information,updated_by,update_date)
values ('$r2-8','','$number','','Order
shipping','$CGI->{entered_by}','[tag time]%Y-%m-%d %H:%M:%S[/tag]')"});

}
$Scratch->{my_lines}--;
}
		return;
		delete $Scratch->{ship_now_complete};
	[/perl]
[comment]
		[if scratch ship_notice_username]
		[email-raw][include etc/ship_notice][/email-raw]
	[/if]
	[/comment]
	[/button]


aaron