[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'; $CGI->{item_id} = $CGI->{order}; return; [/calc] [comment]BEGIN former UI_STD_DBEDIT_HEAD[/comment] [if cgi mv_data_table] [value name=mv_data_table set="[cgi mv_data_table]" hide=1] [else] [value name=mv_data_table set="[calc]$Config->{ProductFiles}[0][/calc]" hide=1] [/else] [/if] [if-mm !tables] [calc] delete $Scratch->{no_bounce}; my $tmp = delete $Scratch->{ui_override_table}; if($tmp eq $Values->{mv_data_table}) { $Scratch->{no_bounce} = 1; } return; [/calc] [if scratch no_bounce] [set no_bounce][/set] [else] [seti ui_error][msg arg.0="[value mv_data_table]"]Not authorized for table %s.[/msg][/seti] [bounce page="__UI_BASE__/error"] [/else] [/if] [/if-mm] [if-mm function=keys name="[cgi item_id]"] [else][bounce href="[area admin/special/key_violation]"][/else] [/if-mm] [perl tables="[value mv_data_table] __UI_META_TABLE__"] my $table = $Values->{mv_data_table}; my $db = $Db{$table}; my $mdb = $Db{__UI_META_TABLE__}; if(! $db) { $Scratch->{ui_error} = errmsg("Bad table '%s'", $table); $Tag->bounce( { page => '__UI_BASE__/error' } ); } $Values->{ui_data_key_name} = $db->config('KEY'); ############################################################### # Get the field display information including breaks and labels ############################################################### if( $mdb and ! $CGI->{ui_data_fields} and ! $CGI->{ui_data_fields_all} and $mdb->record_exists($table) ) { $CGI->{ui_data_fields} = $mdb->field($table, 'options'); $CGI->{ui_data_fields} =~ s/\r\n/\n/g; $CGI->{ui_data_fields} =~ s/\r/\n/g; if($CGI->{ui_data_fields} =~ /\n\n/) { my @breaks; my @break_labels; while ($CGI->{ui_data_fields} =~ s/\n+(?:\n=(.*)\n)?\n+(\w+)/\n$2/) { push @breaks, $2; push @break_labels, "$2=$1" if $1; } $CGI->{ui_break_before} = join " ", @breaks; $CGI->{ui_break_before_label} = join ",", @break_labels; } $CGI->{ui_data_fields} =~ s/^\s+//; $CGI->{ui_data_fields} =~ s/\s+$//; } $Values->{ui_data_fields} = $CGI->{ui_data_fields} || $CGI->{mv_data_fields} || $Values->{"$table:ui_data_fields"} || (join " ", $db->columns()); #Log("data fields: '$Values->{ui_data_fields}' cgi='$CGI->{ui_data_fields}'"); $Values->{ui_data_fields} =~ s/[,\0\s]+/ /g; ############################################################### my @cols = split /[,\0\s]/, $Values->{ui_data_fields}; @cols = grep /:/ || $db->column_exists($_), @cols; $Values->{ui_data_fields} = $CGI->{ui_data_fields} = join " ", @cols; return; [/perl] [comment]END former UI_STD_DBEDIT_HEAD[/comment] [set ui_class]Orders[/set] [seti page_title][L]Order status[/L] -- [cgi order][/seti] [tmp page_banner][L]Order status[/L]: [L]order[/L] [page href="__UI_BASE__/order_view" form="order=[cgi order]"][cgi order][/tmp] [set help_name]item.edit[/set] [set icon_name]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] [form-session-id]

[loop list="[cgi order]"]
[L]Order date[/L] | [convert-date][loop-data transactions order_date][/convert-date]
[L]Status last updated[/L] | [convert-date][loop-data transactions update_date][/convert-date]
[loop prefix=row list="status deleted archived"] [display table=transactions column="[row-code]" key="[loop-code]" applylocale=1 template=|
$LABEL$ |
$WIDGET$ | $HELP${HELPURL} help{/HELPURL}
|] [/loop]
| [if-mm advanced order] [button form=transactions bold=1 text="[L]Ship checked order lines, send email to customer if appropriate[/L]"] 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="[L]Change global status[/L]"] order=[cgi code] [/button] [button text="[L]Cancel[/L]"] mv_nextpage=__UI_BASE__/order_view order=[cgi code] mv_todo=back [set Cancel][/set] [/button] [else] [button text="[L]Back[/L]"] mv_nextpage=__UI_BASE__/order_view order=[cgi code] mv_todo=back [/button] [/else] [/if-mm]

[/loop]

## [L]Individual line item status[/L]

[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'; $CGI->{item_id} = $CGI->{order}; return; [/calc]
[form-session-id]
[L]SKU[/L]/[L]Description[/L] | [L]SKU[/L]: [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]
[L]Last updated[/L] | [convert-date][loop-data orderline update_date][/convert-date]
[display table=orderline column="status" key="[loop-code]" template=|
$LABEL$ |
$WIDGET$ | $HELP${HELPURL} help{/HELPURL}
|]
[/loop]

@_UI_STD_FOOTER_@