Asulpunto_Unicentaopos - Version 0.0.4

Version Notes

0.0.4
Advanced log to identify database connection issues

0.0.3
First official public release

Download this release

Release Info

Developer asulpunto
Extension Asulpunto_Unicentaopos
Version 0.0.4
Comparing to
See all releases


Code changes from version 0.0.3 to 0.0.4

app/code/community/Asulpunto/Unicentaopos/Block/Adminhtml/System/Config/Form/Button.php CHANGED
@@ -62,7 +62,7 @@ class Asulpunto_Unicentaopos_Block_Adminhtml_System_Config_Form_Button extends M
62
  $button = $this->getLayout()->createBlock('adminhtml/widget_button')
63
  ->setData(array(
64
  'id' => 'asulpuntounicentaopos_button',
65
- 'label' => $this->helper('adminhtml')->__('Test Connection & Get Products'),
66
  'onclick' => 'javascript:check(); return false;'
67
  ));
68
 
62
  $button = $this->getLayout()->createBlock('adminhtml/widget_button')
63
  ->setData(array(
64
  'id' => 'asulpuntounicentaopos_button',
65
+ 'label' => $this->helper('adminhtml')->__('Test Connection'),
66
  'onclick' => 'javascript:check(); return false;'
67
  ));
68
 
app/code/community/Asulpunto/Unicentaopos/Helper/Data.php CHANGED
@@ -30,11 +30,24 @@ class Asulpunto_Unicentaopos_Helper_Data extends Mage_Core_Helper_Abstract
30
  $login=Mage::getStoreConfig('asulpuntounicentaopos/unicentaconfig/login');
31
  $password=Mage::getStoreConfig('asulpuntounicentaopos/unicentaconfig/password');
32
  $name=Mage::getStoreConfig('asulpuntounicentaopos/unicentaconfig/dbname');
33
- $db = new PDO("mysql:host={$url};dbname={$name}",
34
- $login,
35
- $password
36
- );
37
- return $db;
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  }
39
 
40
  }
30
  $login=Mage::getStoreConfig('asulpuntounicentaopos/unicentaconfig/login');
31
  $password=Mage::getStoreConfig('asulpuntounicentaopos/unicentaconfig/password');
32
  $name=Mage::getStoreConfig('asulpuntounicentaopos/unicentaconfig/dbname');
33
+ try {
34
+ $db = new PDO("mysql:host={$url};dbname={$name}",
35
+ $login,
36
+ $password
37
+ );
38
+ } catch (Exception $e){
39
+ Mage::log(__METHOD__." ERROR Getting Connetion URL:$url DBNAME:$name Login:$login Password:$password",null,"asulpunto_unicentaopos.log");
40
+ Mage::log(__METHOD__.$e->getMessage(),null,"asulpunto_unicentaopos.log");
41
+ return null;
42
+ }
43
+ return $db;
44
+ }
45
+
46
+ public function doQuery($sql){
47
+ $db=$this->getUnicentaOposConnection();
48
+ if (is_null($db)) return null;
49
+ $rows=$db->query($sql);
50
+ return $rows;
51
  }
52
 
53
  }
app/code/community/Asulpunto/Unicentaopos/Model/Unicentaoposapi.php CHANGED
@@ -27,17 +27,21 @@ class Asulpunto_Unicentaopos_Model_Unicentaoposapi extends Mage_Core_Model_Abstr
27
 
28
  public function checkActivate(){
29
  try{
30
- $db=Mage::Helper('unicentaopos')->getUnicentaOposConnection();
31
- $sql="select * from `APPLICATIONS`";
32
- $rows=$db->query($sql);
33
- foreach ($rows as $row){
34
- if ($row['ID']=='unicentaopos')
35
- return true;
36
  }
37
  }catch(Exception $e){
38
- Mage::log("checkActivate() Error. ".$e->getMessage()."asulpunto_unicentaopos.log");
39
  }
40
- return false;
 
 
 
 
41
  }
42
 
43
  public function cronProducts(){
@@ -53,7 +57,7 @@ class Asulpunto_Unicentaopos_Model_Unicentaoposapi extends Mage_Core_Model_Abstr
53
  }
54
  $this->updateMagentoProducts();
55
  }catch(Exception $e){
56
- Mage::log("cronProducts() Error. ".$e->getMessage()."asulpunto_unicentaopos.log");
57
  }
58
  }
59
 
@@ -68,7 +72,7 @@ class Asulpunto_Unicentaopos_Model_Unicentaoposapi extends Mage_Core_Model_Abstr
68
  }
69
  $this->updateMagentoStock();
70
  }catch(Exception $e){
71
- Mage::log("cronStock() Error. ".$e->getMessage()."asulpunto_unicentaopos.log");
72
  }
73
  }
74
 
@@ -178,7 +182,7 @@ class Asulpunto_Unicentaopos_Model_Unicentaoposapi extends Mage_Core_Model_Abstr
178
  $item->save();
179
  }
180
  }catch(Exception $e){
181
- Mage::log("_updateUnicentaStock() Error. ".$e->getMessage()."asulpunto_unicentaopos.log");
182
  }
183
  }
184
 
@@ -263,7 +267,7 @@ class Asulpunto_Unicentaopos_Model_Unicentaoposapi extends Mage_Core_Model_Abstr
263
  }
264
  catch (exception $e)
265
  {
266
- Mage::log("_saveMagentoProduct() Error. ".$e->getMessage()."asulpunto_unicentaopos.log");
267
  }
268
  return 0;
269
  }
27
 
28
  public function checkActivate(){
29
  try{
30
+ $rows=Mage::Helper('unicentaopos')->doQuery("select * from `APPLICATIONS`");
31
+ if (!is_null($rows)){
32
+ foreach ($rows as $row){
33
+ if ($row['ID']=='unicentaopos')
34
+ return 'OK';
35
+ }
36
  }
37
  }catch(Exception $e){
38
+ Mage::log(__METHOD__.$e->getMessage(),null,"asulpunto_unicentaopos.log");
39
  }
40
+ $error['url']=Mage::getStoreConfig('asulpuntounicentaopos/unicentaconfig/url');
41
+ $error['login']=Mage::getStoreConfig('asulpuntounicentaopos/unicentaconfig/login');
42
+ $error['password']=Mage::getStoreConfig('asulpuntounicentaopos/unicentaconfig/password');
43
+ $error['name']=Mage::getStoreConfig('asulpuntounicentaopos/unicentaconfig/dbname');
44
+ return json_encode($error);
45
  }
46
 
47
  public function cronProducts(){
57
  }
58
  $this->updateMagentoProducts();
59
  }catch(Exception $e){
60
+ Mage::log(__METHOD__.$e->getMessage(),null,"asulpunto_unicentaopos.log");
61
  }
62
  }
63
 
72
  }
73
  $this->updateMagentoStock();
74
  }catch(Exception $e){
75
+ Mage::log(__METHOD__.$e->getMessage(),null,"asulpunto_unicentaopos.log");
76
  }
77
  }
78
 
182
  $item->save();
183
  }
184
  }catch(Exception $e){
185
+ Mage::log(__METHOD__.$e->getMessage(),null,"asulpunto_unicentaopos.log");
186
  }
187
  }
188
 
267
  }
268
  catch (exception $e)
269
  {
270
+ Mage::log(__METHOD__.$e->getMessage(),null,"asulpunto_unicentaopos.log");
271
  }
272
  return 0;
273
  }
app/code/community/Asulpunto/Unicentaopos/etc/config.xml CHANGED
@@ -25,7 +25,7 @@
25
  <config>
26
  <modules>
27
  <Asulpunto_Unicentaopos>
28
- <version>0.0.3</version>
29
  </Asulpunto_Unicentaopos>
30
  </modules>
31
  <global>
25
  <config>
26
  <modules>
27
  <Asulpunto_Unicentaopos>
28
+ <version>0.0.4</version>
29
  </Asulpunto_Unicentaopos>
30
  </modules>
31
  <global>
app/code/community/Asulpunto/Unicentaopos/etc/system.xml CHANGED
@@ -31,7 +31,7 @@
31
  <sections>
32
 
33
  <asulpuntounicentaopos translate="label" module="unicentaopos">
34
- <label>Unicenta Opos</label>
35
  <tab>asulpunto</tab>
36
  <frontend_type>text</frontend_type>
37
  <sort_order>99999</sort_order>
@@ -57,36 +57,40 @@
57
  <show_in_store>0</show_in_store>
58
  <fields>
59
  <url translate="label">
60
- <label>Unicenta Opos Hostname</label>
61
  <frontend_type>text</frontend_type>
62
  <sort_order>10</sort_order>
63
  <show_in_default>1</show_in_default>
64
  <show_in_website>1</show_in_website>
65
  <show_in_store>1</show_in_store>
 
66
  </url>
67
  <dbname translate="label">
68
- <label>Unicenta Opos Database Name</label>
69
  <frontend_type>text</frontend_type>
70
  <sort_order>20</sort_order>
71
  <show_in_default>1</show_in_default>
72
  <show_in_website>1</show_in_website>
73
  <show_in_store>1</show_in_store>
 
74
  </dbname>
75
  <login translate="label">
76
- <label>Unicenta Opos Database Login</label>
77
  <frontend_type>text</frontend_type>
78
  <sort_order>30</sort_order>
79
  <show_in_default>1</show_in_default>
80
  <show_in_website>1</show_in_website>
81
  <show_in_store>1</show_in_store>
 
82
  </login>
83
  <password translate="label">
84
- <label>Unicenta Opos Database Password</label>
85
  <frontend_type>text</frontend_type>
86
  <sort_order>40</sort_order>
87
  <show_in_default>1</show_in_default>
88
  <show_in_website>1</show_in_website>
89
  <show_in_store>1</show_in_store>
 
90
  </password>
91
  </fields>
92
  </unicentaconfig>
@@ -98,17 +102,18 @@
98
  <show_in_store>0</show_in_store>
99
  <fields>
100
  <check translate="label">
101
- <label>Get Unicenta Opos Products</label>
102
  <frontend_type>button</frontend_type>
103
  <frontend_model>asulpuntounicentaopos/adminhtml_system_config_form_button</frontend_model>
104
  <sort_order>20</sort_order>
105
  <show_in_default>1</show_in_default>
106
  <show_in_website>0</show_in_website>
107
  <show_in_store>0</show_in_store>
 
108
  </check>
109
  <orderstatus translate="label">
110
  <label>Order Status for Stock Syncronisation</label>
111
- <comment>Only orders with this status will have the stock value updated in Unicenta Opos</comment>
112
  <frontend_type>select</frontend_type>
113
  <source_model>adminhtml/system_config_source_order_status</source_model>
114
  <validate>required-entry</validate>
31
  <sections>
32
 
33
  <asulpuntounicentaopos translate="label" module="unicentaopos">
34
+ <label>uniCenta oPOS </label>
35
  <tab>asulpunto</tab>
36
  <frontend_type>text</frontend_type>
37
  <sort_order>99999</sort_order>
57
  <show_in_store>0</show_in_store>
58
  <fields>
59
  <url translate="label">
60
+ <label>uniCenta oPOS Hostname</label>
61
  <frontend_type>text</frontend_type>
62
  <sort_order>10</sort_order>
63
  <show_in_default>1</show_in_default>
64
  <show_in_website>1</show_in_website>
65
  <show_in_store>1</show_in_store>
66
+ <validate>required-entry</validate>
67
  </url>
68
  <dbname translate="label">
69
+ <label>uniCenta oPOS Database Name</label>
70
  <frontend_type>text</frontend_type>
71
  <sort_order>20</sort_order>
72
  <show_in_default>1</show_in_default>
73
  <show_in_website>1</show_in_website>
74
  <show_in_store>1</show_in_store>
75
+ <validate>required-entry</validate>
76
  </dbname>
77
  <login translate="label">
78
+ <label>uniCenta oPOS Database Login</label>
79
  <frontend_type>text</frontend_type>
80
  <sort_order>30</sort_order>
81
  <show_in_default>1</show_in_default>
82
  <show_in_website>1</show_in_website>
83
  <show_in_store>1</show_in_store>
84
+ <validate>required-entry</validate>
85
  </login>
86
  <password translate="label">
87
+ <label>uniCenta oPOS Database Password</label>
88
  <frontend_type>text</frontend_type>
89
  <sort_order>40</sort_order>
90
  <show_in_default>1</show_in_default>
91
  <show_in_website>1</show_in_website>
92
  <show_in_store>1</show_in_store>
93
+ <validate>required-entry</validate>
94
  </password>
95
  </fields>
96
  </unicentaconfig>
102
  <show_in_store>0</show_in_store>
103
  <fields>
104
  <check translate="label">
105
+ <label>Check the connection details</label>
106
  <frontend_type>button</frontend_type>
107
  <frontend_model>asulpuntounicentaopos/adminhtml_system_config_form_button</frontend_model>
108
  <sort_order>20</sort_order>
109
  <show_in_default>1</show_in_default>
110
  <show_in_website>0</show_in_website>
111
  <show_in_store>0</show_in_store>
112
+ <comment>Please, save the database configuration before testing the connection.</comment>
113
  </check>
114
  <orderstatus translate="label">
115
  <label>Order Status for Stock Syncronisation</label>
116
+ <comment>Only orders with this status will have the stock value updated in Unicenta Opos</comment>
117
  <frontend_type>select</frontend_type>
118
  <source_model>adminhtml/system_config_source_order_status</source_model>
119
  <validate>required-entry</validate>
app/design/adminhtml/default/default/template/asulpunto/unicentaopos/system/config/button.phtml CHANGED
@@ -28,10 +28,15 @@
28
  method: 'get',
29
  onSuccess: function(transport){
30
 
31
- if (transport.responseText){
32
- alert('Connection OK. Syncronisation has been activated.')
33
  }else {
34
- alert('Connection Error');
 
 
 
 
 
35
  }
36
  }
37
  });
28
  method: 'get',
29
  onSuccess: function(transport){
30
 
31
+ if (transport.responseText=='OK'){
32
+ alert('Connection OK. Syncronisation has been activated.');
33
  }else {
34
+ obj=JSON.parse(transport.responseText);
35
+ url=obj['url'];
36
+ name=obj['name'];
37
+ login=obj['login'];
38
+ pass=obj['password'];
39
+ alert("Connection ERROR. Cannot connect to database. "+"\nHostname:"+url+"\nDatabase name:"+name+"\nLogin:"+login+"\nPassword:"+pass+"\nPlease change the configuration, press the 'Save Config' button and test again.\nPlease check [magento]/var/system/asulpunto_unicentaopos.log for more details.");
40
  }
41
  }
42
  });
package.xml CHANGED
@@ -1,28 +1,33 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Asulpunto_Unicentaopos</name>
4
- <version>0.0.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/GPL-3.0">GNU General Public License 3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>A basic integration for Magento with the popular Unicenta OPOS the open source, touch screen POS. </summary>
10
- <description>Integrates Magento with Unicenta OPOS. http://www.unicentaopos.co.uk &#xD;
11
- Unicenta is a free, commercial grade POS. It also supports touch screen terminals.&#xD;
12
  &#xD;
13
  Features:&#xD;
14
- -Product created on Unicenta a create automatically on Magento&#xD;
15
- -Stock updates on Unicenta are sent to Magento&#xD;
16
- -Purchases on Magento subtract stock from Unicenta.&#xD;
 
17
  &#xD;
18
- To use this extension you have to install Unicenta's database on a Mysql server accessible by the Magento server.&#xD;
19
  &#xD;
20
  </description>
21
- <notes>First official release.</notes>
 
 
 
 
22
  <authors><author><name>asulpunto</name><user>asulpunto</user><email>asulpunto@asulpunto.com</email></author></authors>
23
- <date>2013-09-19</date>
24
- <time>17:16:28</time>
25
- <contents><target name="magecommunity"><dir name="Asulpunto"><dir name="Unicentaopos"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="Button.php" hash="c8d765e9cd5f9609e1ffd4892cfd1539"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="e72e7f19036b4de80f1e7b6be0ca7118"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Unicentaoposorderitem"><file name="Collection.php" hash="bb9cf8ab48304c34fd7bd575e1002574"/></dir><file name="Unicentaoposorderitem.php" hash="edc7cfecd2b60b0bc372da8c0509cf7d"/><dir name="Unicentaoposproduct"><file name="Collection.php" hash="03f65e284b426d36daa2376e38a813e1"/></dir><file name="Unicentaoposproduct.php" hash="1f849c04da97b863ee88c3b34dc8255b"/></dir><file name="Unicentaoposapi.php" hash="b9f4e6923e17c813be24d0404e673684"/><file name="Unicentaoposorderitem.php" hash="31b0f22a1fa3af396a01b741fd9d4adf"/><file name="Unicentaoposproduct.php" hash="8754d16acf3372355bf379deb563ab03"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="UnicentaoposController.php" hash="7da0f12f269dfdc16ef1f8881753d5fa"/></dir></dir><dir name="etc"><file name="config.xml" hash="f04711f0595f920fa4306867ef4a2000"/><file name="system.xml" hash="379f43dc8ce826399f0e297b0e6bf3ca"/></dir><dir name="sql"><dir name="unicentaopos_setup"><file name="mysql4-install-0.0.1.php" hash="84ba3c4373b2a1c6b1219e8fbd881b51"/><file name="mysql4-upgrade-0.0.1-0.0.2.php" hash="76ea73b06b500e88db0891df95744b65"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="asulpunto"><dir name="unicentaopos"><dir name="system"><dir name="config"><file name="button.phtml" hash="37aa35efb0ab32383f130ae9c5bd25df"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Asulpunto_Unicentaopos.xml" hash="0b81c393d2739bbabe04eeccadeaf858"/></dir></target></contents>
26
  <compatible/>
27
- <dependencies><required><php><min>5.2.0</min><max>5.4.0</max></php></required></dependencies>
28
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Asulpunto_Unicentaopos</name>
4
+ <version>0.0.4</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/GPL-3.0">GNU General Public License 3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>A basic integration for Magento with the popular Unicenta OPOS the open source, touch screen POS. </summary>
10
+ <description>Integrates Magento with uniCenta oPOS. http://www.unicentaopos.co.uk &#xD;
11
+ uniCenta oPOS is a free, commercial grade POS. It also supports touch screen terminals.&#xD;
12
  &#xD;
13
  Features:&#xD;
14
+ -Products created on uniCenta oPOS are created automatically on Magento&#xD;
15
+ -Stock Diary updates on uniCenta oPOS are sent to Magento.&#xD;
16
+ -Purchases on uniCenta oPOS reduce stock from Magento.&#xD;
17
+ -Purchases on Magento subtract stock from uniCenta oPOS Stock Diary.&#xD;
18
  &#xD;
19
+ To use this extension you have to install uniCenta oPOS's database on a Mysql server accessible by the Magento server.&#xD;
20
  &#xD;
21
  </description>
22
+ <notes>0.0.4&#xD;
23
+ Advanced log to identify database connection issues&#xD;
24
+ &#xD;
25
+ 0.0.3&#xD;
26
+ First official public release </notes>
27
  <authors><author><name>asulpunto</name><user>asulpunto</user><email>asulpunto@asulpunto.com</email></author></authors>
28
+ <date>2013-09-27</date>
29
+ <time>16:56:03</time>
30
+ <contents><target name="magecommunity"><dir name="Asulpunto"><dir name="Unicentaopos"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="Button.php" hash="ee172a1ea50cd3f75cf819ba40aa2ac3"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="be527e82077d4e3fb91e0509e3e9eaec"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Unicentaoposorderitem"><file name="Collection.php" hash="bb9cf8ab48304c34fd7bd575e1002574"/></dir><file name="Unicentaoposorderitem.php" hash="edc7cfecd2b60b0bc372da8c0509cf7d"/><dir name="Unicentaoposproduct"><file name="Collection.php" hash="03f65e284b426d36daa2376e38a813e1"/></dir><file name="Unicentaoposproduct.php" hash="1f849c04da97b863ee88c3b34dc8255b"/></dir><file name="Unicentaoposapi.php" hash="3a24379f0984dd3af1f3b509bd7409b9"/><file name="Unicentaoposorderitem.php" hash="31b0f22a1fa3af396a01b741fd9d4adf"/><file name="Unicentaoposproduct.php" hash="8754d16acf3372355bf379deb563ab03"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="UnicentaoposController.php" hash="7da0f12f269dfdc16ef1f8881753d5fa"/></dir></dir><dir name="etc"><file name="config.xml" hash="c3ae12d95c4d1f39d784ee6b3e4e58df"/><file name="system.xml" hash="14b9b9206e187554a17492f974f47305"/></dir><dir name="sql"><dir name="unicentaopos_setup"><file name="mysql4-install-0.0.1.php" hash="84ba3c4373b2a1c6b1219e8fbd881b51"/><file name="mysql4-upgrade-0.0.1-0.0.2.php" hash="76ea73b06b500e88db0891df95744b65"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="asulpunto"><dir name="unicentaopos"><dir name="system"><dir name="config"><file name="button.phtml" hash="023c9f40cee588b3e3ad51728a8b9865"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Asulpunto_Unicentaopos.xml" hash="0b81c393d2739bbabe04eeccadeaf858"/></dir></target></contents>
31
  <compatible/>
32
+ <dependencies><required><php><min>5.2.0</min><max>5.5.0</max></php></required></dependencies>
33
  </package>