voxlinesystems CDRs and quantity bs
authorivan <ivan>
Thu, 5 Jun 2008 19:24:33 +0000 (19:24 +0000)
committerivan <ivan>
Thu, 5 Jun 2008 19:24:33 +0000 (19:24 +0000)
FS/FS/cdr.pm
FS/FS/cust_main.pm
httemplate/edit/process/quick-charge.cgi
httemplate/edit/quick-charge.html
httemplate/search/cdr.html
httemplate/view/svc_phone.cgi

index adde898..5b1a4b4 100644 (file)
@@ -422,7 +422,7 @@ my %export_formats = (
   ],
   'voxlinesystems' => [
     sub { time2str('%D', shift->calldate_unix ) },   #DATE
-    sub { time2str('%T', shift->calldate_unix ) },   #TIME
+    sub { time2str('%r', shift->calldate_unix ) },   #TIME
     'userfield',                                     #USER
     'dst',                                           #NUMBER_DIALED
     sub { sprintf('%.2fm', shift->billsec / 60 ) },  #DURATION
@@ -729,9 +729,9 @@ my %import_formats = (
     'enddate',                            #End (also a timestamp!)
     sub { my($cdr, $field) = @_; },       #End date
     sub { my($cdr, $field) = @_; },       #End time
-    'accountcode',                        #Calling customer XXX map to agent_custid??
+    'accountcode',                        #Calling customer... map to agent_custid??
     sub { my($cdr, $field) = @_; },       #Calling type
-    sub { shift->src('30000'); }, #XXX FAKE XXX 'src',                                #Calling number
+    'src',
     'userfield',                          #Calling name #?
     sub { my($cdr, $field) = @_; },       #Called type
     'dst',                                #Called number
index 787a2ef..1f2fe88 100644 (file)
@@ -4675,9 +4675,10 @@ the error, otherwise returns false.
 
 sub charge {
   my $self = shift;
-  my ( $amount, $pkg, $comment, $taxclass, $additional, $classnum );
+  my ( $amount, $quantity, $pkg, $comment, $taxclass, $additional, $classnum );
   if ( ref( $_[0] ) ) {
     $amount     = $_[0]->{amount};
+    $quantity   = exists($_[0]->{quantity}) ? $_[0]->{quantity} : 1;
     $pkg        = exists($_[0]->{pkg}) ? $_[0]->{pkg} : 'One-time charge';
     $comment    = exists($_[0]->{comment}) ? $_[0]->{comment}
                                            : '$'. sprintf("%.2f",$amount);
@@ -4686,6 +4687,7 @@ sub charge {
     $additional = $_[0]->{additional};
   }else{
     $amount     = shift;
+    $quantity   = 1;
     $pkg        = @_ ? shift : 'One-time charge';
     $comment    = @_ ? shift : '$'. sprintf("%.2f",$amount);
     $taxclass   = @_ ? shift : '';
@@ -4738,8 +4740,9 @@ sub charge {
   }
 
   my $cust_pkg = new FS::cust_pkg ( {
-    'custnum' => $self->custnum,
-    'pkgpart' => $pkgpart,
+    'custnum'  => $self->custnum,
+    'pkgpart'  => $pkgpart,
+    'quantity' => $quantity,
   } );
 
   $error = $cust_pkg->insert;
index 22f9685..4c4927f 100644 (file)
@@ -30,6 +30,11 @@ $param->{"amount"} =~ /^\s*(\d+(\.\d{1,2})?)\s*$/
   or $error .= "Illegal amount " . $param->{"amount"} . "  ";
 my $amount = $1;
 
+my $quantity = 1;
+if ( $cgi->param('quantity') =~ /^\s*(\d+)\s*$/ ) {
+  $quantity = $1;
+}
+
 if ( $param->{'taxclass'} eq '(select)' ) {
   $error .= "Must select a tax class.  ";
 }
@@ -40,6 +45,7 @@ unless ( $error ) {
 
   $error ||= $cust_main->charge( {
     'amount'     => $amount,
+    'quantity'   => $quantity,
     'pkg'        => scalar($cgi->param('pkg')),
     'taxclass'   => scalar($cgi->param('taxclass')),
     'classnum'   => scalar($cgi->param('classnum')),
index 2dcbe51..d510150 100644 (file)
@@ -78,18 +78,32 @@ function validate_quick_charge () {
 <TABLE ID="QuickChargeTable" BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 STYLE="background-color: #cccccc">
 
 <TR>
-  <TD ALIGN="right">Amount:</TD>
+  <TD ALIGN="right">Amount: </TD>
   <TD>
     $<INPUT TYPE="text" NAME="amount" SIZE=6 VALUE="<% $amount %>" onChange="enable_quick_charge()" onKeyPress="enable_quick_charge_amount()">
   </TD>
+</TR>
+
+% if ( $conf->exists('invoice-unitprice') ) {
+    <TR>
+      <TD ALIGN="right">Quantity: </TD>
+      <TD>
+        <INPUT TYPE="text" NAME="quantity" SIZE=4 VALUE="<% $quantity %>">
+      </TD>
+    </TR>
+% }
+
 <% include('/elements/tr-select-pkg_class.html', 'curr_value' => $cgi->param('classnum') ) %>
+
 <% include('/elements/tr-select-taxclass.html', 'curr_value' => $cgi->param('taxclass') ) %>
-</TR>
+
+<TR>
   <TD>Description:</TD>
   <TD>
     <INPUT TYPE="text" NAME="pkg" SIZE="60" MAXLENGTH="65" VALUE="<% $pkg %>" onChange="enable_quick_charge()" onKeyPress="enable_quick_charge_desc()">
   </TD>
 </TR>
+
 <TR>
   <TD></TD>
   <TD><FONT SIZE="-1">Optional additional description: </FONT></TD>
@@ -114,7 +128,7 @@ function validate_quick_charge () {
 </TABLE>
 
 <BR>
-<INPUT TYPE="submit" NAME="submit" VALUE="Add one-time charge" <% $cgi->param('error') ? '' :' DISABLED' %>>
+<INPUT TYPE="submit" ID="submit" NAME="submit" VALUE="Add one-time charge" <% $cgi->param('error') ? '' :' DISABLED' %>>
 
 </FORM>
 
@@ -167,6 +181,8 @@ function validate_quick_charge () {
 die "access denied"
   unless $FS::CurrentUser::CurrentUser->access_right('One-time charge');
 
+my $conf = new FS::Conf;
+
 $cgi->param('custnum') =~ /^(\d+)$/ or die 'illegal custnum';
 my $custnum = $1;
 
@@ -175,6 +191,11 @@ if ( $cgi->param('amount') =~ /^\s*\$?\s*(\d+(\.\d{1,2})?)\s*$/ ) {
   $amount = $1;
 }
 
+my $quantity = 1;
+if ( $cgi->param('quantity') =~ /^\s*(\d+)\s*$/ ) {
+  $quantity = $1;
+}
+
 $cgi->param('pkg') =~ /^([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]]*)$/ 
   or die 'illegal description';
 my $pkg = $1;
index 8079b5b..4bac8c1 100644 (file)
@@ -61,7 +61,7 @@ push @search, FS::UI::Web::parse_lt_gt($cgi, 'duration');
 push @search, FS::UI::Web::parse_lt_gt($cgi, 'billsec');
 
 ###
-# src/dest
+# src/dest/charged_party
 ###
 
 my @qsearch = @search;
@@ -78,6 +78,18 @@ if ( $cgi->param('dst') =~ /^\s*([\d\-\+ ]+)\s*$/ ) {
   push @search, "dst = '$dst'";
 }
 
+if ( $cgi->param('charged_party') =~ /^\s*([\d\-\+\ ]+)\s*$/ ) {
+  ( my $charged_party = $1 ) =~ s/\D//g;
+  #$hashref->{'charged_party'} = $charged_party;
+  #push @search, "charged_party = '$charged_party'";
+  #XXX countrycode
+  push @search,  " (    charged_party = '$charged_party'
+                     OR charged_party = '1$charged_party' ) ";
+  push @qsearch, " (    charged_party = '$charged_party'
+                    OR charged_party = '1$charged_party' ) ";
+}
+
+
 ###
 # finish it up
 ###
index 8bd4dba..6f39860 100644 (file)
@@ -24,8 +24,12 @@ my $html_foot = sub {
 
   my $number = $svc_phone->phonenum;
 
+  #my @links = map {
+  #  qq(<A HREF="${p}search/cdr.html?src=$number;freesidestatus=$what{$_}">).
+  #  "View $_ CDRs</A>";
+  #} keys(%what);
   my @links = map {
-    qq(<A HREF="${p}search/cdr.html?src=$number;freesidestatus=$what{$_}">).
+    qq(<A HREF="${p}search/cdr.html?charged_party=$number;freesidestatus=$what{$_}">).
     "View $_ CDRs</A>";
   } keys(%what);