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

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



Revision: 6260
          http://sourceforge.net/p/ledger-smb/code/6260
Author:   einhverfr
Date:     2013-11-08 07:25:27 +0000 (Fri, 08 Nov 2013)
Log Message:
-----------
Moving WXPOS namespace up one level for easier management

Added Paths:
-----------
    addons/1.3/wxPOS/WXPOS/
    addons/1.3/wxPOS/WXPOS/UI/
    addons/1.3/wxPOS/WXPOS/UI/AR/
    addons/1.3/wxPOS/WXPOS/UI/AR.pm
    addons/1.3/wxPOS/WXPOS/UI/IC.pm
    addons/1.3/wxPOS/WXPOS/UI.pm

Removed Paths:
-------------
    addons/1.3/wxPOS/scripts/WXPOS/

Copied: addons/1.3/wxPOS/WXPOS/UI/AR.pm (from rev 6259, addons/1.3/wxPOS/scripts/WXPOS/UI/AR.pm)
===================================================================
--- addons/1.3/wxPOS/WXPOS/UI/AR.pm	                        (rev 0)
+++ addons/1.3/wxPOS/WXPOS/UI/AR.pm	2013-11-08 07:25:27 UTC (rev 6260)
@@ -0,0 +1,275 @@
+package WXPOS::UI::AR;
+
+use base qw(Wx::Frame);
+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 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::Grid;
+use WXPOS::Part;
+use WXPOS::Counterparty;
+use lib 'scripts';
+use WXPOS::UI::AR::Pay;
+
+# TODO:
+# Need payment/posting screen
+# No hardware support/printing support yet.
+# Dropping warehouse search restrictions currently.
+
+sub new {
+ my ($class, $sesion, $action) = @_;
+ my $self = {};
+ $self->{sesion} = $sesion;
+ bless $self, $class;
+ return $self->$action();
+}
+
+####### Invoice Screen
+sub Invoice {
+ my ($self) = @_;
+ $self->{sesion}->{tk} = undef;
+ $self->{sesion}->{tk}->{items} = 0;
+ $self->{tab} = Wx::Panel->new($self->{sesion}->{nb}, -1, wxDefaultPosition, wxDefaultSize);
+
+### Close Window Button
+ my $close_btn = Wx::Button->new($self->{tab}, -1, '[X]', [750, 3], [30, 24]);
+ EVT_BUTTON($self->{tab}, $close_btn, sub{$self->_close_pane});
+
+### Customer
+ my $dft_custom = $self->{sesion}->{defaults}->{custom} || '';
+ $dft_custom ||= $WXPOS::Sysconfig::default_customer;
+ Wx::StaticLine->new($self->{tab}, -1, [0, 0], [800, 2], wxLI_HORIZONTAL);
+ Wx::StaticText->new($self->{tab}, -1, 'Customer', [10, 10], [90, 24]);
+ $self->{custom} = Wx::TextCtrl->new($self->{tab}, -1, $dft_custom, [110, 10], [90, 24]);
+ my $cust_but = Wx::Button->new($self->{tab}, -1, 'Search', [210, 10], [90, 24]);
+ EVT_BUTTON($self->{tab}, $cust_but, sub{$self->_listCustomByName});
+ $self->{customer_list} = Wx::ComboBox->new($self->{tab}, -1, '', [10, 40], [290, 24], [''], wxCB_READONLY);
+ Wx::StaticLine->new($self->{tab}, -1, [0, 70], [800, 2], wxLI_HORIZONTAL);
+### Parts Search
+
+ my $warehouse = $self->{sesion}->{defaults}->{wh} || '';
+ Wx::StaticText->new($self->{tab}, -1, 'Warehouse: '.$warehouse, [10,120], [120, 24]);
+ Wx::StaticText->new($self->{tab}, -1, 'Description', [140, 120], [90, 24]);
+ $self->{desc} = Wx::TextCtrl->new($self->{tab}, -1, '', [240, 120], [180, 24]);
+ my $parts_but = Wx::Button->new($self->{tab}, -1, 'Search', [440, 120], [60, 24]);
+ EVT_BUTTON($self->{tab}, $parts_but, sub{$self->_listPartsByName});
+ Wx::StaticLine->new($self->{tab}, -1, [0, 150], [800, 2], wxLI_HORIZONTAL);
+
+### Line Entry
+ Wx::StaticText->new($self->{tab}, -1, 'Qty: ', [10, 160], [30, 24]);
+ $self->{part_qty} = Wx::TextCtrl->new($self->{tab}, -1, '1', [50, 160], [30, 24]);
+ Wx::StaticText->new($self->{tab}, -1, 'Number: ', [90, 160], [60, 24]);
+ $self->{part_numb} = Wx::TextCtrl->new($self->{tab}, -1, '', [160, 160], [90, 24]);
+ Wx::StaticText->new($self->{tab}, -1, 'Price: ', [260, 160], [60, 24]);
+ $self->{part_sellprice} 
+     = Wx::TextCtrl->new($self->{tab}, -1, '', [300, 160], [90, 24]);
+ Wx::StaticText->new($self->{tab}, -1, 'Disc: ', [400, 160], [60, 24]);
+ $self->{part_discount} 
+     = Wx::TextCtrl->new($self->{tab}, -1, '', [440, 160], [40, 24]);
+ my $parts_add = Wx::Button->new($self->{tab}, -1, 'Add', [500, 160], [60, 24]);
+ EVT_BUTTON($self->{tab}, $parts_add, sub{$self->_addParts});
+ Wx::StaticText->new($self->{tab}, -1, 'Selected: ', [600, 160], [90, 24]);
+ $self->{sel_del} = Wx::StaticText->new($self->{tab}, -1, '', [690, 160], [30, 24]);
+ my $parts_del = Wx::Button->new($self->{tab}, -1, 'Del', [730, 160], [60, 24]);
+ EVT_BUTTON($self->{tab}, $parts_del, sub{$self->_delParts});
+
+### Ticket
+ $self->{list} = Wx::ListCtrl->new($self->{tab}, -1, [10, 200], [780, 280], wxLC_REPORT);
+ $self->{list}->InsertColumn(1, 'Number');
+ $self->{list}->InsertColumn(2, 'Description');
+ $self->{list}->InsertColumn(3, 'Price');
+ $self->{list}->InsertColumn(4, 'Tax');
+ $self->{list}->InsertColumn(5, 'Ratio');
+ $self->{list}->InsertColumn(6, 'SubTotal');
+ $self->{list}->InsertColumn(7, 'Qty');
+ $self->{list}->InsertColumn(8, 'Total');
+ EVT_LIST_ITEM_SELECTED($self->{tab}, $self->{list}, sub{$self->_selParts});
+ EVT_LIST_ITEM_DESELECTED($self->{tab}, $self->{list}, sub{$self->_selParts});
+
+### Pay
+ Wx::StaticLine->new($self->{tab}, -1, [0, 490], [800, 2], wxLI_HORIZONTAL);
+ Wx::StaticText->new($self->{tab}, -1, 'Net: ', [100, 500], [90, 24]);
+ $self->{net_total} = Wx::StaticText->new($self->{tab}, -1, '', [200, 500], [90, 24]);
+ Wx::StaticText->new($self->{tab}, -1, 'Tax: ', [300, 500], [90, 24]);
+ $self->{tax_total} = Wx::StaticText->new($self->{tab}, -1, '', [400, 500], [90, 24]);
+ Wx::StaticText->new($self->{tab}, -1, 'Total: ', [500, 500], [90, 24]);
+ $self->{total} = Wx::StaticText->new($self->{tab}, -1, '', [600, 500], [90, 24]);
+ my $invoice_post = Wx::Button->new($self->{tab}, -1, 'Pay', [700, 500], [90, 24]);
+ EVT_BUTTON($self->{tab}, $invoice_post, sub{$self->_InvoicePay});
+
+## Finishing
+ if ($dft_custom){
+    $self->_listCustomByName;
+ }
+ 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};
+}
+
+sub Customer {
+ 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};
+}
+
+sub _listCustomByName {
+ my($self, $event) = @_;
+ my $customer = $self->{custom}->GetValue();
+ my $list;
+ my $i = 0;
+ foreach (WXPOS::Counterparty->search($customer, 2)) {
+  push (@{$list}, $_->name);
+  $self->{customer_search}->{$_->name} = $_->id;
+  $i++;
+ }
+ if ($list) {
+  $self->{customer_list} = undef;
+  $self->{customer_list} = Wx::ComboBox->new($self->{tab}, -1, $list->[0], [10, 40], [290, 24], $list);
+ }
+ else {
+  $self->{customer_list} = undef;
+  $self->{customer_list} = Wx::ComboBox->new($self->{tab}, -1, '', [10, 40], [290, 24], ['']);
+ }
+ return $self->{customer_list};
+}
+
+sub _listPartsByName {
+ my($self, $event) = @_;
+ my $desc = $self->{desc}->GetValue();
+ my $wh = $self->{sesion}->{defaults}->{wh};
+ my $list;
+ my $cust = $self->{customer_search}->{$self->{customer_list}->GetValue()};
+ foreach (WXPOS::Part->search($desc, $cust, 2)) {
+  push (@{$list}, $_->description);
+  $self->{parts_search}->{$_->description} = $_->partnumber;
+ }
+ if ($list) {
+  $self->{parts_list} = undef;
+  $self->{parts_list} = Wx::ComboBox->new($self->{tab}, -1, $list->[0], [510, 120], [280, 24], $list, wxCB_READONLY);
+  EVT_COMBOBOX($self->{tab}, $self->{parts_list}, sub{$self->_getPartsNumber});
+ }
+ else {
+  $self->{parts_list} = undef;
+  $self->{parts_list} = Wx::ComboBox->new($self->{tab}, -1, '', [510, 120], [280, 24], [''], wxCB_READONLY);
+ }
+ 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();
+ my $cust = $self->{customer_search}->{$self->{customer_list}->GetValue()};
+### Check for customer
+ if (!$cust) {
+  Wx::MessageBox("Please, try again selecting a customer.", "Customer not Found!", wxOK|wxCENTRE|wxICON_ERROR, $self->{tab});
+  return 0;
+ }
+### Check for part
+ if (!$part) {
+  Wx::MessageBox("Please, try again selecting a part.", "Part not Found!", wxOK|wxCENTRE|wxICON_ERROR, $self->{tab});
+  return 0;
+ }
+ $part = WXPOS::Part->get_by_partnumber($part, $cust, 2);
+ my $numb = $part->partnumber;
+ my $desc = $part->description;
+ my $sell = $part->sellprice;
+ if (!$numb) {
+  Wx::MessageBox("Please, try again.", "Part not Found!", wxOK|wxCENTRE|wxICON_ERROR, $self->{tab});
+  return 0;
+ }
+## Price/discount overrides
+ if ($self->{part_sellprice}->GetValue()){
+    $sell = $self->{part_sellprice}->GetValue();
+ }
+ my $disc = $self->{part_discount}->GetValue();
+ my $format;
+ if ($disc){
+    $sell = $sell * (100 - $disc)/100;
+    $format = "%." .$WXPOS::Sysconfig::money_places . "f";
+    
+    $sell = sprintf($format, $sell);
+ }
+ my $qty = $self->{part_qty}->GetValue();
+ my $total_tax = 0;
+ my $total_tax_ratio = 0;
+### Calculates total ratio and total tax ammount
+ foreach my $tax (@{$self->{sesion}->{ldb}->getTaxByPair($cust, $part)}) {
+  $total_tax_ratio += $tax->[1];
+  $total_tax += $tax->[1] * $sell;
+ }
+ my $st = $total_tax + $sell;
+ my $total = $st * $qty;
+ my $pp = $self->{list}->InsertStringItem($self->{sesion}->{tk}->{items}, $numb);
+ $self->{list}->SetItem($pp, 1, $desc, -1);
+ $self->{list}->SetItem($pp, 2, $sell, -1);
+ $self->{list}->SetItem($pp, 3, $total_tax, -1);
+ $self->{list}->SetItem($pp, 4, $total_tax_ratio, -1);
+ $self->{list}->SetItem($pp, 5, $st, -1);
+ $self->{list}->SetItem($pp, 6, $qty, -1);
+ $self->{list}->SetItem($pp, 7, $total, -1);
+
+ $self->{sesion}->{tk}->{tnet} += $sell;
+ $self->{sesion}->{tk}->{ttax} += $total_tax;
+ $self->{sesion}->{tk}->{total} += $total;
+ $self->{net_total}->SetLabel($self->{sesion}->{tk}->{tnet});
+ $self->{tax_total}->SetLabel($self->{sesion}->{tk}->{ttax});
+ $self->{total}->SetLabel($self->{sesion}->{tk}->{total});
+ $self->{sesion}->{tk}->{items}++;
+ return $part;
+}
+
+sub _selParts {
+ my($self) = @_;
+ $self->{sel_del}->SetLabel($self->{list}->GetSelectedItemCount);
+ return 1;
+}
+
+sub _delParts {
+ my($self) = @_;
+ if ($self->{list}->GetSelectedItemCount < 1) {
+  Wx::MessageBox("Please, try again selecting an item.", "Item not deleted!", wxOK|wxCENTRE|wxICON_ERROR, $self->{tab});
+  return 0;
+ }
+ my $item = $self->{list}->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+ my $sell = $self->{list}->GetItem($item, 2)->GetText();
+ my $total_tax = $self->{list}->GetItem($item, 3)->GetText();
+ my $total = $self->{list}->GetItem($item, 7)->GetText();
+ $self->{sesion}->{tk}->{tnet} -= $sell;
+ $self->{sesion}->{tk}->{ttax} -= $total_tax;
+ $self->{sesion}->{tk}->{total} -= $total;
+ $self->{net_total}->SetLabel($self->{sesion}->{tk}->{tnet});
+ $self->{tax_total}->SetLabel($self->{sesion}->{tk}->{ttax});
+ $self->{total}->SetLabel($self->{sesion}->{tk}->{total});
+ $self->{list}->DeleteItem($item);
+ $self->{sesion}->{tk}->{items}--;
+ $self->{sel_del}->SetLabel($self->{list}->GetSelectedItemCount);
+#use Data::Dumper;
+#print Dumper($item_col);
+ return 1;
+}
+
+sub _close_pane {
+ my ($self) = $_;
+ my $selection = $WXPOS::State::Notebook->GetSelection;
+ $WXPOS::State::Notebook->DeletePage($selection);
+ return 1;
+}
+
+sub _InvoicePay {
+ my($self) = @_;
+ WXPOS::UI::AR::Pay->new();
+}
+1;

Copied: addons/1.3/wxPOS/WXPOS/UI/IC.pm (from rev 6258, addons/1.3/wxPOS/scripts/WXPOS/UI/IC.pm)
===================================================================
--- addons/1.3/wxPOS/WXPOS/UI/IC.pm	                        (rev 0)
+++ addons/1.3/wxPOS/WXPOS/UI/IC.pm	2013-11-08 07:25:27 UTC (rev 6260)
@@ -0,0 +1,116 @@
+=head1 NAME
+
+LedgerSMB - Wx Inventory Control
+
+=head1 SYNOPSIS
+
+This module is on charge of inventory operations.
+
+=head1 METHODS
+
+=over
+
+=item new ($sesion, $action)
+
+This will get, set and go an action from the menu that is a method of this class. It will
+work as a kind of handler and will return a reference to that action.
+$sesion = It is a hash with all objects and variables needed.
+$action = Method name to invoque as String
+
+=item Parts ()
+
+This is an action that will show a panel asiking for number or description.
+
+=item _listPartsByName ()
+
+A private function used by the Search action that invoques lsmbdb interface to get parts list from the db.
+
+=back
+
+=head1 AUTHOR
+
+Andres Basile (..hidden..)
+
+=cut
+
+package WXPOS::UI::IC;
+
+use base qw(Wx::Frame);
+use Wx::Event qw(EVT_BUTTON);
+use Wx qw(wxDefaultPosition wxDefaultSize wxMAXIMIZE wxCB_READONLY);
+use Wx::Grid;
+
+sub new {
+ my ($class, $sesion, $action) = @_;
+ my $self = {};
+ $self->{sesion} = $sesion;
+ $self->{wh_dft_id} = $self->{sesion}->{defaults}->{wh};
+ bless $self, $class;
+ $self->_getWarehouses();
+ return $self->$action();
+}
+
+sub _close_pane {
+ my ($self) = $_;
+ my $selection = $WXPOS::State::Notebook->GetSelection;
+ $WXPOS::State::Notebook->DeletePage($selection);
+ return 1;
+}
+
+sub _getWarehouses {
+ my ($self) = @_;
+ $self->{wh_des}->{''} = '';
+ foreach (@{$self->{sesion}->{ldb}->getWarehouseList()}) {
+  $self->{wh_des}->{$_->[1]} = $_->[0];
+  if ($_->[0] == $self->{wh_dft_id}) {
+   $self->{wh_dft_des} = $_->[1];
+  }
+ }
+ return $self;
+}
+
+sub Parts {
+ my ($self) = @_;
+### Close Window
+ $self->{WxPanel} = Wx::Panel->new($self->{sesion}->{nb}, -1, wxDefaultPosition, wxDefaultSize, wxMAXIMIZE);
+ my $close_btn = Wx::Button->new($self->{WxPanel}, -1, '[X]', [750, 3], [30, 24]);
+ EVT_BUTTON($self->{WxPanel}, $close_btn, sub{$self->_close_pane});
+ Wx::StaticText->new($self->{WxPanel}, -1, 'Number', [10, 20], [90, 24]);
+ $self->{numb} = Wx::TextCtrl->new($self->{WxPanel}, -1, '', [110, 20], [90, 24]);
+ Wx::StaticText->new($self->{WxPanel}, -1, 'Description', [10, 60], [90, 24]);
+ $self->{desc} = Wx::TextCtrl->new($self->{WxPanel}, -1, '', [110, 60], [180, 24]);
+ Wx::StaticText->new($self->{WxPanel}, -1, 'Warehouse', [310, 40], [90, 24]);
+ $self->{wh} = Wx::ComboBox->new($self->{WxPanel}, -1, $self->{wh_dft_des}, [400, 40], [180, 24], [keys(%{$self->{wh_des}})]);
+ my $button = Wx::Button->new($self->{WxPanel}, -1, 'Search', [110, 100], [60, 24]);
+ EVT_BUTTON($self->{WxPanel}, $button, sub{$self->_listPartsByName});
+ return $self->{WxPanel};
+}
+
+sub _listPartsByName {
+ my($self, $event) = @_;
+ my $numb = $self->{numb}->GetValue();
+ my $desc = $self->{desc}->GetValue();
+ my $wh = $self->{wh_des}->{$self->{wh}->GetValue()};wxCB_READONLY
+ $self->{list} = Wx::Grid->new($self->{WxPanel}, -1, [10, 160], [790, 480], wxCB_READONLY);
+ $self->{list}->CreateGrid(0, 4);
+ $self->{list}->SetColLabelValue(0, 'Number');
+ $self->{list}->SetColSize(0, 100);
+ $self->{list}->SetColLabelValue(1, 'Description');
+ $self->{list}->SetColSize(1, 440);
+ $self->{list}->SetColLabelValue(2, 'Warehouse');
+ $self->{list}->SetColSize(2, 100);
+ $self->{list}->SetColLabelValue(3, 'Qty');
+ $self->{list}->SetColSize(3, 60);
+ my $list = $self->{sesion}->{ldb}->getPartsList($numb, $desc, $wh);
+ my $i = 0;
+ foreach (@{$list}) {
+  $self->{list}->AppendRows();
+  $self->{list}->SetCellValue($i, 0, $_->[0]);
+  $self->{list}->SetCellValue($i, 1, $_->[1]);
+  $self->{list}->SetCellValue($i, 2, $_->[2]);
+  $self->{list}->SetCellValue($i, 3, $_->[3]);
+  $i++;
+ }
+ return $self->{list};
+}
+1;

Copied: addons/1.3/wxPOS/WXPOS/UI.pm (from rev 6258, addons/1.3/wxPOS/scripts/WXPOS/UI.pm)
===================================================================
--- addons/1.3/wxPOS/WXPOS/UI.pm	                        (rev 0)
+++ addons/1.3/wxPOS/WXPOS/UI.pm	2013-11-08 07:25:27 UTC (rev 6260)
@@ -0,0 +1,150 @@
+=head1 NAME
+
+LedgerSMB - Wx Console
+
+=head1 SYNOPSIS
+
+This is the main window, menu and handler for the LedgerSMB Wx client
+
+=head1 METHODS
+
+=over
+
+=item new()
+
+This method creates a new Frame that will work as main window, then it uses Login package poping up
+a small dialog asking for database credentials. Once the database handler is gotten, it will show
+a menu.
+
+=item _load_module()
+
+This is the main handler. It will get from the menu $module and $action in order to init a $module->new($action).
+
+=item $self->{sesion}
+
+This is a hash reference that works as a container for all that variables shared by the whole program. It will be passed as argument to the modules.
+
+Initialized by Login module:
+->{user} = User logged to database.
+->{comp} = Database name.
+->{serv} = Server ip or host where the database is listening.
+->{logo} = Wx bitmap containing LedgerSMB 200x100 logo.
+->{ldb} = LedgerSMB database interface. LSMBDP object with an active connection to database.
+->{user_info} = User full name, etc.
+->{defaults} = This is a hash stored into note table on the database. It would be like WX user defaults and each user should have at least a warehouse assigned in order to work.
+
+Initialized by Console:
+->{nb} = It is the NoteBook object that works as window parent.
+
+=back
+
+=head1 AUTHOR
+
+Andres Basile (..hidden..)
+
+=cut
+
+package WXPOS::UI;
+
+use base qw(Wx::Frame);
+use Wx::Menu;
+use Wx qw(wxDefaultPosition wxDefaultSize wxDEFAULT_FRAME_STYLE wxNO_FULL_REPAINT_ON_RESIZE wxCLIP_CHILDREN wxBITMAP_TYPE_PNG wxMAXIMIZE);
+use Wx::Event qw(EVT_TREE_SEL_CHANGED EVT_CLOSE EVT_IDLE EVT_MENU EVT_KEY_DOWN);
+use WXPOS::Sysconfig;
+
+sub new {
+ my ($class) = @_;
+ my $self = $class->SUPER::new(undef, -1, 'LedgerSMB', wxDefaultPosition, [800, 600], wxDEFAULT_FRAME_STYLE);
+
+### First at all, login, get a db handler and other stuff initialized by Login dialog as sesion.
+#
+ use WXPOS::UI::Login;
+ my $login = WXPOS::UI::Login->new();
+ if ($login->ShowModal()) {
+  die();
+ }
+### Getting my initialized hash sesion with lsmbdb object (an object layer to access db), login options, logo image object
+ $self->{sesion} = $login->{sesion};
+###
+ $login->Destroy();
+#
+###
+
+### Notebook (tabs), this will be the window parent inside the frame.
+#
+ $self->{sesion}->{nb} = Wx::Notebook->new($self, -1, wxDefaultPosition, wxDefaultSize, wxNO_FULL_REPAINT_ON_RESIZE|wxCLIP_CHILDREN);
+
+ $WXPOS::State::Notebook = $self->{sesion}->{nb};
+
+#
+###
+
+### 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_PARTS) = (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_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_PARTS, "&Parts");
+ EVT_MENU($self, $IC_PARTS, sub{$self->_load_module(IC, Parts)});
+ $bar->Append($ic, "&Inventory" );
+
+ $self->SetMenuBar($bar);
+ return $self;
+}
+
+sub _process_char {
+ my ($evt) = @_;
+ warn 'key pressed';
+}
+
+### About
+sub _about {
+ my ($self) = @_;
+ use Wx qw(wxOK wxCENTRE);
+ my $about = Wx::MessageBox("LedgerSMB WX Client\nEmployee: ".$self->{sesion}->{user_info}->{name}."\nWarehouse: ".$self->{sesion}->{defaults}->{wh}, "Version 0.2", wxOK|wxCENTRE, $self);
+ return 1;
+}
+
+### Exit
+sub _logout {
+ my ($self) = @_;
+ $self->SUPER::Close();
+}
+
+### Handler
+sub _load_module {
+ my ($self, $module, $action) = @_;
+ #$self->{sesion}->{nb}->DeleteAllPages();
+ my $mname = "WXPOS::UI::$module"; 
+ use lib "scripts";
+ my $mfile = "$mname.pm";
+ $mfile =~ s|::|/|g;
+ require $mfile;
+ my $tab = $mname->new($self->{sesion}, $action);
+ $self->{sesion}->{nb}->AddPage($tab, $action, 1);
+ $tab->Show();
+ EVT_KEY_DOWN($tab, sub {$self->_process_char});
+ return $self;
+}
+
+###
+sub DESTROY {
+ my ($self) = @_;
+ $self->{sesion}->{ldb}->{dbh}->disconnect();
+}
+1;

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


------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits