- add init file installation to Makefile, add unified init file
authorivan <ivan>
Fri, 19 Apr 2002 01:16:39 +0000 (01:16 +0000)
committerivan <ivan>
Fri, 19 Apr 2002 01:16:39 +0000 (01:16 +0000)
- fix qsearch for op => '!=', value => '' searches
- fix invalid_catd typo
- add payby method to part_pkg and have fs_signup_server pass the data

FS/FS/Record.pm
FS/FS/cust_main.pm
FS/FS/part_pkg.pm
Makefile
fs_signup/fs_signup_server
init.d/freeside-init [new file with mode: 0644]

index ed87b0c..ac8117e 100644 (file)
@@ -224,10 +224,24 @@ sub qsearch {
       }
 
       if ( ! defined( $record->{$_} ) || $record->{$_} eq '' ) {
-        if ( driver_name =~ /^Pg$/i ) {
-          qq-( $_ IS NULL OR $_ = '' )-;
+        if ( $op eq '=' ) {
+          if ( driver_name =~ /^Pg$/i ) {
+            qq-( $_ IS NULL OR $_ = '' )-;
+          } else {
+            qq-( $_ IS NULL OR $_ = "" )-;
+          }
+        } elsif ( $op eq '!=' ) {
+          if ( driver_name =~ /^Pg$/i ) {
+            qq-( $_ IS NOT NULL AND $_ != '' )-;
+          } else {
+            qq-( $_ IS NOT NULL AND $_ != "" )-;
+          }
         } else {
-          qq-( $_ IS NULL OR $_ = "" )-;
+          if ( driver_name =~ /^Pg$/i ) {
+            qq-( $_ $op '' )-;
+          } else {
+            qq-( $_ $op "" )-;
+          }
         }
       } else {
         "$_ $op ?";
index 66e032b..445c695 100644 (file)
@@ -644,11 +644,11 @@ sub check {
     my $payinfo = $self->payinfo;
     $payinfo =~ s/\D//g;
     $payinfo =~ /^(\d{13,16})$/
-      or return gettext('invalid_catd'); # . ": ". $self->payinfo;
+      or return gettext('invalid_card'); # . ": ". $self->payinfo;
     $payinfo = $1;
     $self->payinfo($payinfo);
     validate($payinfo)
-      or return gettext('invalid_catd'); # . ": ". $self->payinfo;
+      or return gettext('invalid_card'); # . ": ". $self->payinfo;
     return gettext('unknown_card_type')
       if cardtype($self->payinfo) eq "Unknown";
 
index 00ce1d9..e8cc677 100644 (file)
@@ -262,11 +262,33 @@ sub svcpart {
   $pkg_svc[0]->svcpart;
 }
 
+=item payby
+
+Returns a list of the acceptable payment types for this package.  Eventually
+this should come out of a database table and be editable, but currently has the
+following logic instead;
+
+If the package has B<0> setup and B<0> recur, the single item B<BILL> is
+returned, otherwise, the single item B<CARD> is returned.
+
+=cut
+
+sub payby {
+  my $self = shift;
+  #if ( $self->setup == 0 && $self->recur == 0 ) {
+  if (    $self->setup =~ /^\s*0+(\.0*)?\s*$/
+       && $self->recur =~ /^\s*0+(\.0*)?\s*$/ ) {
+    ( 'BILL' );
+  } else {
+    ( 'CARD' );
+  }
+}
+
 =back
 
 =head1 VERSION
 
-$Id: part_pkg.pm,v 1.9 2002-03-24 17:42:58 ivan Exp $
+$Id: part_pkg.pm,v 1.10 2002-04-19 01:16:39 ivan Exp $
 
 =head1 BUGS
 
index 21aeb45..315d430 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -13,8 +13,10 @@ ASP_GLOBAL = /usr/local/etc/freeside/asp-global
 
 FREESIDE_DOCUMENT_ROOT = /var/www/freeside
 
+INIT_FILE = /etc/init.d/freeside
+
 HTTPD_RESTART = /etc/init.d/apache restart
-QUEUED_RESTART = /etc/init.d/freeside restart
+FREESIDE_RESTART = /etc/init.d/freeside restart
 
 #---
 
@@ -74,11 +76,14 @@ install-perl-modules: perl-modules
        cd FS; \
        make install UNINST=1
 
-install: install-perl-modules install-docs
+install-init:
+       [ -e ${INIT_FILE} ] || install -o root -g root -m 711 init.d/freeside-init ${INIT_FILE}
+
+install: install-perl-modules install-docs install-init
 
 deploy: install
        ${HTTPD_RESTART}
-       ${QUEUED_RESTART}
+       ${FREESIDE_RESTART}
 
 create-database:
        perl -e 'use DBIx::DataSource qw( create_database ); create_database( "${DATASOURCE}", "${DB_USER}", "${DB_PASSWORD}" ) or die $$DBIx::DataSource::errstr;'
index 4abdafc..1618cf1 100755 (executable)
@@ -67,7 +67,8 @@ while (1) {
       
     'part_pkg' =>
       [
-        map { $_->hashref }
+        #map { $_->hashref }
+        map { { 'payby' => [ $_->payby ], %{$_->hashref} } }
           grep { $_->svcpart('svc_acct') && $pkgpart_href->{ $_->pkgpart } }
             qsearch( 'part_pkg', { 'disabled' => '' } )
       ],
diff --git a/init.d/freeside-init b/init.d/freeside-init
new file mode 100644 (file)
index 0000000..fd9e9e7
--- /dev/null
@@ -0,0 +1,58 @@
+#! /bin/sh
+#
+# chkconfig: 345 86 16
+# description: Freeside daemons
+
+QUEUED_USER=ivan
+
+FREESIDE_PATH="/home/ivan/freeside_current"
+
+PASSWD_USER=ivan
+PASSWD_MACHINE=localhost
+
+SIGNUP_USER=ivan
+SIGNUP_MACHINE=localhost
+SIGNUP_AGENTNUM=2
+SIGNUP_REFNUM=2
+
+case "$1" in
+  start)
+        # Start daemons.
+        echo -n "Starting freeside-queued: "
+        freeside-queued $QUEUED_USER
+        echo "done."
+
+        echo -n "Starting fs_passwd_server: "
+        su freeside -c "$FREESIDE_PATH/fs_passwd/fs_passwd_server $PASSWD_USER $PASSWD_MACHINE" &
+        echo "done."
+
+        echo -n "Starting fs_signup_server: "
+        su freeside -c "$FREESIDE_PATH/fs_signup/fs_signup_server $SIGNUP_USER $SIGNUP_MACHINE $SIGNUP_AGENTNUM $SIGNUP_REFNUM" &
+        echo "done."
+        ;;
+  stop)
+        # Stop daemons.
+        echo -n "Stopping freeside-queued: "
+        kill `cat /var/run/freeside-queued.pid`
+        echo "done."
+
+        echo -n "Stopping fs_passwd_server: "
+        killall fs_passwd_server
+        echo "done."
+
+        echo -n "Stopping fs_passwd_server: "
+        killall fs_signup_server
+        echo "done."
+        ;;
+
+  restart)
+        $0 stop
+        $0 start
+        ;;
+  *)
+        echo "Usage: freeside {start|stop|restart}"
+        exit 1
+esac
+
+exit 0
+