# Link this delivery order to the quotations it was created from.
RecordLinks->create_links('dbh' => $dbh,
- 'mode' => 'string',
+ 'mode' => 'ids',
'from_table' => 'oe',
'from_ids' => $form->{convert_from_oe_ids},
'to_table' => 'delivery_orders',
Common::webdav_folder($form) if ($main::webdav);
- my @close_do_ids = map { $_ * 1 } grep { $_ } split m/\s+/, $form->{close_do_ids};
- if (scalar @close_do_ids) {
+ # Link this record to the records it was created from.
+ RecordLinks->create_links('dbh' => $dbh,
+ 'mode' => 'ids',
+ 'from_table' => 'oe',
+ 'from_ids' => $form->{convert_from_oe_ids},
+ 'to_table' => 'ap',
+ 'to_id' => $form->{id},
+ );
+ delete $form->{convert_from_oe_ids};
+
+ my @convert_from_do_ids = map { $_ * 1 } grep { $_ } split m/\s+/, $form->{convert_from_do_ids};
+ if (scalar @convert_from_do_ids) {
DO->close_orders('dbh' => $dbh,
- 'ids' => \@close_do_ids);
+ 'ids' => \@convert_from_do_ids);
+
+ RecordLinks->create_links('dbh' => $dbh,
+ 'mode' => 'ids',
+ 'from_table' => 'delivery_orders',
+ 'from_ids' => \@convert_from_do_ids,
+ 'to_table' => 'ap',
+ 'to_id' => $form->{id},
+ );
}
my $rc = 1;
Common::webdav_folder($form) if ($main::webdav);
- my @close_do_ids = map { $_ * 1 } grep { $_ } split m/\s+/, $form->{close_do_ids};
-
- if (scalar @close_do_ids) {
+ # Link this record to the records it was created from.
+ RecordLinks->create_links('dbh' => $dbh,
+ 'mode' => 'ids',
+ 'from_table' => 'oe',
+ 'from_ids' => $form->{convert_from_oe_ids},
+ 'to_table' => 'ar',
+ 'to_id' => $form->{id},
+ );
+ delete $form->{convert_from_oe_ids};
+
+ my @convert_from_do_ids = map { $_ * 1 } grep { $_ } split m/\s+/, $form->{convert_from_do_ids};
+
+ if (scalar @convert_from_do_ids) {
DO->close_orders('dbh' => $dbh,
- 'ids' => \@close_do_ids);
+ 'ids' => \@convert_from_do_ids);
+
+ RecordLinks->create_links('dbh' => $dbh,
+ 'mode' => 'ids',
+ 'from_table' => 'delivery_orders',
+ 'from_ids' => \@convert_from_do_ids,
+ 'to_table' => 'ar',
+ 'to_id' => $form->{id},
+ );
}
my $rc = 1;
# save printed, emailed, queued
$form->save_status($dbh);
+ # Link this record to the records it was created from.
+ RecordLinks->create_links('dbh' => $dbh,
+ 'mode' => 'ids',
+ 'from_table' => 'oe',
+ 'from_ids' => $form->{convert_from_oe_ids},
+ 'to_table' => 'oe',
+ 'to_id' => $form->{id},
+ );
+ delete $form->{convert_from_oe_ids};
+
if (($form->{currency} ne $form->{defaultcurrency}) && !$exchangerate) {
if ($form->{vc} eq 'customer') {
$form->update_exchangerate($dbh, $form->{currency}, $form->{transdate}, $form->{exchangerate}, 0);
if ($form->{"multi_id_$_"} and $form->{"trans_id_$_"})
} (1 .. $form->{"rowcount"});
+ if ($form->{rowcount} && scalar @ids) {
+ $form->{convert_from_oe_ids} = join ' ', @ids;
+ }
+
# if called in multi id mode, and still only got one id, switch back to single id
if ($form->{"rowcount"} and $#ids == 0) {
$form->{"id"} = $ids[0];
my $self = shift;
my %params = @_;
- if ($params{mode} && ($params{mode} eq 'string')) {
+ if ($params{mode} && ($params{mode} eq 'ids')) {
Common::check_params_x(\%params, [ qw(from_ids to_ids) ]);
} else {
my @links;
- if ($params{mode} && ($params{mode} eq 'string')) {
+ if ($params{mode} && ($params{mode} eq 'ids')) {
my ($from_to, $to_from) = $params{from_ids} ? qw(from to) : qw(to from);
- my %ids = ( $from_to => [ grep { $_ } map { $_ * 1 } split m/\s+/, $params{"${from_to}_ids"} ] );
+ my %ids;
+
+ if ('ARRAY' eq ref $params{"${from_to}_ids"}) {
+ $ids{$from_to} = $params{"${from_to}_ids"};
+ } else {
+ $ids{$from_to} = [ grep { $_ } map { $_ * 1 } split m/\s+/, $params{"${from_to}_ids"} ];
+ }
if (my $num = scalar @{ $ids{$from_to} }) {
$main::lxdebug->message(0, "3");
check_do_access();
$auth->assert($form->{type} eq 'purchase_delivery_order' ? 'vendor_invoice_edit' : 'invoice_edit');
- $form->{close_do_ids} = $form->{id};
+ $form->{convert_from_do_ids} = $form->{id};
+ $form->{deliverydate} = $form->{transdate};
+ $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
+ $form->{duedate} = $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
+ $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
- $form->{deliverydate} = $form->{transdate};
- $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
- $form->{duedate} = $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
-
- $form->{id} = '';
- $form->{closed} = 0;
$form->{rowcount}--;
- $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
+ delete @{$form}{qw(id closed delivered)};
if ($form->{type} eq 'purchase_delivery_order') {
$form->{title} = $locale->text('Add Vendor Invoice');
'back_button' => 1);
}
- $form->{close_do_ids} = join ' ', @do_ids;
- $form->{deliverydate} = $form->{transdate};
- $form->{transdate} = $form->current_date(\%myconfig);
- $form->{duedate} = $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
- $form->{type} = "invoice";
- $form->{closed} = 0;
- $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
+ $form->{convert_from_do_ids} = join ' ', @do_ids;
+ $form->{deliverydate} = $form->{transdate};
+ $form->{transdate} = $form->current_date(\%myconfig);
+ $form->{duedate} = $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
+ $form->{type} = "invoice";
+ $form->{closed} = 0;
+ $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
my $buysell;
if ($form->{type} eq 'purchase_delivery_order') {
$form->hide_form(qw(id title vc type level creditlimit creditremaining closedto locked shippted storno storno_id
max_dunning_level dunning_amount vendor_id oldvendor selectvendor taxaccounts
- fxgain_accno fxloss_accno taxpart taxservice cursor_fokus),
+ fxgain_accno fxloss_accno taxpart taxservice cursor_fokus
+ convert_from_oe_ids convert_from_do_ids),
map { $_.'_rate', $_.'_description' } split / /, $form->{taxaccounts} );
print qq|<p>$form->{saved_message}</p>| if $form->{saved_message};
</tr>
</table>
<br>
-| . $cgi->hidden('-name' => 'close_do_ids', '-default' => [$form->{close_do_ids}]);
+|;
$invdate = $form->datetonum($form->{invdate}, \%myconfig);
$closedto = $form->datetonum($form->{closedto}, \%myconfig);
creditlimit creditremaining tradediscount business closedto locked shipped storno storno_id
max_dunning_level dunning_amount
shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax
- shiptoemail shiptodepartment_1 shiptodepartment_2 message email subject cc bcc taxaccounts cursor_fokus),
+ shiptoemail shiptodepartment_1 shiptodepartment_2 message email subject cc bcc taxaccounts cursor_fokus
+ convert_from_do_ids convert_from_oe_ids),
map { $_.'_rate', $_.'_description', $_.'_taxnumber' } split / /, $form->{taxaccounts} );
print qq|<p>$form->{saved_message}</p>| if $form->{saved_message};
$cgi->hidden("-name" => "callback", "-value" => $form->{callback})
. $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}])
. $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}])
-. $cgi->hidden('-name' => 'close_do_ids', '-default' => [$form->{close_do_ids}])
. qq|
</form>
$form->{"select$form->{vc}"} = 1;
$form->{$form->{vc}} = qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
}
- $form->{"old$form->{vc}"} = $form->{$form->{vc}};
+
+ $form->{"old$form->{vc}"} = $form->{$form->{vc}};
+ $form->{"old$form->{vc}"} .= qq|--$form->{"$form->{vc}_id"}| unless ($form->{"old$form->{vc}"} =~ m/--\d+$/);
$lxdebug->leave_sub();
}
OE->close_orders(\%myconfig, \%$form);
}
- $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
- $form->{duedate} = $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
+ $form->{convert_from_oe_ids} = $form->{id};
+ $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
+ $form->{duedate} = $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
+ $form->{shipto} = 1;
+ $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
- $form->{id} = '';
- $form->{closed} = 0;
+ delete @{$form}{qw(id closed)};
$form->{rowcount}--;
- $form->{shipto} = 1;
-
- $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
if ($form->{type} =~ /_order$/) {
$form->{exchangerate} = $exchangerate;
delete($form->{ordnumber});
}
- $form->{cp_id} *= 1;
- $form->{convert_from_oe_ids} = $form->{id};
+ $form->{cp_id} *= 1;
- $form->{title} = $locale->text('Add Sales Order');
- $form->{vc} = "customer";
- $form->{type} = "sales_order";
+ $form->{title} = $locale->text('Add Sales Order');
+ $form->{vc} = "customer";
+ $form->{type} = "sales_order";
&poso;
$form->{transdate} = $form->current_date(\%myconfig);
delete $form->{duedate};
- $form->{closed} = 0;
+ $form->{convert_from_oe_ids} = $form->{id};
+ $form->{closed} = 0;
- $form->{old_employee_id} = $form->{employee_id};
- $form->{old_salesman_id} = $form->{salesman_id};
+ $form->{old_employee_id} = $form->{employee_id};
+ $form->{old_salesman_id} = $form->{salesman_id};
# reset
- map { delete $form->{$_} } qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal);
+ map { delete $form->{$_} } qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal delivered);
for $i (1 .. $form->{rowcount}) {
map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if ($form->{"${_}_${i}"}) } qw(ship qty sellprice listprice basefactor);
<input type="hidden" name="[% HTML.escape(row.name) %]" value="[% HTML.escape(row.value) %]" >
[%- END %]
+ <input type="hidden" name="convert_from_oe_ids" value="[% HTML.escape(convert_from_oe_ids) %]">
+
<input type="hidden" name="follow_up_trans_id_1" value="[% HTML.escape(id) %]">
<input type="hidden" name="follow_up_trans_type_1" value="[% HTML.escape(type) %]">
<input type="hidden" name="follow_up_trans_info_1" value="[% HTML.escape(follow_up_trans_info) %]">
<input type="hidden" name="[% HTML.escape(row.name) %]" value="[% HTML.escape(row.value) %]" >
[%- END %]
+ <input type="hidden" name="convert_from_oe_ids" value="[% HTML.escape(convert_from_oe_ids) %]">
+
<input type="hidden" name="follow_up_trans_id_1" value="[% HTML.escape(id) %]">
<input type="hidden" name="follow_up_trans_type_1" value="[% HTML.escape(type) %]">
<input type="hidden" name="follow_up_trans_info_1" value="[% HTML.escape(follow_up_trans_info) %]">