[freeside-commits] freeside/httemplate/elements select-table.html, 1.18, 1.19 select-part_pkg.html, 1.4, 1.5 tr-select-cust-part_pkg.html, 1.1, 1.2

Ivan,,, ivan at wavetail.420.am
Sat Jan 30 12:05:18 PST 2010


Update of /home/cvs/cvsroot/freeside/httemplate/elements
In directory wavetail.420.am:/tmp/cvs-serv5401/httemplate/elements

Modified Files:
	select-table.html select-part_pkg.html 
	tr-select-cust-part_pkg.html 
Log Message:
discounts, RT#6679

Index: select-table.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/select-table.html,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- select-table.html	29 Oct 2009 19:08:13 -0000	1.18
+++ select-table.html	30 Jan 2010 20:05:16 -0000	1.19
@@ -45,6 +45,10 @@
                             #<SELECT> element
     'onchange'       => '', #javascript code
 
+    #params (well, a param) controlling the <OPTION>s
+    'extra_option_attributes' => [ 'field' ], #field or method in $table objects
+                                              #(are prefixed w/data- per HTML5)
+
     #special return options
     'js_only'      => 0, #set true to return only the JS portions (i.e. nothing)
     'html_only'    => 0, #set true to return only the HTML portions (no-op, i.e. return everything)
@@ -89,6 +93,9 @@
             <% $opt{'all_selected'} || ref($value) && $value->{$recvalue} || $value == $recvalue
                ? ' SELECTED' : ''
             %>
+%           foreach my $att ( @{ $opt{'extra_option_attributes'} } ) {
+              data-<% $att %>="<% $record->$att() |h %>"
+%           }
     ><% $opt{'label_showkey'} ? "$recvalue: " : '' %>
      <% $opt{'label_callback'}
           ? &{ $opt{'label_callback'} }( $record )
@@ -106,6 +113,8 @@
 warn "elements/select-table.html: \n". Dumper(%opt)
   if exists $opt{debug} && $opt{debug};
 
+$opt{'extra_option_attributes'} ||= [];
+
 my $onchange = '';
 if ( $opt{'onchange'} ) {
   $onchange = $opt{'onchange'};

Index: tr-select-cust-part_pkg.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/tr-select-cust-part_pkg.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- tr-select-cust-part_pkg.html	28 Mar 2009 22:59:35 -0000	1.1
+++ tr-select-cust-part_pkg.html	30 Jan 2010 20:05:16 -0000	1.2
@@ -8,8 +8,9 @@
 
   <SCRIPT TYPE="text/javascript">
 
-    function opt(what,value,text) {
+    function part_pkg_opt(what,value,text,can_discount) {
       var optionName = new Option(text, value, false, false);
+      optionName.setAttribute('data-can_discount', can_discount);
       var length = what.length;
       what.options[length] = optionName;
     }
@@ -18,6 +19,10 @@
 
       what.form.pkgpart.disabled = 'disabled'; //disable part_pkg dropdown
       what.form.submit.disabled = true; //disable the submit button
+      var discountnum = what.form.discountnum;
+      if ( discountnum ) {
+        discountnum.disabled = true; //disable discount dropdown
+      }
 
       classnum = what.options[what.selectedIndex].value;
 
@@ -30,9 +35,12 @@
         // add the new packages
         opt(what.form.pkgpart, '', 'Select package');
         var packagesArray = eval('(' + part_pkg + ')' );
-        for ( var s = 0; s < packagesArray.length; s=s+2 ) {
+        for ( var s = 0; s < packagesArray.length; s=s+3 ) {
           var packagesLabel = packagesArray[s+1];
-          opt(what.form.pkgpart, packagesArray[s], packagesLabel);
+          var can_discount  = packagesArray[s+2];
+          part_pkg_opt(
+            what.form.pkgpart, packagesArray[s], packagesLabel, can_discount
+          );
         }
 
         what.form.pkgpart.disabled = ''; //re-enable part_pkg dropdown

Index: select-part_pkg.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/select-part_pkg.html,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- select-part_pkg.html	28 Mar 2009 22:59:35 -0000	1.4
+++ select-part_pkg.html	30 Jan 2010 20:05:16 -0000	1.5
@@ -23,6 +23,7 @@
               'empty_label'    => 'Select package', #should this be the default?
               'label_callback' => sub { shift->pkg_comment },
               'hashref'        => \%hash,
+              'extra_option_attributes' => [ 'can_discount' ],
               %opt,
           )
 %>



More information about the freeside-commits mailing list