[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[6292] addons/1.3/wxPOS



Revision: 6292
          http://sourceforge.net/p/ledger-smb/code/6292
Author:   einhverfr
Date:     2013-11-16 08:27:24 +0000 (Sat, 16 Nov 2013)
Log Message:
-----------
Partnumber and description are now filtering combo boxes

Modified Paths:
--------------
    addons/1.3/wxPOS/WXPOS/Part.pm
    addons/1.3/wxPOS/WXPOS/UI/AP.pm
    addons/1.3/wxPOS/WXPOS/UI/AR.pm
    addons/1.3/wxPOS/setup/functions.sql

Modified: addons/1.3/wxPOS/WXPOS/Part.pm
===================================================================
--- addons/1.3/wxPOS/WXPOS/Part.pm	2013-11-15 13:49:46 UTC (rev 6291)
+++ addons/1.3/wxPOS/WXPOS/Part.pm	2013-11-16 08:27:24 UTC (rev 6292)
@@ -63,6 +63,23 @@
 
 =head1 METHODS
 
+=head2 get_autocomplet_list()
+
+Gets the autocomplete list. This is cached for the duration of the application.
+
+returns an arrayref.
+
+=cut
+
+my $autocomplete = undef;
+
+sub get_autocomplete_list {
+    my $class = shift @_;
+    return $autocomplete if defined $autocomplete;
+    @{$autocomplete} = $class->call_procedure(funcname => 'list');
+    return $autocomplete;
+}
+
 =head2 get_part_by_partnumber($partnumber, $contact_id, $entity_class)
 
 This retrieves the part and pricematrix given the partnumber, contact id, and 

Modified: addons/1.3/wxPOS/WXPOS/UI/AP.pm
===================================================================
--- addons/1.3/wxPOS/WXPOS/UI/AP.pm	2013-11-15 13:49:46 UTC (rev 6291)
+++ addons/1.3/wxPOS/WXPOS/UI/AP.pm	2013-11-16 08:27:24 UTC (rev 6292)
@@ -1,7 +1,7 @@
 package WXPOS::UI::AP;
 
 use Wx qw(wxDefaultPosition wxDefaultSize wxLI_HORIZONTAL wxCB_READONLY wxICON_ERROR wxOK wxCENTRE wxLC_REPORT wxLIST_NEXT_ALL wxLIST_STATE_SELECTED wxLIST_STATE_DONTCARE wxLIST_NEXT_BELOW wxLC_VIRTUAL);
-use Wx::Event qw(EVT_BUTTON EVT_LISTBOX_DCLICK EVT_COMBOBOX EVT_LIST_ITEM_RIGHT_CLICK EVT_LIST_ITEM_SELECTED EVT_LIST_ITEM_DESELECTED);
+use Wx::Event qw(EVT_BUTTON EVT_TEXT EVT_LISTBOX_DCLICK EVT_COMBOBOX EVT_LIST_ITEM_RIGHT_CLICK EVT_LIST_ITEM_SELECTED EVT_LIST_ITEM_DESELECTED);
 use base qw(Wx::Frame);
 use Wx::Grid;
 use WXPOS::Part;
@@ -24,8 +24,21 @@
 }
 
 ####### Invoice Screen
+my $pnumidx = {};
+my $pdescidx = {};
 sub Invoice {
  my ($self) = @_;
+
+ my $plist = WXPOS::Part->get_autocomplete_list;
+ my $pnumlist = [];
+ my $pdesclist = [];
+ my $have_index = values %$pnumidx;
+ for my $part (@$plist){
+     push @$pnumlist, $part->{partnumber};
+     push @$pdesclist, $part->{description};
+     $pdescidx->{$part->{description}} = $part unless $have_index;
+     $pnumidx->{$part->{partnumber}} = $part unless $have_index;
+ }
  $self->{sesion}->{tk} = undef;
  $self->{sesion}->{tk}->{items} = 0;
  $self->{tab} = Wx::Panel->new($self->{sesion}->{nb}, -1, wxDefaultPosition, wxDefaultSize);
@@ -51,10 +64,17 @@
  Wx::StaticLine->new($self->{tab}, -1, [0, 150], [800, 2], wxLI_HORIZONTAL);
 
 ### Line Entry
- $self->{part_numb} = Wx::TextCtrl->new($self->{tab}, -1, '', 
-                                     [10, 460], [80, 24]);
- $self->{desc} = Wx::TextCtrl->new($self->{tab}, -1, '', 
-                                     [90, 460], [250, 24]);
+ $self->{part_numb} = Wx::ComboBox->new($self->{tab}, -1, '', 
+                                     [10, 460], [80, 24], $pnumlist);
+ EVT_TEXT($self->{tab}, $self->{part_numb}, 
+          sub {$self->_autocomplete('part_numb', 
+                                      [10, 460], [80, 24], $pnumlist)});
+ $self->{desc} = Wx::ComboBox->new($self->{tab}, -1, '', 
+                                     [90, 460], [250, 24], $pdesclist);
+ EVT_TEXT($self->{tab}, $self->{desc}, 
+          sub {$self->_autocomplete('desc', 
+                                      [90, 460], [250,24], $pdesclist)});
+ EVT_COMBOBOX($self->{tab}, $self->{desc}, sub { $self->_selectDesc } );
  my $parts_but = Wx::Button->new($self->{tab}, -1, 'Search', [440, 120], [60, 24]);
  EVT_BUTTON($self->{tab}, $parts_but, sub{$self->_listPartsByName});
  $self->{part_sellprice} 
@@ -150,14 +170,6 @@
  return $self->{parts_list};
 }
 
-sub _getPartsNumber {
- my($self, $event) = @_;
- my $numb = $self->{parts_search}->{$self->{parts_list}->GetValue()};
- $self->{part_numb}->SetValue($numb);
- return $self->{part_numb};
-}
-
-
 sub _addParts {
  my($self, $event) = @_;
  my $part = $self->{part_numb}->GetValue();
@@ -218,6 +230,29 @@
  return $part;
 }
 
+### Autocomplete
+#
+sub _autocomplete {
+    my ($self, $control, $place, $size, $list) = @_;
+    my $string = $self->{$control}->GetValue();
+    my $newlist = [];
+    push @$newlist, $_ for (grep /$string/, @$list);
+    $self->{$control}->Clear;
+   
+    $self->{$control}->Append($_) for @$newlist;
+    if ($control eq 'desc' and @$newlist 
+        and $string eq $newlist->[0]
+     ){
+        $self->{part_numb}->SetValue(
+             $pdescidx->{$string}->{partnumber});
+    }
+}
+
+sub _selectDesc {
+    my ($self) = @_;
+    my $val = $self->{desc}->GetString($self->{desc}->GetSelection);
+}
+
 sub _selParts {
  my($self) = @_;
  $self->{sel_del}->SetLabel($self->{list}->GetSelectedItemCount);

Modified: addons/1.3/wxPOS/WXPOS/UI/AR.pm
===================================================================
--- addons/1.3/wxPOS/WXPOS/UI/AR.pm	2013-11-15 13:49:46 UTC (rev 6291)
+++ addons/1.3/wxPOS/WXPOS/UI/AR.pm	2013-11-16 08:27:24 UTC (rev 6292)
@@ -1,7 +1,7 @@
 package WXPOS::UI::AR;
 
 use Wx qw(wxDefaultPosition wxDefaultSize wxLI_HORIZONTAL wxCB_READONLY wxICON_ERROR wxOK wxCENTRE wxLC_REPORT wxLIST_NEXT_ALL wxLIST_STATE_SELECTED wxLIST_STATE_DONTCARE wxLIST_NEXT_BELOW wxLC_VIRTUAL);
-use Wx::Event qw(EVT_BUTTON EVT_LISTBOX_DCLICK EVT_COMBOBOX EVT_LIST_ITEM_RIGHT_CLICK EVT_LIST_ITEM_SELECTED EVT_LIST_ITEM_DESELECTED);
+use Wx::Event qw(EVT_BUTTON EVT_TEXT EVT_LISTBOX_DCLICK EVT_COMBOBOX EVT_LIST_ITEM_RIGHT_CLICK EVT_LIST_ITEM_SELECTED EVT_LIST_ITEM_DESELECTED);
 use base qw(Wx::Frame);
 use Wx::Grid;
 use WXPOS::Part;
@@ -25,8 +25,21 @@
 }
 
 ####### Invoice Screen
+my $pnumidx = {};
+my $pdescidx = {};
 sub Invoice {
  my ($self) = @_;
+
+ my $plist = WXPOS::Part->get_autocomplete_list;
+ my $pnumlist = [];
+ my $pdesclist = [];
+ my $have_index = values %$pnumidx;
+ for my $part (@$plist){
+     push @$pnumlist, $part->{partnumber};
+     push @$pdesclist, $part->{description};
+     $pdescidx->{$part->{description}} = $part unless $have_index;
+     $pnumidx->{$part->{partnumber}} = $part unless $have_index;
+ }
  $self->{sesion}->{tk} = undef;
  $self->{sesion}->{tk}->{items} = 0;
  $self->{tab} = Wx::Panel->new($self->{sesion}->{nb}, -1, wxDefaultPosition, wxDefaultSize);
@@ -52,10 +65,17 @@
  Wx::StaticLine->new($self->{tab}, -1, [0, 150], [800, 2], wxLI_HORIZONTAL);
 
 ### Line Entry
- $self->{part_numb} = Wx::TextCtrl->new($self->{tab}, -1, '', 
-                                     [10, 460], [80, 24]);
- $self->{desc} = Wx::TextCtrl->new($self->{tab}, -1, '', 
-                                     [90, 460], [250, 24]);
+ $self->{part_numb} = Wx::ComboBox->new($self->{tab}, -1, '', 
+                                     [10, 460], [80, 24], $pnumlist);
+ EVT_TEXT($self->{tab}, $self->{part_numb}, 
+          sub {$self->_autocomplete('part_numb', 
+                                      [10, 460], [80, 24], $pnumlist)});
+ $self->{desc} = Wx::ComboBox->new($self->{tab}, -1, '', 
+                                     [90, 460], [250, 24], $pdesclist);
+ EVT_TEXT($self->{tab}, $self->{desc}, 
+          sub {$self->_autocomplete('desc', 
+                                      [90, 460], [250,24], $pdesclist)});
+ EVT_COMBOBOX($self->{tab}, $self->{desc}, sub { $self->_selectDesc } );
  my $parts_but = Wx::Button->new($self->{tab}, -1, 'Search', [440, 120], [60, 24]);
  EVT_BUTTON($self->{tab}, $parts_but, sub{$self->_listPartsByName});
  $self->{part_sellprice} 
@@ -103,17 +123,34 @@
  if ($dft_custom){
     $self->_listCustomByName;
  }
+ $self->{part_numb}->SetFocus();
  return $self->{tab};
 }
 #######
 
-sub Transaction {
- my ($self) = @_;
- $self->{tab} = Wx::Panel->new($self->{sesion}->{nb}, -1, wxDefaultPosition, wxDefaultSize);
- Wx::StaticText->new($self->{tab}, -1, 'WIP', [400, 300], [100, 24]);
- return $self->{tab};
+### Autocomplete
+#
+sub _autocomplete {
+    my ($self, $control, $place, $size, $list) = @_;
+    my $string = $self->{$control}->GetValue();
+    my $newlist = [];
+    push @$newlist, $_ for (grep /$string/, @$list);
+    $self->{$control}->Clear;
+   
+    $self->{$control}->Append($_) for @$newlist;
+    if ($control eq 'desc' and @$newlist 
+        and $string eq $newlist->[0]
+     ){
+        $self->{part_numb}->SetValue(
+             $pdescidx->{$string}->{partnumber});
+    }
 }
 
+sub _selectDesc {
+    my ($self) = @_;
+    my $val = $self->{desc}->GetString($self->{desc}->GetSelection);
+}
+
 sub Customer {
  my ($self) = @_;
  $self->{tab} = Wx::Panel->new($self->{sesion}->{nb}, -1, wxDefaultPosition, wxDefaultSize);
@@ -165,14 +202,6 @@
  return $self->{parts_list};
 }
 
-sub _getPartsNumber {
- my($self, $event) = @_;
- my $numb = $self->{parts_search}->{$self->{parts_list}->GetValue()};
- $self->{part_numb}->SetValue($numb);
- return $self->{part_numb};
-}
-
-
 sub _addParts {
  my($self, $event) = @_;
  my $part = $self->{part_numb}->GetValue();

Modified: addons/1.3/wxPOS/setup/functions.sql
===================================================================
--- addons/1.3/wxPOS/setup/functions.sql	2013-11-15 13:49:46 UTC (rev 6291)
+++ addons/1.3/wxPOS/setup/functions.sql	2013-11-16 08:27:24 UTC (rev 6292)
@@ -92,6 +92,15 @@
 END;
 $$;
 
+CREATE OR REPLACE FUNCTION wxpos_part__list ()
+RETURNS SETOF parts LANGUAGE SQL AS $$
+
+SELECT * FROM parts 
+ WHERE EXISTS (select 1 FROM defaults 
+                WHERE setting_key = 'wxpos_autocomplete_parts' AND value = '1')
+ ORDER BY partnumber;
+$$;
+
 CREATE OR REPLACE FUNCTION wxpos_part__search
 (in_string text, in_contact_id int, in_contact_class int)
 RETURNS SETOF parts LANGUAGE PLPGSQL AS
@@ -149,4 +158,5 @@
        (e.name @@ plainto_tsquery($1) OR eca.pay_to_name @@plainto_tsquery($1));
 $$;
 
+
 COMMIT;

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


------------------------------------------------------------------------------
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits