[if !cgi order] [bounce page="__UI_BASE__/order"] [/if] [calc] $Values->{ui_data_fields} = $CGI->{ui_data_fields} = 'status archive delete'; $CGI->{mv_data_table} = 'transactions'; $Scratch->{arg} = $CGI->{item_id} = $CGI->{order}; return; [/calc] @_UI_STD_DBEDIT_HEAD_@ [set ui_class]Orders[/set] [seti page_title]Order status -- [cgi order][/seti] [tmp page_banner]Order status: order [page href="__UI_BASE__/order_view" form="order=[cgi order]"][cgi order][/tmp] [set help_name]item.edit[/set] [set icon_name]admin/icon_item.gif[/set] @_UI_STD_HEAD_@ [tmp order_lines_tmp][loop search=" fi=orderline st=db sf=order_number se=[cgi order] ml=1000 "][loop-code] [/loop][/tmp]
[loop list="[cgi order]"] [loop prefix=row list="status deleted archived"] [display table=transactions column="[row-code]" key="[loop-code]" template=| |] [/loop]
Order date [convert-date][loop-data transactions order_date][/convert-date]
Status last updated [convert-date][loop-data transactions update_date][/convert-date]
$LABEL$
$WIDGET$$HELP${HELPURL}
help{/HELPURL}
  [if-mm advanced order] [button form=transactions bold=1 text="Ship checked order lines, send email to customer if appropriate"] mv_todo=back order=[cgi code] [tag flag write]orderline transactions[/tag] [perl tables="orderline transactions userdb __UI_META_TABLE__"] my $odb = $Db{orderline} or die "No orderline database!\n"; my $tdb = $Db{transactions} or die "No transactions database!\n"; my $udb = $Db{userdb} or die "No userdb database!\n"; my $on = $Scratch->{ship_notice_order_number} = $CGI->{code}; my $user = $tdb->field($on, 'username'); my $wants_copy = $udb->field($user, 'email_copy'); #Log("Order number=$on username=$user wants=$wants_copy"); delete $Scratch->{ship_notice_username}; delete $Scratch->{ship_notice_email}; if($wants_copy) { $Scratch->{ship_notice_username} = $user; $Scratch->{ship_notice_email} = $udb->field($user, 'email') or delete $Scratch->{ship_notice_username}; } if($CGI->{status} =~ /\d\d\d\d/) { $tdb->set_field($on, 'status', $CGI->{status}); } else { $tdb->set_field($on, 'status', 'shipped'); } my @shiplines = grep /\S/, split /\0/, $CGI->{lines_shipped}; my $to_ship = scalar @shiplines; my $count_q = "select * from orderline where order_number = '$on'"; my $lines_ary = $odb->query($count_q); if(! $lines_ary) { $Scratch->{ui_message} = "No order lines for order $on"; return; } my $total_lines = scalar @$lines_ary; my $odb_keypos = $odb->config('KEY_INDEX'); # See if some items have already shipped my %already; for(@$lines_ary) { my $code = $_->[$odb_keypos]; my $status = $odb->field($code, 'status'); if($status eq 'shipped') { $already{$code} = $code; } } my $ship_mesg; my $g_status; my %shipping; @shipping = grep ! $already{$_}, @shipping; @shipping{@shiplines} = @shiplines; if($total_lines == $to_ship) { $ship_mesg = "Order $on complete, $total_lines lines set shipped."; $Scratch->{ship_notice_complete} = $ship_mesg; $g_status = 'shipped'; } else { $ship_mesg = "Order $on partially shipped ($to_ship of $total_lines lines)."; delete $Scratch->{ship_notice_complete}; $g_status = 'partial'; } my $minor_mesg = ''; my $email_mesg = $Scratch->{ship_notice_username} ? "Email copy sent to $Scratch->{ship_notice_email}." : "No email copy sent as per user preference."; # Actually update the orderline database for(@$lines_ary) { my $code = $_->[$odb_keypos]; next if $already{$code}; my $status = $shipping{$code} ? 'shipped' : 'backorder'; $odb->set_field($code, 'status', $status) or do { $Scratch->{ui_message} = "Orderline $code ship status update failed."; return; }; } for(keys %already) { $shipping{$_} = $_; } my $total_shipped_now = scalar keys %shipping; delete $Scratch->{ship_now_complete}; if ( $total_lines != scalar @shipping and $total_shipped_now == $total_lines ) { $g_status = 'shipped'; $Scratch->{ship_now_complete} = 1 if $total_shipped_now == $total_lines; $ship_mesg = "Order $on now complete (all $total_lines lines)."; } $tdb->set_field($on, 'status', $g_status); $Scratch->{ui_message} = "$ship_mesg $email_mesg"; delete $Scratch->{ship_notice_username}; delete $Scratch->{ship_notice_email}; if($wants_copy) { $Scratch->{ship_notice_username} = $user; $Scratch->{ship_notice_email} = $tdb->field($on, 'email') or $Scratch->{ship_notice_email} = $tdb->field($on, 'email') or delete $Scratch->{ship_notice_username}; } return; [/perl] [if scratch ship_notice_username] [email-raw][include etc/ship_notice][/email-raw] [/if] [/button]
[loop prefix=partial list="[scratch order_lines_tmp]"] Line [partial-increment] ([partial-filter 16][partial-data orderline description][/partial-filter])
[/loop]
[button bold=1 text="Change global status"] order=[cgi code] [/button]    [button text="Cancel"] mv_nextpage=__UI_BASE__/order_view order=[cgi code] mv_todo=back [/button] [else] [button text="Back"] mv_nextpage=__UI_BASE__/order_view order=[cgi code] mv_todo=back [/button] [/else] [/if-mm]
[/loop]

Individual line item status

[loop search=" fi=orderline st=db sf=order_number se=[cgi order] ml=1000 "] [calc] $Values->{ui_data_fields} = $CGI->{ui_data_fields} = 'code status delete'; $CGI->{mv_data_table} = 'transactions'; $Scratch->{arg} = $CGI->{item_id} = $CGI->{order}; return; [/calc] [/loop]
@@UI_STD_DBEDIT_HEAD@@
[display table=orderline column="status" key="[loop-code]" template=| |]
SKU/Description SKU: [loop-data orderline sku], [loop-data orderline quantity]@[filter %.2f][loop-data orderline price][/filter] = [currency][loop-data orderline subtotal][/currency]
[loop-data orderline description]
Last updated [convert-date][loop-data orderline update_date][/convert-date]
$LABEL$
$WIDGET$$HELP${HELPURL}
help{/HELPURL}
 
@_UI_STD_FOOTER_@