add cust_main-custom_content config item for Globelink's custom customer view, RT...
[freeside.git] / FS / FS / cust_pkg.pm
index 5ccdb35..788b1d3 100644 (file)
@@ -885,7 +885,9 @@ sub cancel_if_expired {
 locationnum, (other fields?).  Attempts to re-provision cancelled services
 using history information (errors at this stage are not fatal).
 
-cust_pkg: pass a scalar reference, will be filled in with
+cust_pkg: pass a scalar reference, will be filled in with the new cust_pkg object
+
+svc_fatal: service provisioning errors are fatal
 
 svc_errors: pass an array reference, will be filled in with any provisioning errors
 
@@ -968,9 +970,18 @@ sub uncancel {
     }
 
     my $svc_error = $svc_x->insert;
-    if ( $svc_error ) { #&& $options{svc_fatal} ) {
+    if ( $svc_error && $options{svc_fatal} ) {
       $dbh->rollback if $oldAutoCommit;
-      return $error;
+      return $svc_error;
+    } else {
+      my $cust_svc = qsearchs('cust_svc', { 'svcnum' => $svc_x->svcnum });
+      if ( $cust_svc ) {
+        my $cs_error = $cust_svc->delete;
+        if ( $cs_error ) {
+          $dbh->rollback if $oldAutoCommit;
+          return $cs_error;
+        }
+      }
     }
     push @svc_errors, $svc_error if $svc_error;
   }
@@ -2059,7 +2070,7 @@ sub cust_svc {
   }
   if ( $opt{'svcdb'} ) {
     $search{addl_from} = ' LEFT JOIN part_svc USING ( svcpart ) ';
-    $search{hashref}->{svcdb} = $opt{'svcdb'};
+    $search{extra_sql} = ' AND svcdb = '. dbh->quote( $opt{'svcdb'} );
   }
 
   cluck "cust_pkg->cust_svc called" if $DEBUG > 2;
@@ -3680,7 +3691,7 @@ sub _location_sql_where {
 
 #        ( $table.${prefix}city    = ? $or_empty_city   $ornull )
   "
-        ( $table.${prefix}district = ? OR ? = '' OR CAST(? AS text) IS NULL )
+        ( $table.district = ? OR ? = '' OR CAST(? AS text) IS NULL )
     AND ( $table.${prefix}city     = ? OR ? = '' OR CAST(? AS text) IS NULL )
     AND ( $table.${prefix}county   = ? $or_empty_county $ornull )
     AND ( $table.${prefix}state    = ? $or_empty_state  $ornull )