Tiny - Version 0.0.9

Version Notes

Importa Pedidos, Produtos e Acesso Pelo menu do Painel.

Download this release

Release Info

Developer XDMIX.com.br
Extension Tiny
Version 0.0.9
Comparing to
See all releases


Code changes from version 0.0.8 to 0.0.9

app/code/local/Tiny/Iframe/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Tiny_Iframe>
5
- <version>0.0.8</version>
6
  </Tiny_Iframe>
7
  </modules>
8
  <global>
@@ -88,6 +88,9 @@
88
  <tiny>
89
  <general>
90
  <enable_tiny>1</enable_tiny>
 
 
 
91
  </general>
92
  </tiny>
93
  </default>
2
  <config>
3
  <modules>
4
  <Tiny_Iframe>
5
+ <version>0.0.9</version>
6
  </Tiny_Iframe>
7
  </modules>
8
  <global>
88
  <tiny>
89
  <general>
90
  <enable_tiny>1</enable_tiny>
91
+ <apiKey_tiny></apiKey_tiny>
92
+ <exportar_Tiny>0</exportar_Tiny>
93
+ <destino_Tiny>0</destino_Tiny>
94
  </general>
95
  </tiny>
96
  </default>
app/code/local/Tiny/Iframe/etc/system.xml CHANGED
@@ -23,11 +23,64 @@
23
  <div>
24
  <br style="clear: both;"/>
25
  <div style="width: 439px; height: 40px; display: block; float: left; padding-left: 35px;">
26
- <label style="font-size: 22px">Vers&atilde;o: <strong>0.0.8</strong></label>
27
  </div>
28
  <br style="clear: both;"/>
29
  <hr>
30
  <br /><br />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  <p>
32
  <h2>Mantido por: <a href="http://www.tiny.com.br/" target="_blank">Tiny</a> e <a href="http://www.xdmix.com.br/" target="_blank">XDMIX</a></h2><br />
33
  Desenvolvedores:<br />
@@ -90,27 +143,16 @@
90
  <img src="http://www.tiny.com.br/manuais/images/magento_tiny_3.png" width="600" height="598" style="border:solid 1px #ccc;" /><br />
91
  Após salvá-lo aparecerá em notas fiscais (Vendas->Notas Fiscais).<br />
92
  </div>
93
- <br /><br /><hr>
94
  </div>
95
  ]]></comment>
96
  <frontend_type>text</frontend_type>
97
- <sort_order>10</sort_order>
98
  <show_in_default>1</show_in_default>
99
  <show_in_website>1</show_in_website>
100
  <show_in_store>1</show_in_store>
101
- <fields>
102
- <enable_tiny translate="label comment">
103
- <label>Versão 0.0.8</label>
104
- <frontend_type>select</frontend_type>
105
- <source_model>adminhtml/system_config_source_yesno</source_model>
106
- <sort_order>1</sort_order>
107
- <show_in_default>1</show_in_default>
108
- <show_in_website>1</show_in_website>
109
- <show_in_store>1</show_in_store>
110
- </enable_tiny>
111
- </fields>
112
- </general>
113
  </groups>
114
  </tiny>
115
  </sections>
116
- </config>
23
  <div>
24
  <br style="clear: both;"/>
25
  <div style="width: 439px; height: 40px; display: block; float: left; padding-left: 35px;">
26
+ <label style="font-size: 22px">Vers&atilde;o: <strong>0.0.9</strong></label>
27
  </div>
28
  <br style="clear: both;"/>
29
  <hr>
30
  <br /><br />
31
+ </div>
32
+ ]]>
33
+ </comment>
34
+ <frontend_type>text</frontend_type>
35
+ <sort_order>1</sort_order>
36
+ <show_in_default>1</show_in_default>
37
+ <show_in_website>1</show_in_website>
38
+ <show_in_store>1</show_in_store>
39
+ <fields>
40
+ <enable_tiny translate="label comment">
41
+ <label>Habilitar Tiny</label>
42
+ <frontend_type>select</frontend_type>
43
+ <source_model>adminhtml/system_config_source_yesno</source_model>
44
+ <sort_order>1</sort_order>
45
+ <show_in_default>1</show_in_default>
46
+ <show_in_website>1</show_in_website>
47
+ <show_in_store>1</show_in_store>
48
+ </enable_tiny>
49
+ <apiKey_tiny translate="label comment">
50
+ <label>ApiKey</label>
51
+ <frontend_type>text</frontend_type>
52
+ <comment>ApiKey Tiny encontrada no seu painel Tiny em: Preferências -> Configuração de Integração -> ApiKey</comment>
53
+ <sort_order>2</sort_order>
54
+ <show_in_default>1</show_in_default>
55
+ <show_in_website>1</show_in_website>
56
+ <show_in_store>1</show_in_store>
57
+ </apiKey_tiny>
58
+ <exportar_Tiny translate="label comment">
59
+ <label>Exportar quando</label>
60
+ <frontend_type>select</frontend_type>
61
+ <source_model>Tiny_Pedidos_Model_OpcoesTiny</source_model>
62
+ <sort_order>3</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
+ </exportar_Tiny>
67
+ <destino_Tiny translate="label comment">
68
+ <label>Exportar para</label>
69
+ <frontend_type>select</frontend_type>
70
+ <source_model>Tiny_Pedidos_Model_DestinoTiny</source_model>
71
+ <sort_order>4</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
+ </destino_Tiny>
76
+ </fields>
77
+ </general>
78
+ <about translate="label">
79
+ <label>Como Funciona?</label>
80
+ <comment>
81
+ <![CDATA[
82
+ <div>
83
+ <br style="clear: both;"/>
84
  <p>
85
  <h2>Mantido por: <a href="http://www.tiny.com.br/" target="_blank">Tiny</a> e <a href="http://www.xdmix.com.br/" target="_blank">XDMIX</a></h2><br />
86
  Desenvolvedores:<br />
143
  <img src="http://www.tiny.com.br/manuais/images/magento_tiny_3.png" width="600" height="598" style="border:solid 1px #ccc;" /><br />
144
  Após salvá-lo aparecerá em notas fiscais (Vendas->Notas Fiscais).<br />
145
  </div>
146
+ <br /><br />
147
  </div>
148
  ]]></comment>
149
  <frontend_type>text</frontend_type>
150
+ <sort_order>2</sort_order>
151
  <show_in_default>1</show_in_default>
152
  <show_in_website>1</show_in_website>
153
  <show_in_store>1</show_in_store>
154
+ </about>
 
 
 
 
 
 
 
 
 
 
 
155
  </groups>
156
  </tiny>
157
  </sections>
158
+ </config>
app/code/local/Tiny/Pedidos/Model/DestinoTiny.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Used in creating options for Yes|No|Specified config value selection
29
+ *
30
+ */
31
+ class Tiny_Pedidos_Model_DestinoTiny
32
+ {
33
+
34
+ /**
35
+ * Options getter
36
+ *
37
+ * @return array
38
+ */
39
+ public function toOptionArray()
40
+ {
41
+ return array(
42
+ array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('Pedidos de venda')),
43
+ array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('Nota fiscal')),
44
+ );
45
+ }
46
+
47
+ }
app/code/local/Tiny/Pedidos/Model/Observer.php CHANGED
@@ -18,7 +18,7 @@
18
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19
  */
20
 
21
- require_once("config.php");
22
 
23
  class Tiny_Pedidos_Model_Observer {
24
 
@@ -28,7 +28,15 @@ class Tiny_Pedidos_Model_Observer {
28
  */
29
 
30
  public function inserePedido(Varien_Event_Observer $observer) {
31
- if (INTEGRACAO_NA_CRIACAO_DO_PEDIDO_ATIVA == "S") {
 
 
 
 
 
 
 
 
32
  try {
33
  $orderId = $observer->getEvent()->getOrder()->getIncrementId();
34
  $this->exportarPedido($orderId);
@@ -37,32 +45,47 @@ class Tiny_Pedidos_Model_Observer {
37
  }
38
  }
39
 
40
- public function exportarPedido($num, $pedidoNota = "P") {
41
- try {
42
-
43
- $url = URL_TINY;
44
- $data = 'apiKey=' . APIKEY_TINY .'&tipo=' . $pedidoNota . '&numeroPedido=' . $num;
45
-
46
- $optional_headers = null;
47
- $params = array('http' => array('method' => 'POST', 'content' => $data));
48
- if ($optional_headers !== null) {
49
- $params['http']['header'] = $optional_headers;
50
- }
51
- $ctx = stream_context_create($params);
52
- $fp = @fopen($url, 'rb', false, $ctx);
53
- if (!$fp) {
54
- throw new Exception("Problema com $url, $php_errormsg");
55
- }
56
- $response = @stream_get_contents($fp);
57
- if ($response === false) {
58
- throw new Exception("Problema obtendo retorno de $url, $php_errormsg");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  }
60
- } catch(Exception $e) {
61
  }
62
  }
63
 
64
  public function inserePedidoPeloPagamento(Varien_Event_Observer $observer) {
65
- if (INTEGRACAO_NA_CRIACAO_DA_FATURA_ATIVA == "S") {
 
66
  try {
67
  $orderId = $observer->getPayment()->getOrder()->getIncrementId();
68
  $this->exportarPedido($orderId);
@@ -76,7 +99,7 @@ class Tiny_Pedidos_Model_Observer {
76
  $order = $observer->getEvent()->getOrder();
77
  $orderId = $order->getRealOrderId();
78
  //$orderId = $observer->getPayment()->getOrder()->getIncrementId();
79
- $this->exportarPedido($orderId);
80
  } catch(Exception $e) {
81
  }
82
  }
18
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19
  */
20
 
21
+ define("URL_TINY", "http://www.tiny.com.br/tinyerp/api2/recepcao.magento.api.php");
22
 
23
  class Tiny_Pedidos_Model_Observer {
24
 
28
  */
29
 
30
  public function inserePedido(Varien_Event_Observer $observer) {
31
+
32
+ $exportarQuando = Mage::getStoreConfig('tiny/general/exportar_Tiny');
33
+ /*
34
+ array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('Não exportar')),
35
+ array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('Quando o pedido for incluído')),
36
+ array('value' => 2, 'label'=>Mage::helper('adminhtml')->__('Quando o pedido for faturado'))
37
+ */
38
+
39
+ if ($exportarQuando == 1) {
40
  try {
41
  $orderId = $observer->getEvent()->getOrder()->getIncrementId();
42
  $this->exportarPedido($orderId);
45
  }
46
  }
47
 
48
+ public function exportarPedido($num) {
49
+
50
+ $apiKey = Mage::getStoreConfig('tiny/general/apiKey_tiny');
51
+ $exportarQuando = Mage::getStoreConfig('tiny/general/exportar_Tiny');
52
+ $destino = Mage::getStoreConfig('tiny/general/destino_Tiny');
53
+
54
+ if ($destino == 1) {
55
+ $pedidoNota = "N";
56
+ } else {
57
+ $pedidoNota = "P";
58
+ }
59
+
60
+ if ($exportarQuando != 0) {
61
+
62
+ try {
63
+
64
+ $url = URL_TINY;
65
+ $data = 'apiKey=' . $apiKey .'&tipo=' . $pedidoNota . '&numeroPedido=' . $num;
66
+
67
+ $optional_headers = null;
68
+ $params = array('http' => array('method' => 'POST', 'content' => $data));
69
+ if ($optional_headers !== null) {
70
+ $params['http']['header'] = $optional_headers;
71
+ }
72
+ $ctx = stream_context_create($params);
73
+ $fp = @fopen($url, 'rb', false, $ctx);
74
+ if (!$fp) {
75
+ throw new Exception("Problema com $url, $php_errormsg");
76
+ }
77
+ $response = @stream_get_contents($fp);
78
+ if ($response === false) {
79
+ throw new Exception("Problema obtendo retorno de $url, $php_errormsg");
80
+ }
81
+ } catch(Exception $e) {
82
  }
 
83
  }
84
  }
85
 
86
  public function inserePedidoPeloPagamento(Varien_Event_Observer $observer) {
87
+ $exportarQuando = Mage::getStoreConfig('tiny/general/exportar_Tiny');
88
+ if ($exportarQuando == 2) {
89
  try {
90
  $orderId = $observer->getPayment()->getOrder()->getIncrementId();
91
  $this->exportarPedido($orderId);
99
  $order = $observer->getEvent()->getOrder();
100
  $orderId = $order->getRealOrderId();
101
  //$orderId = $observer->getPayment()->getOrder()->getIncrementId();
102
+ //$this->exportarPedido($orderId);
103
  } catch(Exception $e) {
104
  }
105
  }
app/code/local/Tiny/Pedidos/Model/OpcoesTiny.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Used in creating options for Yes|No|Specified config value selection
29
+ *
30
+ */
31
+ class Tiny_Pedidos_Model_OpcoesTiny
32
+ {
33
+
34
+ /**
35
+ * Options getter
36
+ *
37
+ * @return array
38
+ */
39
+ public function toOptionArray()
40
+ {
41
+ return array(
42
+ array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('Não exportar')),
43
+ array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('Quando o pedido for incluído')),
44
+ array('value' => 2, 'label'=>Mage::helper('adminhtml')->__('Quando o pedido for faturado'))
45
+ );
46
+ }
47
+
48
+ }
app/code/local/Tiny/Pedidos/etc/config.xml CHANGED
@@ -2,10 +2,10 @@
2
  <config>
3
  <modules>
4
  <Tiny_Pedidos>
5
- <version>0.0.8</version>
6
  </Tiny_Pedidos>
7
  <Tiny_Pedidos_Pagos>
8
- <version>0.0.8</version>
9
  </Tiny_Pedidos_Pagos>
10
  </modules>
11
  <global>
2
  <config>
3
  <modules>
4
  <Tiny_Pedidos>
5
+ <version>0.0.9</version>
6
  </Tiny_Pedidos>
7
  <Tiny_Pedidos_Pagos>
8
+ <version>0.0.9</version>
9
  </Tiny_Pedidos_Pagos>
10
  </modules>
11
  <global>
app/design/adminhtml/default/default/template/tiny/author.phtml DELETED
@@ -1 +0,0 @@
1
- teste
 
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Tiny</name>
4
- <version>0.0.8</version>
5
  <stability>stable</stability>
6
  <license>GNU General Public License (GPL)</license>
7
  <channel>community</channel>
@@ -13,9 +13,9 @@ Importa&#xE7;&#xE3;o de Produtos.&#xD;
13
  Menu Tiny com janela para para o Sistema Tiny.</description>
14
  <notes>Importa Pedidos, Produtos e Acesso Pelo menu do Painel.</notes>
15
  <authors><author><name>XDMIX.com.br</name><user>ClarckBR</user><email>clarck.1@gmail.com</email></author><author><name>tiny.com.br</name><user>marcosGrzeca</user><email>marcos@tiny.com.br</email></author></authors>
16
- <date>2013-02-27</date>
17
- <time>14:32:23</time>
18
- <contents><target name="magelocal"><dir name="Tiny"><dir name="Iframe"><dir name="Block"><dir name="Adminhtml"><file name="Tinybackend.php" hash="ecf98e41f9335db02d7a2b780017d355"/><file name="Tinybackendnew.php" hash="fe03059e072a3ac07d38be59035b7f0b"/></dir></dir><dir name="Helper"><file name="Data.php" hash="89f964f9eae39d4b89861c4af449f27a"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="TinybackendController.php" hash="6730806216146eb04e89c12e8c757d6f"/><file name="TinybackendnewController.php" hash="6047fe80abd6eccd543ac5959fcc6bd1"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="f6d0d5eb762fa72b2c3acb17f0dce47b"/><file name="config.xml" hash="10bc82ff719a7be14d9186bc58d62c42"/><file name="system.xml" hash="11834a908634802b128bf19464ff1f72"/></dir></dir><dir name="Pedidos"><dir name="Model"><file name="Observer.php" hash="5ef302545e20649861c0da6a8a4d8211"/><file name="config.php" hash="9ed1451ca8d2d4cc00cf38bb1f82dd7c"/></dir><dir name="etc"><file name="config.xml" hash="63cb7a978e6cfe814d51d7accc842737"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="tiny.xml" hash="335baf6004b5b0afe2d19f0a752bbec6"/></dir><dir name="template"><dir name="tiny"><file name="author.phtml" hash="698dc19d489c4e4db73e28a713eab07b"/><file name="tinybackend.phtml" hash="a52bca8a8b3f7de6281a1305476f5d28"/><file name="tinybackendnew.phtml" hash="3c76a75bb7adb8b7223c2faa331579a4"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Tiny.xml" hash="468d04f14f2ac16ee21d0cb863c10137"/></dir></target></contents>
19
  <compatible/>
20
  <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
21
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Tiny</name>
4
+ <version>0.0.9</version>
5
  <stability>stable</stability>
6
  <license>GNU General Public License (GPL)</license>
7
  <channel>community</channel>
13
  Menu Tiny com janela para para o Sistema Tiny.</description>
14
  <notes>Importa Pedidos, Produtos e Acesso Pelo menu do Painel.</notes>
15
  <authors><author><name>XDMIX.com.br</name><user>ClarckBR</user><email>clarck.1@gmail.com</email></author><author><name>tiny.com.br</name><user>marcosGrzeca</user><email>marcos@tiny.com.br</email></author></authors>
16
+ <date>2013-03-04</date>
17
+ <time>14:11:22</time>
18
+ <contents><target name="magelocal"><dir name="Tiny"><dir name="Iframe"><dir name="Block"><dir name="Adminhtml"><file name="Tinybackend.php" hash="ecf98e41f9335db02d7a2b780017d355"/><file name="Tinybackendnew.php" hash="fe03059e072a3ac07d38be59035b7f0b"/></dir></dir><dir name="Helper"><file name="Data.php" hash="89f964f9eae39d4b89861c4af449f27a"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="TinybackendController.php" hash="6730806216146eb04e89c12e8c757d6f"/><file name="TinybackendnewController.php" hash="6047fe80abd6eccd543ac5959fcc6bd1"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="f6d0d5eb762fa72b2c3acb17f0dce47b"/><file name="config.xml" hash="1801f687a61b657f274ec007c60d85f8"/><file name="system.xml" hash="0fc01422089a0562c9978e22864273e6"/></dir></dir><dir name="Pedidos"><dir name="Model"><file name="DestinoTiny.php" hash="840dcbfbdbe8b3a5174d49f73f8dd38b"/><file name="Observer.php" hash="6f15f2f0283d77a4478b06f5b0a0347a"/><file name="OpcoesTiny.php" hash="78295366d294042d3cf00eadaa97b50d"/><file name="config.php" hash="9ed1451ca8d2d4cc00cf38bb1f82dd7c"/></dir><dir name="etc"><file name="config.xml" hash="820acfa11d916438f1d05aa30a66b152"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="tiny.xml" hash="335baf6004b5b0afe2d19f0a752bbec6"/></dir><dir name="template"><dir name="tiny"><file name="tinybackend.phtml" hash="a52bca8a8b3f7de6281a1305476f5d28"/><file name="tinybackendnew.phtml" hash="3c76a75bb7adb8b7223c2faa331579a4"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Tiny.xml" hash="468d04f14f2ac16ee21d0cb863c10137"/></dir></target></contents>
19
  <compatible/>
20
  <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
21
  </package>