summaryrefslogtreecommitdiff
path: root/httemplate/edit/process
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate/edit/process')
-rw-r--r--httemplate/edit/process/access_group.html5
-rw-r--r--httemplate/edit/process/access_user.html8
-rwxr-xr-xhttemplate/edit/process/agent_type.cgi39
-rwxr-xr-xhttemplate/edit/process/cust_bill_pay.cgi16
-rwxr-xr-xhttemplate/edit/process/cust_credit.cgi17
-rwxr-xr-xhttemplate/edit/process/cust_credit_bill.cgi16
-rw-r--r--httemplate/edit/process/elements/process.html19
7 files changed, 77 insertions, 43 deletions
diff --git a/httemplate/edit/process/access_group.html b/httemplate/edit/process/access_group.html
new file mode 100644
index 000000000..e8c6d07b1
--- /dev/null
+++ b/httemplate/edit/process/access_group.html
@@ -0,0 +1,5 @@
+<%= include( 'elements/process.html',
+ 'table' => 'access_group',
+ 'viewall_dir' => 'browse',
+ )
+%>
diff --git a/httemplate/edit/process/access_user.html b/httemplate/edit/process/access_user.html
new file mode 100644
index 000000000..a6c2a36b1
--- /dev/null
+++ b/httemplate/edit/process/access_user.html
@@ -0,0 +1,8 @@
+<%= include( 'elements/process.html',
+ 'table' => 'access_user',
+ 'viewall_dir' => 'browse',
+ 'process_m2m' => { 'link_table' => 'access_usergroup',
+ 'target_table' => 'access_group',
+ },
+ )
+%>
diff --git a/httemplate/edit/process/agent_type.cgi b/httemplate/edit/process/agent_type.cgi
index 516594573..fd8ca8833 100755
--- a/httemplate/edit/process/agent_type.cgi
+++ b/httemplate/edit/process/agent_type.cgi
@@ -11,43 +11,24 @@ my $new = new FS::agent_type ( {
my $error;
if ( $typenum ) {
- $error=$new->replace($old);
+ $error = $new->replace($old);
} else {
- $error=$new->insert;
- $typenum=$new->getfield('typenum');
+ $error = $new->insert;
+ $typenum = $new->getfield('typenum');
}
+#$error ||= $new->process_m2m( );
if ( $error ) {
$cgi->param('error', $error);
print $cgi->redirect(popurl(2). "agent_type.cgi?". $cgi->query_string );
} else {
- #false laziness w/ edit/process/part_svc.cgi
- foreach my $part_pkg (qsearch('part_pkg',{})) {
- my($pkgpart)=$part_pkg->getfield('pkgpart');
-
- my($type_pkgs)=qsearchs('type_pkgs',{
- 'typenum' => $typenum,
- 'pkgpart' => $pkgpart,
- });
- if ( $type_pkgs && ! $cgi->param("pkgpart$pkgpart") ) {
- my($d_type_pkgs)=$type_pkgs; #need to save $type_pkgs for below.
- $error=$d_type_pkgs->delete;
- die $error if $error;
-
- } elsif ( $cgi->param("pkgpart$pkgpart")
- && ! $type_pkgs
- ) {
- #ok to clobber it now (but bad form nonetheless?)
- $type_pkgs=new FS::type_pkgs ({
- 'typenum' => $typenum,
- 'pkgpart' => $pkgpart,
- });
- $error= $type_pkgs->insert;
- die $error if $error;
- }
-
- }
+ my $error = $new->process_m2m(
+ 'link_table' => 'type_pkgs',
+ 'target_table' => 'part_pkg',
+ 'params' => scalar($cgi->Vars)
+ );
+ die $error if $error;
print $cgi->redirect(popurl(3). "browse/agent_type.cgi");
}
diff --git a/httemplate/edit/process/cust_bill_pay.cgi b/httemplate/edit/process/cust_bill_pay.cgi
index 0025b16b5..fc668bb07 100755
--- a/httemplate/edit/process/cust_bill_pay.cgi
+++ b/httemplate/edit/process/cust_bill_pay.cgi
@@ -33,11 +33,19 @@ if ($cgi->param('invnum') =~ /^Refund$/) {
my $error = $new->insert;
if ( $error ) {
+
$cgi->param('error', $error);
- print $cgi->redirect(popurl(2). "cust_bill_pay.cgi?". $cgi->query_string );
+ %><%= $cgi->redirect(popurl(2). "cust_bill_pay.cgi?". $cgi->query_string ) %><%
+
} else {
- print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum");
-}
+ #print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum");
+
+ %><%= header('Payment application sucessful') %>
+ <SCRIPT TYPE="text/javascript">
+ window.top.location.reload();
+ </SCRIPT>
+
+ </BODY></HTML>
-%>
+<% } %>
diff --git a/httemplate/edit/process/cust_credit.cgi b/httemplate/edit/process/cust_credit.cgi
index 85bfd4489..6a4ef194a 100755
--- a/httemplate/edit/process/cust_credit.cgi
+++ b/httemplate/edit/process/cust_credit.cgi
@@ -13,14 +13,23 @@ my $error = $new->insert;
if ( $error ) {
$cgi->param('error', $error);
- print $cgi->redirect(popurl(2). "cust_credit.cgi?". $cgi->query_string );
+
+ %><%= $cgi->redirect(popurl(2). "cust_credit.cgi?". $cgi->query_string ) %><%
+
} else {
+
if ( $cgi->param('apply') eq 'yes' ) {
my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum })
or die "unknown custnum $custnum";
$cust_main->apply_credits;
}
- print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum");
-}
+ #print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum");
+
+ %><%= header('Credit sucessful') %>
+ <SCRIPT TYPE="text/javascript">
+ window.top.location.reload();
+ </SCRIPT>
+
+ </BODY></HTML>
-%>
+<% } %>
diff --git a/httemplate/edit/process/cust_credit_bill.cgi b/httemplate/edit/process/cust_credit_bill.cgi
index 28f892f62..3b759536f 100755
--- a/httemplate/edit/process/cust_credit_bill.cgi
+++ b/httemplate/edit/process/cust_credit_bill.cgi
@@ -34,11 +34,19 @@ if ($cgi->param('invnum') =~ /^Refund$/) {
my $error = $new->insert;
if ( $error ) {
+
$cgi->param('error', $error);
- print $cgi->redirect(popurl(2). "cust_credit_bill.cgi?". $cgi->query_string );
+ %><%= $cgi->redirect(popurl(2). "cust_credit_bill.cgi?". $cgi->query_string ) %><%
+
} else {
- print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum");
-}
+ #print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum");
+
+ %><%= header('Credit application sucessful') %>
+ <SCRIPT TYPE="text/javascript">
+ window.top.location.reload();
+ </SCRIPT>
+
+ </BODY></HTML>
-%>
+<% } %>
diff --git a/httemplate/edit/process/elements/process.html b/httemplate/edit/process/elements/process.html
index 83ff6f728..59ad35ee4 100644
--- a/httemplate/edit/process/elements/process.html
+++ b/httemplate/edit/process/elements/process.html
@@ -2,10 +2,21 @@
# options example...
#
+ ###
+ ##req
+ ##
# 'table' =>
+ #
# #? 'primary_key' => #required when the dbdef doesn't know...???
# #? 'fields' => []
+ #
+ ###
+ ##opt
+ ###
# 'viewall_dir' => '', #'search' or 'browse', defaults to 'search'
+ # 'process_m2m' => { 'link_table' => 'link_table_name',
+ # 'target_table' => 'target_table_name',
+ # }.
my(%opt) = @_;
@@ -31,12 +42,16 @@
if ( $pkeyvalue ) {
$error = $new->replace($old);
} else {
- warn $new;
$error = $new->insert;
- warn $error;
$pkeyvalue = $new->getfield($pkey);
}
+ if ( !$error && $opt{'process_m2m'} ) {
+ $error = $new->process_m2m( %{ $opt{'process_m2m'} },
+ 'params' => scalar($cgi->Vars),
+ );
+ }
+
if ( $error ) {
$cgi->param('error', $error);
print $cgi->redirect(popurl(2). "$table.html?". $cgi->query_string );