RT# 77532 - can search cust main phone numbers in advanced customer search
[freeside.git] / httemplate / search / report_cust_main.html
index 6721174..3dd92af 100755 (executable)
-<% include('/elements/header.html', 'Customer Report' ) %>
+<& /elements/header.html, mt('Customer Report') &>
 
 <FORM ACTION="cust_main.html" METHOD="GET">
 <INPUT TYPE="hidden" NAME="magic" VALUE="bill">
 
-  <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
+  <FONT CLASS="fsinnerbox-title"><% emt('Basic search options') %></FONT>
+  <TABLE CLASS="fsinnerbox">
 
-    <TR>
-      <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1">Search options</FONT></TH>
-    </TR>
-
-    <% include( '/elements/tr-select-agent.html',
+    <& /elements/tr-select-agent.html,
                   'curr_value'    => scalar($cgi->param('agentnum')),
                   'disable_empty' => 0,
-               )
-    %>
+    &>
 
-    <% include( '/elements/tr-select-cust_main-status.html',
-                  'label' => 'Status'
-              )
-    %>
+    <& /elements/tr-select-sales.html,
+                  'curr_value'    => scalar($cgi->param('salesnum')),
+                  'pre_options'   => [ '' => 'all',
+                                       0  => '(none)', ],
+                  'disable_empty' => 1,
+                  'th' => 1,
+    &>
 
-    <% include( '/elements/tr-select-cust_class.html',
-                  'label'        => 'Class',
+    <& /elements/tr-select-cust_main-status.html,
+                  'label' => emt('Status'),
+    &>
+
+    <& /elements/tr-select-cust_class.html,
+                  'label'        => emt('Class'),
                   'multiple'     => 1,
-                  'pre_options'  => [ '' => '(none)' ],
+                  'pre_options'  => [ '' => emt('(none)') ],
                   'all_selected' => 1,
-              )
-    %>
+    &>
+
+    <& /elements/tr-select-part_referral.html,
+                  'label'        => emt('Advertising Source'),
+                  'multiple'     => 1,
+                  #no, causes customers with disabled ones to disappear
+                  #'all_selected' => 1,
+    &>
 
     <TR>
-      <TD ALIGN="right" VALIGN="center">Address</TD>
-      <TD><INPUT TYPE="text" NAME="address" SIZE=54></TD>
+        <TH ALIGN="right" VALIGN="center"><% mt('Signup date') |h %></TH>
+        <TD>
+        <TABLE>
+            <& /elements/tr-input-beginning_ending.html,
+                      prefix   => 'signupdate',
+                      layout   => 'horiz',
+            &>
+        </TABLE>
+        </TD>
     </TR>
 
-%   foreach my $field (qw( signupdate )) {
+%    if ( $conf->exists('cust_main-enable_birthdate') ) {
+      <TR>
+          <TH ALIGN="right" VALIGN="center"><% mt('Date of Birth') |h %></TH>
+          <TD>
+          <TABLE>
+              <& /elements/tr-input-beginning_ending.html,
+                        prefix   => 'birthdate',
+                        layout   => 'horiz',
+              &>
+          </TABLE>
+          </TD>
+      </TR>
+%   }
 
+%    if ( $conf->exists('cust_main-enable_spouse_birthdate') ) {
       <TR>
-        <TD ALIGN="right" VALIGN="center"><% $label{$field} %></TD>
-        <TD>
+          <TH ALIGN="right" VALIGN="center"><% mt('Spouse Date of Birth') |h %></TH>
+          <TD>
           <TABLE>
-            <% include( '/elements/tr-input-beginning_ending.html',
-                          prefix   => $field,
-                          layout   => 'horiz',
-                      )
-            %>
+              <& /elements/tr-input-beginning_ending.html,
+                        prefix   => 'spouse_birthdate',
+                        layout   => 'horiz',
+              &>
           </TABLE>
-        </TD>
+          </TD>
       </TR>
+%   }
 
+%    if ( $conf->exists('cust_main-enable_anniversary_date') ) {
+      <TR>
+          <TH ALIGN="right" VALIGN="center"><% mt('Anniversary Date') |h %></TH>
+          <TD>
+          <TABLE>
+              <& /elements/tr-input-beginning_ending.html,
+                        prefix   => 'anniversary_date',
+                        layout   => 'horiz',
+              &>
+          </TABLE>
+          </TD>
+      </TR>
 %   }
 
-    <% include( '/elements/tr-select-cust_tag.html',
-                 'cgi'          => $cgi,
-                 'is_report'    => 1,
-                  'multiple'     => 1,
-              )
-    %>
+      <TR>
+        <TH ALIGN="right">Tags</TH>
+        <TD>
+            <& /elements/select-cust_tag.html,
+                          'cgi'                => $cgi,
+                          'is_report'   => 1,
+                          'multiple'    => 1,
+            &>
+          <DIV STYLE="display:inline-block; vertical-align:baseline">
+            <INPUT TYPE="radio" NAME="all_tags" VALUE="0" CHECKED> Any of these
+            <BR>
+            <INPUT TYPE="radio" NAME="all_tags" VALUE="all"> All of these
+            <BR>
+            <INPUT TYPE="radio" NAME="all_tags" VALUE="none"> None of these
+          </DIV>
+        </TD>
+      </TR>
 
-    <% include( '/elements/tr-select-payby.html',
-                  'payby_type'   => 'cust',
-                  'multiple'     => 1,
-                  'all_selected' => 1,
-              )
-    %>
+  </TABLE>
+  <BR>
+
+  <FONT CLASS="fsinnerbox-title"><% emt('Referral search options') %></FONT>
+  <TABLE CLASS="fsinnerbox">
+
+      <& /elements/tr-input-text.html,
+           label     => emt('At least this many'),
+           field     => 'with_referrals',
+           size      => 4,
+           maxlength => 4,
+      &>
+
+      <& /elements/tr-select-cust_main-status.html,
+           label => emt('Referral status'),
+           field => 'referral_status',
+      &>
+
+  </TABLE>
+  <BR>
+
+  <FONT CLASS="fsinnerbox-title"><% emt('Package search options') %></FONT>
+  <TABLE CLASS="fsinnerbox">
+
+      <TR>
+
+        <TH ALIGN="right">With</TH>
+        <TD><SELECT NAME="any_pkg_status">
+              <OPTION VALUE="0">active packages
+              <OPTION VALUE="1">any status packages
+            </SELECT>
+        </TD>
+     </TR>
+
+        <TH ALIGN="right">of class</TH>
+        <TD>
+            <& /elements/select-pkg_class.html,
+                          'field'       => 'pkg_classnum',
+                          'multiple'    => 1,
+            &>
+          <DIV STYLE="display:inline-block; vertical-align:baseline">
+            <INPUT TYPE="radio" NAME="all_pkg_classnums" VALUE="0" CHECKED>
+              Any of these
+            <BR>
+            <INPUT TYPE="radio" NAME="all_pkg_classnums" VALUE="1">
+              All of these
+          </DIV>
+        </TD>
+      </TR>
+
+  </TABLE>
+  <BR>
+
+  <FONT CLASS="fsinnerbox-title"><% emt('Location search options') %></FONT>
+  <TABLE CLASS="fsinnerbox">
+    <& elements/options_cust_location.html &>
+    <& elements/cust_main_phones.html &>
+  </TABLE>
+  <BR>
+
+  <FONT CLASS="fsinnerbox-title"><% emt('Contacts search options') %></FONT>
+  <TABLE CLASS="fsinnerbox">
+    <& elements/options_cust_contacts.html,
+        'pre_fix'   => 'contacts_',
+    &>
+  </TABLE>
+  <BR>
+
+  <FONT CLASS="fsinnerbox-title"><% emt('Billing search options') %></FONT>
+  <TABLE CLASS="fsinnerbox">
+
+% my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
+% unless ( @exempt_groups ) { 
+
+%   #falze laziness with With/Without postal mail invoices
+     <TR>
+      <TH ALIGN="right" VALIGN="center"><% mt('Tax exempt') |h %></TH>
+        <TD><INPUT TYPE="checkbox" NAME="tax" ID="tax" onClick="tax_changed();"></TD>
+    </TR>
 
     <TR>
-      <TD ALIGN="right">Payment expiration before</TD>
-      <TD>
-        <SELECT NAME="paydate_month" DISABLED>
-%         foreach my $month ( 1 .. 12 ) {
-            <OPTION VALUE="<% $month %>"><% $month %></OPTION>
-%         }
-        </SELECT>
-        /
-        <SELECT NAME="paydate_year" onChange="paydate_year_changed(this);">
-          <OPTION VALUE=""></OPTION>
-%         my $lastyear = (localtime(time))[5] + 1899;
-%         foreach my $year ( $lastyear .. $lastyear+12 ) {
-            <OPTION VALUE="<% $year %>"><% $year %></OPTION>
-%         }
-        </SELECT>
-      </TD>
+      <TH ALIGN="right" VALIGN="center"><% mt('Not tax exempt') |h %></TH>
+        <TD><INPUT TYPE="checkbox" NAME="no_tax" ID="no_tax" onClick="no_tax_changed();"></TD>
     </TR>
 
     <SCRIPT TYPE="text/javascript">
-      function paydate_year_changed(what) {
-        var value = what.options[what.selectedIndex].value;
-        var month_select = what.form.paydate_month;
-        if ( value == '' ) {
-          month_select.disabled = true;
-        } else {
-          month_select.disabled = false;
+      function  tax_changed() {
+        if ( document.getElementById('tax').checked == true ) {
+          document.getElementById('no_tax').checked = false;
+        }
+      }
+      function no_tax_changed() {
+        if ( document.getElementById('no_tax').checked == true ) {
+          document.getElementById('tax').checked = false;
         }
       }
     </SCRIPT>
+% }
+
     <TR>
-      <TD ALIGN="right">Invoice terms</TD>
+      <TH ALIGN="right"><% mt('Invoice terms') |h %></TH>
       <TD>
-        <% include( '/elements/select-terms.html',
-                      'pre_options' => [ '' => 'all' ],
-                      'empty_value' => 'NULL',
-                  )
-        %>
+%       my @agentnums = $FS::CurrentUser::CurrentUser->agentnums;
+%       my $agentnum = scalar(@agentnums) == 1 ? $agentnums[0] : '';
+        <& /elements/select-terms.html,
+             'pre_options' => [ '' => emt('all') ],
+             'empty_value' => 'NULL',
+             'agentnum'    => $agentnum,
+        &>
       </TD>
     </TR>
     
-    <% include( '/elements/tr-input-lessthan_greaterthan.html',
-                  label   => 'Current balance',
+    <& /elements/tr-input-lessthan_greaterthan.html,
+                  label   => emt('Current balance'),
                   field   => 'current_balance',
-              )
-    %>
+    &>
 
     <TR>
-      <TD ALIGN="right" VALIGN="center">Include cancelled packages</TD>
-        <TD><INPUT TYPE="checkbox" NAME="cancelled_pkgs"></TD>
+      <TH ALIGN="right" VALIGN="center"><% mt('With invoicing email address(es)') |h %></TH>
+        <TD><INPUT TYPE="checkbox" NAME="with_email"></TD>
     </TR>
 
     <TR>
-      <TD ALIGN="right" VALIGN="center">Without census tract</TD>
-        <TD><INPUT TYPE="checkbox" NAME="no_censustract"></TD>
+      <TH ALIGN="right" VALIGN="center"><% mt('With postal mail invoices') |h %></TH>
+        <TD><INPUT TYPE="checkbox" NAME="POST" ID="POST" onClick="POST_changed();"></TD>
     </TR>
 
-%   if ( $conf->exists('enable_taxproducts') ) {
+    <TR>
+      <TH ALIGN="right" VALIGN="center"><% mt('Without postal mail invoices') |h %></TH>
+        <TD><INPUT TYPE="checkbox" NAME="no_POST" ID="no_POST" onClick="no_POST_changed();"></TD>
+    </TR>
 
-      <TR>
-        <TD ALIGN="right" VALIGN="center">With hardcoded tax location</TD>
-          <TD><INPUT TYPE="checkbox" NAME="with_geocode"></TD>
-      </TR>
+    <SCRIPT TYPE="text/javascript">
+      function POST_changed() {
+        if ( document.getElementById('POST').checked == true ) {
+          document.getElementById('no_POST').checked = false;
+        }
+      }
+      function no_POST_changed() {
+        if ( document.getElementById('no_POST').checked == true ) {
+          document.getElementById('POST').checked = false;
+        }
+      }
+    </SCRIPT>
 
-%   }
+  </TABLE>
+  <BR>
 
-    <TR>
-      <TH CLASS="background" COLSPAN=2>&nbsp;</TH>
-    </TR>
+  <FONT CLASS="fsinnerbox-title"><% emt('Display options') %></FONT>
+  <TABLE CLASS="fsinnerbox">
+
+    <& /elements/tr-select-cust-fields.html &>
 
     <TR>
-      <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1">Display options</FONT></TH>
+      <TH ALIGN="right" VALIGN="center"><% mt('Add package columns') |h %></TH>
+        <TD><INPUT TYPE="checkbox" NAME="flattened_pkgs"></TD>
     </TR>
-    <% include( '/elements/tr-select-cust-fields.html' ) %>
 
     <TR>
-      <TD ALIGN="right" VALIGN="center">Add package columns</TD>
-        <TD><INPUT TYPE="checkbox" NAME="flattened_pkgs"></TD>
+      <TH ALIGN="right" VALIGN="center"><% mt('Include cancelled packages') |h %></TH>
+        <TD><INPUT TYPE="checkbox" NAME="cancelled_pkgs"></TD>
     </TR>
+
   </TABLE>
 
 <BR>
-<INPUT TYPE="submit" VALUE="Get Report">
+<INPUT TYPE="submit" VALUE="<% mt('Get Report') |h %>">
 
 </FORM>
 
-<% include('/elements/footer.html') %>
+<& /elements/footer.html &>
 <%init>
 
 die "access denied"
-  unless ( $FS::CurrentUser::CurrentUser->access_right('List customers') &&
-           $FS::CurrentUser::CurrentUser->access_right('List packages')
-         );
+  unless $FS::CurrentUser::CurrentUser->access_right('Advanced customer search');
 
 my $conf = new FS::Conf;
 
 </%init>
-<%once>
-
-my %label = (
-  'signupdate'     => 'Signup date',
-);
-
-</%once>