+ push @q, { 'quotationnum' => $quotation->quotationnum,
+ '_date' => $quotation->_date,
+ 'num_pkgs' => scalar($quotation->quotation_pkg),
+ 'total_setup' => $quotation->total_setup,
+ 'total_recur' => $quotation->total_recur,
+ };
+ }
+ return { 'quotations' => \@q, 'error' => '' };
+}
+
+=item quotation_new { session }
+
+Creates a quotation and returns its quotationnum.
+
+=cut
+
+sub quotation_new {
+ my $p = shift;
+
+ my($context, $session, $custnum) = _custoragent_session_custnum($p);
+ return { 'error' => $session } if $context eq 'error';
+
+ my $quotation = FS::quotation->new({
+ 'custnum' => $session->{'custnum'},
+ 'usernum' => $FS::CurrentUser::CurrentUser->usernum,
+ '_date' => time,
+ });
+ my $error = $quotation->insert;
+ if ( $error ) {
+ warn "failed to create selfservice quotation for custnum #" .
+ $session->{custnum} . "\n";
+ return { 'error' => $error };
+ } else {
+ warn "started new selfservice quotation #". $quotation->quotationnum."\n"
+ if $DEBUG;
+ return { 'error' => $error, 'quotationnum' => $quotation->quotationnum };
+ }