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

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



Revision: 4637
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4637&view=rev
Author:   einhverfr
Date:     2012-03-31 11:00:28 +0000 (Sat, 31 Mar 2012)
Log Message:
-----------
Adding Andres Basile's wxPerl POS client

Added Paths:
-----------
    addons/1.3/wxPOS/
    addons/1.3/wxPOS/LedgerSMB.pl
    addons/1.3/wxPOS/scripts/
    addons/1.3/wxPOS/scripts/AR.pm
    addons/1.3/wxPOS/scripts/ConsoleWx.pm
    addons/1.3/wxPOS/scripts/IC.pm
    addons/1.3/wxPOS/scripts/LoginWx.pm

Added: addons/1.3/wxPOS/LedgerSMB.pl
===================================================================
--- addons/1.3/wxPOS/LedgerSMB.pl	                        (rev 0)
+++ addons/1.3/wxPOS/LedgerSMB.pl	2012-03-31 11:00:28 UTC (rev 4637)
@@ -0,0 +1,24 @@
+#!/usr/bin/perl -w
+
+use strict;
+use Wx;
+use lib "scripts";
+
+package LsmbWx;
+use base 'Wx::App';
+
+sub OnInit {
+ my ($class) = @_;
+ use ConsoleWx;
+ my $console = ConsoleWx->new();
+ $class->SetTopWindow($console);
+ $console->Show(1);
+ $console->SetIcon( Wx::GetWxPerlIcon() );
+ return 1;
+}
+
+# LooP
+package main;
+
+my $app = LsmbWx->new;
+$app->MainLoop;


Property changes on: addons/1.3/wxPOS/LedgerSMB.pl
___________________________________________________________________
Added: svn:executable
   + *

Added: addons/1.3/wxPOS/scripts/AR.pm
===================================================================
--- addons/1.3/wxPOS/scripts/AR.pm	                        (rev 0)
+++ addons/1.3/wxPOS/scripts/AR.pm	2012-03-31 11:00:28 UTC (rev 4637)
@@ -0,0 +1,53 @@
+package AR;
+
+use base qw(Wx::Frame);
+use Wx::Event qw(EVT_BUTTON);
+use Wx qw(wxDefaultPosition wxDefaultSize);
+use Wx::Grid;
+
+sub new {
+ my ($class, $dbh, $parent, $action) = @_;
+ $class->{dbh} = $dbh;
+ return $class->$action($parent);
+}
+
+sub Invoice {
+ my ($class, $parent) = @_;
+ $class->{WxPanel} = Wx::Panel->new($parent, -1, wxDefaultPosition, wxDefaultSize);
+ $class->{custom} = Wx::TextCtrl->new($class->{WxPanel}, -1, 'Customer', [50, 100], [100, 20]);
+ my $button = Wx::Button->new($class->{WxPanel}, -1, 'Search', [150, 100], [100, 20]);
+ EVT_BUTTON($class->{WxPanel}, $button, sub{$class->CustomSearch});
+ $class->{WxPanel}->{'in_num'} = Wx::TextCtrl->new($class->{WxPanel}, -1, 'Invoice Number', [50, 220], [100, 20]);
+ $class->{WxPanel}->{'or_num'} = Wx::TextCtrl->new($class->{WxPanel}, -1, 'Order Number', [50, 240], [100, 20]);
+ return $class->{WxPanel};
+}
+
+sub Transaction {
+ my ($class, $parent) = @_;
+ $class->{WxPanel} = Wx::Panel->new($parent, -1, wxDefaultPosition, wxDefaultSize);
+ $class->{custom} = Wx::TextCtrl->new($class->{WxPanel}, -1, 'Customer', [50, 100], [100, 20]);
+ $class->{'in_num'} = Wx::TextCtrl->new($class->{WxPanel}, -1, 'Invoice Number', [50, 120], [100, 20]);
+ $class->{'or_num'} = Wx::TextCtrl->new($class->{WxPanel}, -1, 'Order Number', [50, 140], [100, 20]);
+ return $class->{WxPanel};
+}
+
+sub Customer {
+ my ($class, $parent) = @_;
+ $class->{WxPanel} = Wx::Panel->new($parent, -1, wxDefaultPosition, wxDefaultSize);
+ $class->{custom} = Wx::TextCtrl->new($class->{WxPanel}, -1, 'Name', [50, 120], [100, 20]);
+ my $button = Wx::Button->new($class->{WxPanel}, -1, 'Search', [50, 160], [100, 20]);
+ EVT_BUTTON($class->{WxPanel}, $button, sub{$class->CustomSearch});
+ $class->{list} = Wx::Grid->new($class->{WxPanel}, -1, [50, 200], [500, 500]);
+ $class->{list}->CreateGrid(0, 2);
+ return $class->{WxPanel};
+}
+
+sub CustomSearch {
+ my($self, $event) = @_;
+ my $customer = $self->{custom}->GetValue();
+ my $sql = "SELECT id, name FROM public.entity WHERE entity_class = \'1\' AND name ILIKE \'%".$customer."%\'";
+ my ($list) = $self->{dbh}->selectall_arrayref($sql);
+ $self->{customer_list} = Wx::ListBox->new($self->{WxPanel}, -1, [250, 100], [150, 80], $list);
+ return $self->{customer_list};
+}
+1;

Added: addons/1.3/wxPOS/scripts/ConsoleWx.pm
===================================================================
--- addons/1.3/wxPOS/scripts/ConsoleWx.pm	                        (rev 0)
+++ addons/1.3/wxPOS/scripts/ConsoleWx.pm	2012-03-31 11:00:28 UTC (rev 4637)
@@ -0,0 +1,98 @@
+package ConsoleWx;
+
+use base qw(Wx::Frame);
+use Wx::Event;
+use Wx::Menu;
+use Wx qw(wxDefaultPosition wxDefaultSize wxDEFAULT_FRAME_STYLE wxNO_FULL_REPAINT_ON_RESIZE wxCLIP_CHILDREN);
+use Wx::Event qw(EVT_TREE_SEL_CHANGED EVT_CLOSE EVT_IDLE EVT_MENU);
+
+sub new {
+ my ($class) = @_;
+ my $self = $class->SUPER::new(undef, -1, 'LedgerSMB', wxDefaultPosition, [800, 600]);
+
+### First at all, login and get a db handler
+#
+ use LoginWx;
+ my $login = LoginWx->new();
+ $login->ShowModal();
+ $self->{dbh} = $login->{dbh};
+ $login->Destroy();
+#
+###
+
+### TODO
+# The idea would be to init LedgerSMB class here.
+# my $sql = "SELECT id, label, parent, position FROM public.menu_node";
+# my $menu_list = $self->{dbh}->selectall_arrayref($sql);
+###
+
+### Notebook (tabs)
+#
+ $self->{nb} = Wx::Notebook->new($self, -1, wxDefaultPosition, wxDefaultSize, wxNO_FULL_REPAINT_ON_RESIZE|wxCLIP_CHILDREN);
+#
+###
+
+### Menu
+# TODO: It should be loaded/created on demand according to user acl.
+#
+ my($ID_FILE, $ID_ABOUT, $ID_EXIT, $ID_AR, $AR_INVOICE, $AR_TRANSACTION, $AR_CUSTOMER, $ID_AP, $ID_IC, $IC_SEARCH) = (100 .. 200);
+ my $bar = Wx::MenuBar->new;
+
+ my $file = Wx::Menu->new;
+ $file->Append($ID_ABOUT, "&About");
+ EVT_MENU($self, $ID_ABOUT, \&about);
+ $file->Append($ID_EXIT, "&Exit");
+ EVT_MENU($self, $ID_EXIT, \&logout);
+ $bar->Append($file, "&File" );
+
+ my $ar = Wx::Menu->new;
+ $ar->Append($AR_INVOICE, "&Invoice");
+ EVT_MENU($self, $AR_INVOICE, sub{$self->load_module(AR, Invoice)});
+ $ar->Append($AR_TRANSACTION, "&Transaction");
+ EVT_MENU($self, $AR_TRANSACTION, sub{$self->load_module(AR, Transaction)});
+ $ar->Append($AR_CUSTOMER, "&Customer");
+ EVT_MENU($self, $AR_CUSTOMER, sub{$self->load_module(AR, Customer)});
+ $bar->Append($ar, "&AR" );
+
+ my $ic = Wx::Menu->new;
+ $ic->Append($IC_SEARCH, "&Search");
+ EVT_MENU($self, $IC_SEARCH, sub{$self->load_module(IC, Search)});
+ $bar->Append($ic, "&Inventory" );
+
+ $self->SetMenuBar($bar);
+#
+###
+ return $self;
+}
+
+### Basic Commands
+#
+sub about {
+ my ($self) = @_;
+ use Wx qw(wxOK wxCENTRE);
+ Wx::MessageBox("LedgerSMB WX Client\n", "Version", wxOK|wxCENTRE, $self);
+ return 1;
+}
+
+sub logout {
+ my ($self) = @_;
+ $self->SUPER::Close();
+}
+#
+###
+
+### Handler
+#
+sub load_module {
+ my ($self, $module, $action) = @_;
+ $self->{nb}->DeleteAllPages();
+ use lib "scripts";
+ require $module.".pm";
+ my $tab = $module->new($self->{dbh}, $self->{nb}, $action);
+ $self->{nb}->AddPage($tab, $module."::".$action, 0);
+ $tab->Show();
+ return $self;
+}
+#
+###
+1;

Added: addons/1.3/wxPOS/scripts/IC.pm
===================================================================
--- addons/1.3/wxPOS/scripts/IC.pm	                        (rev 0)
+++ addons/1.3/wxPOS/scripts/IC.pm	2012-03-31 11:00:28 UTC (rev 4637)
@@ -0,0 +1,54 @@
+package IC;
+
+use base qw(Wx::Frame);
+use Wx::Event qw(EVT_BUTTON);
+use Wx qw(wxDefaultPosition wxDefaultSize);
+use Wx::Grid;
+
+sub new {
+ my ($class, $dbh, $parent, $action) = @_;
+ $class->{dbh} = $dbh;
+ return $class->$action($parent);
+}
+
+sub Search {
+ my ($class, $parent) = @_;
+ $class->{WxPanel} = Wx::Panel->new($parent, -1, wxDefaultPosition, wxDefaultSize);
+ $class->{numb} = Wx::TextCtrl->new($class->{WxPanel}, -1, 'Number', [50, 100], [100, 20]);
+ $class->{desc} = Wx::TextCtrl->new($class->{WxPanel}, -1, 'Description', [50, 120], [100, 20]);
+ my $button = Wx::Button->new($class->{WxPanel}, -1, 'Search', [50, 160], [100, 20]);
+ EVT_BUTTON($class->{WxPanel}, $button, sub{$class->SearchThis});
+ $class->{list} = Wx::Grid->new($class->{WxPanel}, -1, [50, 200], [500, 500]);
+ $class->{list}->CreateGrid(0, 2);
+ return $class->{WxPanel};
+}
+
+sub SearchThis {
+ my($self, $event) = @_;
+ my $numb = $self->{numb}->GetValue();
+ my $desc = $self->{desc}->GetValue();
+ $self->{list}->ClearGrid();
+ if ($self->{dbh}) {
+  my $sql;
+  if ($numb) {
+   $sql = "SELECT partnumber, description FROM public.parts WHERE partnumber = \'".$numb."\'";
+  }
+  else {
+   $sql = "SELECT partnumber, description FROM public.parts WHERE description ILIKE \'%".$desc."%\'";
+  }
+  my ($list) = $self->{dbh}->selectall_arrayref($sql);
+  my $i = 0;
+  foreach (@{$list}) {
+   $self->{list}->AppendRows();
+   $self->{list}->SetCellValue($i, 0, $_->[0]);
+   $self->{list}->SetCellValue($i, 1, $_->[1]);
+   $i++;
+  }
+ }
+ else {
+  Wx::MessageBox("Database handler not working.", "ERROR", wxOK|wxCENTRE, $self);
+ }
+ return $self;
+}
+1;
+

Added: addons/1.3/wxPOS/scripts/LoginWx.pm
===================================================================
--- addons/1.3/wxPOS/scripts/LoginWx.pm	                        (rev 0)
+++ addons/1.3/wxPOS/scripts/LoginWx.pm	2012-03-31 11:00:28 UTC (rev 4637)
@@ -0,0 +1,35 @@
+package LoginWx;
+
+use base qw(Wx::Dialog);
+use Wx::Event qw(EVT_BUTTON);
+use Wx qw(wxDefaultPosition wxDefaultSize wxOK wxCENTRE wxTE_PASSWORD wxCLOSE_BOX);
+
+sub new {
+ my ($class) = @_;
+ my $self = Wx::Dialog->new(undef , -1, "LedgerSMB", wxDefaultPosition, [200, 200], wxCLOSE_BOX);
+ my $panel = Wx::Panel->new($self, -1, wxDefaultPosition, [200, 200]);
+ my $button = Wx::Button->new($panel, -1, 'Enter', [50, 160], [100, 20]);
+ $self->{user} = Wx::TextCtrl->new($panel, -1, 'postgres', [50, 100], [100, 20]);
+ $self->{pass} = Wx::TextCtrl->new($panel, -1, '', [50, 120], [100, 20], wxTE_PASSWORD);
+ $self->{comp} = Wx::TextCtrl->new($panel, -1, 'database', [50, 140], [100, 20]);
+ EVT_BUTTON($self, $button, \&Login);
+ return $self;
+}
+
+sub Login {
+ my($self, $event) = @_;
+ my $value = {};
+ my $user = $self->{user}->GetValue();
+ my $pass = $self->{pass}->GetValue();
+ my $comp = $self->{comp}->GetValue();
+ use DBI;
+ $self->{dbh} = DBI->connect("dbi:Pg:dbname=$comp;host=localhost", $user, $pass, {RaiseError => 0, AutoCommit => 0});
+ if ( $self->{'dbh'} ) {
+  $self->EndModal($self);
+ }
+ else {
+  Wx::MessageBox("Please, try again.", "Login Error!", wxOK|wxCENTRE, $self);
+ }
+ return 1;
+}
+1;

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