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

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



Revision: 6192
          http://sourceforge.net/p/ledger-smb/code/6192
Author:   einhverfr
Date:     2013-10-28 10:09:10 +0000 (Mon, 28 Oct 2013)
Log Message:
-----------
Adding configuration ini files to wxpos

Modified Paths:
--------------
    addons/1.3/wxPOS/scripts/Console.pm
    addons/1.3/wxPOS/scripts/Login.pm

Added Paths:
-----------
    addons/1.3/wxPOS/scripts/WXPOS/Sysconfig.pm
    addons/1.3/wxPOS/wxpos.conf.template

Modified: addons/1.3/wxPOS/scripts/Console.pm
===================================================================
--- addons/1.3/wxPOS/scripts/Console.pm	2013-10-28 08:16:04 UTC (rev 6191)
+++ addons/1.3/wxPOS/scripts/Console.pm	2013-10-28 10:09:10 UTC (rev 6192)
@@ -50,6 +50,7 @@
 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) = @_;

Modified: addons/1.3/wxPOS/scripts/Login.pm
===================================================================
--- addons/1.3/wxPOS/scripts/Login.pm	2013-10-28 08:16:04 UTC (rev 6191)
+++ addons/1.3/wxPOS/scripts/Login.pm	2013-10-28 10:09:10 UTC (rev 6192)
@@ -36,6 +36,7 @@
 
 use LSMBDB;
 use WXPOS::User;
+use WXPOS::Sysconfig;
 
 sub new {
  my ($class) = @_;
@@ -46,13 +47,14 @@
  $self->{sesion}->{logo} =  Wx::Bitmap->new("ledgersmb.png", wxBITMAP_TYPE_PNG);
  Wx::StaticBitmap->new($self->{WxPanel}, -1, $self->{sesion}->{logo}, [50, 10], [200, 100]);
  Wx::StaticText->new($self->{WxPanel}, -1, 'User', [50, 120], [80, 24]);
- $self->{user} = Wx::TextCtrl->new($self->{WxPanel}, -1, '', [130, 120], [120, 24]);
+ my $user = $WXPOS::Sysconfig::dbconfig->{user} || '';
+ $self->{user} = Wx::TextCtrl->new($self->{WxPanel}, -1, $user, [130, 120], [120, 24]);
  Wx::StaticText->new($self->{WxPanel}, -1, 'Password', [50, 160], [90, 24]);
- $self->{pass} = Wx::TextCtrl->new($self->{WxPanel}, -1, 'pass', [130, 160], [120, 24], wxTE_PASSWORD);
+ $self->{pass} = Wx::TextCtrl->new($self->{WxPanel}, -1, $WXPOS::Sysconfig::dbconfig->{password} || '', [130, 160], [120, 24], wxTE_PASSWORD);
  Wx::StaticText->new($self->{WxPanel}, -1, 'Company', [50, 200], [90, 30]);
- $self->{comp} = Wx::TextCtrl->new($self->{WxPanel}, -1, 'mtech_test', [130, 200], [120, 24]);
+ $self->{comp} = Wx::TextCtrl->new($self->{WxPanel}, -1, $WXPOS::Sysconfig::dbconfig->{database} || '', [130, 200], [120, 24]);
  Wx::StaticText->new($self->{WxPanel}, -1, 'Server', [50, 240], [90, 30]);
- $self->{serv} = Wx::TextCtrl->new($self->{WxPanel}, -1, 'localhost', [130, 240], [120, 24]);
+ $self->{serv} = Wx::TextCtrl->new($self->{WxPanel}, -1, $WXPOS::Sysconfig::dbconfig->{host} || '', [130, 240], [120, 24]);
  my $button = Wx::Button->new($self->{WxPanel}, -1, 'Enter', [100, 280], [100, 24]);
  EVT_BUTTON($self, $button, \&Login);
  my $exitbtn =  Wx::Button->new($self->{WxPanel}, -1, 'X', [250, 280], [20, 24]);

Added: addons/1.3/wxPOS/scripts/WXPOS/Sysconfig.pm
===================================================================
--- addons/1.3/wxPOS/scripts/WXPOS/Sysconfig.pm	                        (rev 0)
+++ addons/1.3/wxPOS/scripts/WXPOS/Sysconfig.pm	2013-10-28 10:09:10 UTC (rev 6192)
@@ -0,0 +1,74 @@
+=head1 NAME
+
+WXPOS::Sysconfig - System config for wxPOS.
+
+=head1 COPYRIGHT
+
+Copyright (C) 2013 Chris Travers.  It may be used under the terms of the GNU
+General Public License version 2 or at your option any later version.  See the
+included LICENSE.TXT for more information.
+
+=cut
+
+package WXPOS::Sysconfig;
+use Config::IniFiles; # For future config parsing.  For now, this is just
+                          # written here for initial testing.
+
+our $default_language = 'en';
+
+our $dbconfig = {
+     host => 'localhost',
+     port => 5432,
+};
+
+our $pdconfig = {
+   driver => 'lc3000',
+   device => '/dev/ttyS0'
+};
+
+our $printerconfig = {
+    model => 'U220D',
+   device => '/dev/lp0',
+   driver => 'esc_pos',
+};
+
+our $cashdrawerconfig = {
+     mode => 'printer'
+};
+
+our $curr = {
+   series => qw(100000 50000 20000 10000 5000 1000 500 200 100 50),
+     curr => 'IDR',
+};
+
+my $cfg = Config::IniFiles->new( -file => "wxpos.conf" ) 
+       || die @Config::IniFiles::errors;
+
+$default_language = $cfg->val('main','default_language') 
+      if $cfg->val('main','default_language');
+
+for my $var (qw(database user host port password)){
+    $dbconfig->{$var} = $cfg->val('database', $var)
+         if $cfg->val('database', $var);
+} 
+
+for my $var (qw(driver device)){
+    $pdconfig->{$var} = $cfg->val('poledisp', $var)
+         if $cfg->val('poledisp', $var);
+}
+
+for my $var (qw(driver device model mode)){
+    $printerconfig->{$var} = $cfg->val('posprinter', $var)
+         if $cfg->val('posprinter', $var);
+}
+
+for my $var (qw(driver device model mode)){
+    $cashdrawerconfig->{$var} = $cfg->val('cashdrawer', $var)
+         if $cfg->val('cashdrawer', $var);
+}
+
+for my $var (qw(curr series)){
+    $curr->{$var} = $cfg->val('currency', $var)
+         if $cfg->val('currency', $var);
+}
+1;

Added: addons/1.3/wxPOS/wxpos.conf.template
===================================================================
--- addons/1.3/wxPOS/wxpos.conf.template	                        (rev 0)
+++ addons/1.3/wxPOS/wxpos.conf.template	2013-10-28 10:09:10 UTC (rev 6192)
@@ -0,0 +1,24 @@
+[main]
+default_language=en
+
+[database]
+database=mtech_test
+user=chris
+host=localhost
+port=5432
+
+[poledisp]
+device=/dev/ttys0
+driver=lc3000
+
+[posprinter]
+device=/dev/ttyS1
+driver=esc_pos
+model=U220D
+
+[cashdrawer]
+mode=printer
+
+[currency]
+curr=IDR
+series=100000,50000,20000,10000,5000,2000,1000,500,200,100,50 

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


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits