@@ -1,32 +1,32 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class HomeController extends AppController{ |
|
3 | +class HomeController extends AppController { |
|
4 | 4 | |
5 | - public function beforeFilter(){ |
|
5 | + public function beforeFilter() { |
|
6 | 6 | return true; |
7 | 7 | } |
8 | 8 | |
9 | - function index(){ |
|
9 | + function index() { |
|
10 | 10 | $this->layout = 'winners'; |
11 | 11 | } |
12 | 12 | |
13 | - function servicos(){ |
|
13 | + function servicos() { |
|
14 | 14 | $this->layout = 'winners'; |
15 | 15 | } |
16 | 16 | |
17 | - function contact(){ |
|
17 | + function contact() { |
|
18 | 18 | $this->layout = 'winners'; |
19 | 19 | } |
20 | 20 | |
21 | - function timeline(){ |
|
21 | + function timeline() { |
|
22 | 22 | $this->layout = 'winners'; |
23 | 23 | } |
24 | 24 | |
25 | - function developers(){ |
|
25 | + function developers() { |
|
26 | 26 | $this->layout = 'winners'; |
27 | 27 | } |
28 | 28 | |
29 | - function cases(){ |
|
29 | + function cases() { |
|
30 | 30 | $this->layout = 'winners'; |
31 | 31 | } |
32 | 32 | |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | $dados = $this->request->data('dados'); |
41 | 41 | |
42 | 42 | // Check for empty fields |
43 | - if(empty($dados['name']) || |
|
44 | - empty($dados['email']) || |
|
45 | - empty($dados['message']) || |
|
46 | - !filter_var($dados['email'], FILTER_VALIDATE_EMAIL)) { |
|
43 | + if (empty($dados['name']) || |
|
44 | + empty($dados['email']) || |
|
45 | + empty($dados['message']) || |
|
46 | + ! filter_var($dados['email'], FILTER_VALIDATE_EMAIL)) { |
|
47 | 47 | $this->Session->setFlash('Você deve preencher todos os dados!'); |
48 | 48 | return $this->redirect('/'); |
49 | 49 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $email_body = "Mensagem site: ".$message; |
59 | 59 | $headers = "From: [email protected]\n"; // This is the email address the generated message will be from. We recommend using something like [email protected]. |
60 | 60 | $headers .= "Reply-To: $email_address"; |
61 | - mail($to,$email_subject,$email_body,$headers); |
|
61 | + mail($to, $email_subject, $email_body, $headers); |
|
62 | 62 | //resposta automatica ao cliente |
63 | 63 | $to = $email_address; |
64 | 64 | $email_subject = '[email protected]'; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $headers = "From: [email protected]\n"; // This is the email address the generated message will be from. We recommend using something like [email protected]. |
67 | 67 | $headers .= "Reply-To: $email_address"; |
68 | 68 | |
69 | - mail($to,$email_subject,$email_body,$headers); |
|
69 | + mail($to, $email_subject, $email_body, $headers); |
|
70 | 70 | |
71 | 71 | $this->Session->setFlash('O e-mail foi enviado em breve entraremos em contato!'); |
72 | 72 |
@@ -18,60 +18,60 @@ discard block |
||
18 | 18 | protected $usuario; |
19 | 19 | |
20 | 20 | public function beforeFilter(){ |
21 | - $lojaSession = $this->Session->read('Usuario.loja'); |
|
21 | + $lojaSession = $this->Session->read('Usuario.loja'); |
|
22 | 22 | |
23 | - if (isset($lojaSession)) |
|
24 | - { |
|
25 | - if (isset($this->params['loja'])) |
|
26 | - { |
|
27 | - if ($this->params['loja'] != $lojaSession) |
|
28 | - { |
|
29 | - $loja = $this->params['loja']; |
|
30 | - } |
|
31 | - else |
|
32 | - { |
|
33 | - $loja = $lojaSession; |
|
34 | - } |
|
35 | - } |
|
36 | - else |
|
37 | - { |
|
38 | - $loja = $lojaSession; |
|
39 | - } |
|
40 | - } |
|
41 | - else |
|
42 | - { |
|
43 | - $loja = $this->params['loja']; |
|
44 | - } |
|
23 | + if (isset($lojaSession)) |
|
24 | + { |
|
25 | + if (isset($this->params['loja'])) |
|
26 | + { |
|
27 | + if ($this->params['loja'] != $lojaSession) |
|
28 | + { |
|
29 | + $loja = $this->params['loja']; |
|
30 | + } |
|
31 | + else |
|
32 | + { |
|
33 | + $loja = $lojaSession; |
|
34 | + } |
|
35 | + } |
|
36 | + else |
|
37 | + { |
|
38 | + $loja = $lojaSession; |
|
39 | + } |
|
40 | + } |
|
41 | + else |
|
42 | + { |
|
43 | + $loja = $this->params['loja']; |
|
44 | + } |
|
45 | 45 | |
46 | - if (!isset($loja)) |
|
47 | - { |
|
48 | - echo 'Loja não existe'; |
|
49 | - exit; |
|
50 | - } |
|
51 | - else |
|
52 | - { |
|
53 | - $this->loadModel('Usuario'); |
|
54 | - |
|
55 | - $this->usuario = $this->Usuario->find('first', array( |
|
56 | - 'conditions' => array( |
|
57 | - 'Usuario.loja' => $loja |
|
58 | - ) |
|
59 | - ) |
|
60 | - ); |
|
61 | - |
|
62 | - if (empty($this->usuario)) |
|
63 | - { |
|
64 | - echo 'Loja não existe'; |
|
65 | - exit; |
|
66 | - } |
|
67 | - |
|
68 | - $this->Session->write('Usuario.id', $this->usuario['Usuario']['id']);//gambi temporaria |
|
69 | - $this->Session->write('Usuario.loja', $this->usuario['Usuario']['loja']);//gambi temporaria |
|
70 | - |
|
71 | - $this->set('usuario', $this->usuario); |
|
72 | - |
|
73 | - $this->layout = $this->usuario['Usuario']['layout_loja']; |
|
74 | - } |
|
46 | + if (!isset($loja)) |
|
47 | + { |
|
48 | + echo 'Loja não existe'; |
|
49 | + exit; |
|
50 | + } |
|
51 | + else |
|
52 | + { |
|
53 | + $this->loadModel('Usuario'); |
|
54 | + |
|
55 | + $this->usuario = $this->Usuario->find('first', array( |
|
56 | + 'conditions' => array( |
|
57 | + 'Usuario.loja' => $loja |
|
58 | + ) |
|
59 | + ) |
|
60 | + ); |
|
61 | + |
|
62 | + if (empty($this->usuario)) |
|
63 | + { |
|
64 | + echo 'Loja não existe'; |
|
65 | + exit; |
|
66 | + } |
|
67 | + |
|
68 | + $this->Session->write('Usuario.id', $this->usuario['Usuario']['id']);//gambi temporaria |
|
69 | + $this->Session->write('Usuario.loja', $this->usuario['Usuario']['loja']);//gambi temporaria |
|
70 | + |
|
71 | + $this->set('usuario', $this->usuario); |
|
72 | + |
|
73 | + $this->layout = $this->usuario['Usuario']['layout_loja']; |
|
74 | + } |
|
75 | 75 | |
76 | 76 | return true; |
77 | 77 | } |
@@ -79,22 +79,22 @@ discard block |
||
79 | 79 | public function loadProducts($id_categoria = null, $id_produto = null) { |
80 | 80 | $this->loadModel('Produto'); |
81 | 81 | |
82 | - $params = array('conditions' => |
|
83 | - array( |
|
84 | - 'Produto.ativo' => 1, |
|
85 | - 'Produto.id_usuario' => $this->Session->read('Usuario.id'), |
|
86 | - 'Produto.destaque' => 1 |
|
87 | - ), |
|
88 | - 'limit' => 9 |
|
89 | - ); |
|
82 | + $params = array('conditions' => |
|
83 | + array( |
|
84 | + 'Produto.ativo' => 1, |
|
85 | + 'Produto.id_usuario' => $this->Session->read('Usuario.id'), |
|
86 | + 'Produto.destaque' => 1 |
|
87 | + ), |
|
88 | + 'limit' => 9 |
|
89 | + ); |
|
90 | 90 | |
91 | - if ($id_categoria != null) { |
|
92 | - $params['conditions']['Produto.categoria_id'] = $id_categoria; |
|
93 | - } |
|
91 | + if ($id_categoria != null) { |
|
92 | + $params['conditions']['Produto.categoria_id'] = $id_categoria; |
|
93 | + } |
|
94 | 94 | |
95 | - if ($id_produto != null) { |
|
96 | - $params['conditions']['Produto.id'] = $id_produto; |
|
97 | - } |
|
95 | + if ($id_produto != null) { |
|
96 | + $params['conditions']['Produto.id'] = $id_produto; |
|
97 | + } |
|
98 | 98 | |
99 | 99 | $produtos = $this->Produto->find('all', $params); |
100 | 100 | |
@@ -102,28 +102,28 @@ discard block |
||
102 | 102 | } |
103 | 103 | |
104 | 104 | public function loadBanners($id_banner = null) { |
105 | - $this->loadModel('Banner'); |
|
106 | - |
|
107 | - $params = array( |
|
108 | - 'joins' => array( |
|
109 | - array( |
|
110 | - 'table' => 'categoria_banners', |
|
111 | - 'alias' => 'CategoriaBanner', |
|
112 | - 'type' => 'LEFT', |
|
113 | - 'conditions' => array( |
|
114 | - 'Banner.categoria_banner_id = CategoriaBanner.id', |
|
115 | - ), |
|
116 | - ) |
|
117 | - ), |
|
118 | - 'conditions' => array( |
|
119 | - 'Banner.ativo' => 1, |
|
120 | - 'Banner.usuario_id' => $this->Session->read('Usuario.id') |
|
121 | - ) |
|
122 | - ); |
|
123 | - |
|
124 | - $banners = $this->Banner->find('all', $params); |
|
125 | - |
|
126 | - return $banners; |
|
105 | + $this->loadModel('Banner'); |
|
106 | + |
|
107 | + $params = array( |
|
108 | + 'joins' => array( |
|
109 | + array( |
|
110 | + 'table' => 'categoria_banners', |
|
111 | + 'alias' => 'CategoriaBanner', |
|
112 | + 'type' => 'LEFT', |
|
113 | + 'conditions' => array( |
|
114 | + 'Banner.categoria_banner_id = CategoriaBanner.id', |
|
115 | + ), |
|
116 | + ) |
|
117 | + ), |
|
118 | + 'conditions' => array( |
|
119 | + 'Banner.ativo' => 1, |
|
120 | + 'Banner.usuario_id' => $this->Session->read('Usuario.id') |
|
121 | + ) |
|
122 | + ); |
|
123 | + |
|
124 | + $banners = $this->Banner->find('all', $params); |
|
125 | + |
|
126 | + return $banners; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | public function addCart() { |
@@ -133,26 +133,26 @@ discard block |
||
133 | 133 | $this->redirect('/' . $this->usuario['Usuario']['loja'] . '/'); |
134 | 134 | } |
135 | 135 | |
136 | - if (!$this->validateProduct($produto)) { |
|
137 | - $this->Session->setFlash('Quantidade de produtos escolhidas é maior do que a disponivel!'); |
|
138 | - $this->redirect('/' . $this->usuario['Usuario']['loja'] . '/'); |
|
139 | - } |
|
136 | + if (!$this->validateProduct($produto)) { |
|
137 | + $this->Session->setFlash('Quantidade de produtos escolhidas é maior do que a disponivel!'); |
|
138 | + $this->redirect('/' . $this->usuario['Usuario']['loja'] . '/'); |
|
139 | + } |
|
140 | 140 | |
141 | 141 | $cont = count($this->Session->read('Produto')); |
142 | 142 | |
143 | 143 | $this->Session->write('Produto.'.$produto['id'].'.id' , $produto['id']); |
144 | - $this->Session->write('Produto.'.$produto['id'].'.quantidade' , $produto['quantidade']); |
|
145 | - $this->Session->write('Produto.'.$produto['id'].'.variacao', $produto['variacao']); |
|
144 | + $this->Session->write('Produto.'.$produto['id'].'.quantidade' , $produto['quantidade']); |
|
145 | + $this->Session->write('Produto.'.$produto['id'].'.variacao', $produto['variacao']); |
|
146 | 146 | |
147 | 147 | $this->redirect('/' . $this->usuario['Usuario']['loja'] . '/cart'); |
148 | 148 | } |
149 | 149 | |
150 | 150 | public function removeProductCart() { |
151 | - if ( ($this->Session->read('Produto.' . $this->params['id'])) !== null ) { |
|
152 | - $this->Session->delete( 'Produto.' . $this->params['id'] ); |
|
153 | - } |
|
151 | + if ( ($this->Session->read('Produto.' . $this->params['id'])) !== null ) { |
|
152 | + $this->Session->delete( 'Produto.' . $this->params['id'] ); |
|
153 | + } |
|
154 | 154 | |
155 | - $this->redirect('/' . $this->usuario['Usuario']['loja'] . '/cart'); |
|
155 | + $this->redirect('/' . $this->usuario['Usuario']['loja'] . '/cart'); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | public function clearCart() { |
@@ -160,368 +160,368 @@ discard block |
||
160 | 160 | } |
161 | 161 | |
162 | 162 | public function loadProductsAndValuesCart() { |
163 | - $this->loadModel('Produto'); |
|
164 | - $this->loadModel('Variacao'); |
|
163 | + $this->loadModel('Produto'); |
|
164 | + $this->loadModel('Variacao'); |
|
165 | 165 | |
166 | - $productsSession = $this->Session->read('Produto'); |
|
166 | + $productsSession = $this->Session->read('Produto'); |
|
167 | 167 | |
168 | - (float) $total = 0.00; |
|
169 | - $produtos = array(); |
|
170 | - foreach ($productsSession as $indice => $item) { |
|
171 | - $produto = $this->Produto->find('all', |
|
172 | - array('conditions' => |
|
173 | - array('Produto.ativo' => 1, |
|
174 | - 'Produto.id' => $item['id'] |
|
175 | - ) |
|
176 | - ) |
|
177 | - ); |
|
168 | + (float) $total = 0.00; |
|
169 | + $produtos = array(); |
|
170 | + foreach ($productsSession as $indice => $item) { |
|
171 | + $produto = $this->Produto->find('all', |
|
172 | + array('conditions' => |
|
173 | + array('Produto.ativo' => 1, |
|
174 | + 'Produto.id' => $item['id'] |
|
175 | + ) |
|
176 | + ) |
|
177 | + ); |
|
178 | 178 | |
179 | - $total += $produto[0]['Produto']['preco'] * $item['quantidade']; |
|
179 | + $total += $produto[0]['Produto']['preco'] * $item['quantidade']; |
|
180 | 180 | |
181 | - $produto[0]['Produto']['quantidade'] = $item['quantidade']; |
|
181 | + $produto[0]['Produto']['quantidade'] = $item['quantidade']; |
|
182 | 182 | |
183 | - $variacao = $this->Variacao->find('all', |
|
184 | - array('conditions' => |
|
185 | - array('Variacao.id' => $item['variacao']) |
|
186 | - ), |
|
187 | - array('fields' => |
|
188 | - array('Variacao.nome_variacao') |
|
189 | - ) |
|
190 | - ); |
|
183 | + $variacao = $this->Variacao->find('all', |
|
184 | + array('conditions' => |
|
185 | + array('Variacao.id' => $item['variacao']) |
|
186 | + ), |
|
187 | + array('fields' => |
|
188 | + array('Variacao.nome_variacao') |
|
189 | + ) |
|
190 | + ); |
|
191 | 191 | |
192 | - $produto[0]['Produto']['variacao'] = $variacao[0]['Variacao']['nome_variacao']; |
|
192 | + $produto[0]['Produto']['variacao'] = $variacao[0]['Variacao']['nome_variacao']; |
|
193 | 193 | |
194 | - $produtos[] = $produto[0]; |
|
195 | - } |
|
194 | + $produtos[] = $produto[0]; |
|
195 | + } |
|
196 | 196 | |
197 | - return array('products_cart' => $produtos, 'total' => $total); |
|
197 | + return array('products_cart' => $produtos, 'total' => $total); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | public function loadCategoriesProducts($id_categoria = null) { |
201 | - $this->loadModel('Categoria'); |
|
201 | + $this->loadModel('Categoria'); |
|
202 | 202 | |
203 | - $params = array('conditions' => |
|
204 | - array('ativo' => 1, |
|
205 | - 'usuario_id' => $this->Session->read('Usuario.id') |
|
206 | - ) |
|
207 | - ); |
|
203 | + $params = array('conditions' => |
|
204 | + array('ativo' => 1, |
|
205 | + 'usuario_id' => $this->Session->read('Usuario.id') |
|
206 | + ) |
|
207 | + ); |
|
208 | 208 | |
209 | - $categorias = $this->Categoria->find('all', $params); |
|
209 | + $categorias = $this->Categoria->find('all', $params); |
|
210 | 210 | |
211 | - return $categorias; |
|
211 | + return $categorias; |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | public function payment() { |
215 | - $andress = $this->request->data('endereco'); |
|
215 | + $andress = $this->request->data('endereco'); |
|
216 | 216 | |
217 | - $client = $this->request->data('cliente'); |
|
217 | + $client = $this->request->data('cliente'); |
|
218 | 218 | |
219 | - $products = $this->loadProductsAndValuesCart(); |
|
219 | + $products = $this->loadProductsAndValuesCart(); |
|
220 | 220 | |
221 | - (float) $valor_frete = number_format($this->Session->read('Frete.valor'), 2, '.', ','); |
|
221 | + (float) $valor_frete = number_format($this->Session->read('Frete.valor'), 2, '.', ','); |
|
222 | 222 | |
223 | - $objVenda = new VendaController(); |
|
223 | + $objVenda = new VendaController(); |
|
224 | 224 | |
225 | - $productsSale = $this->prepareProductsSale($products['products_cart']); |
|
225 | + $productsSale = $this->prepareProductsSale($products['products_cart']); |
|
226 | 226 | |
227 | - $usuario_id = $this->Session->read('Usuario.id'); |
|
227 | + $usuario_id = $this->Session->read('Usuario.id'); |
|
228 | 228 | |
229 | - $retorno_venda = $objVenda->salvar_venda($productsSale, array('forma_pagamento' => 'pagseguro'), array('valor' => $valor_frete + $products['total']), $usuario_id); |
|
229 | + $retorno_venda = $objVenda->salvar_venda($productsSale, array('forma_pagamento' => 'pagseguro'), array('valor' => $valor_frete + $products['total']), $usuario_id); |
|
230 | 230 | |
231 | - $this->paymentPagSeguro($products['products_cart'], $andress, $client, $products['total'], $valor_frete, $retorno_venda['id']); |
|
231 | + $this->paymentPagSeguro($products['products_cart'], $andress, $client, $products['total'], $valor_frete, $retorno_venda['id']); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | public function paymentPagSeguro($products, $andress, $client, $total, $shipping, $id) { |
235 | - $pagamento = new PagamentoController('PagseguroController'); |
|
235 | + $pagamento = new PagamentoController('PagseguroController'); |
|
236 | 236 | |
237 | - $pagamento->setToken($this->usuario['Usuario']['token_pagseguro']); |
|
237 | + $pagamento->setToken($this->usuario['Usuario']['token_pagseguro']); |
|
238 | 238 | |
239 | - $pagamento->setEmail($this->usuario['Usuario']['email_pagseguro']); |
|
239 | + $pagamento->setEmail($this->usuario['Usuario']['email_pagseguro']); |
|
240 | 240 | |
241 | - $pagamento->setProdutos($products); |
|
241 | + $pagamento->setProdutos($products); |
|
242 | 242 | |
243 | - $pagamento->adicionarProdutosGateway(); |
|
243 | + $pagamento->adicionarProdutosGateway(); |
|
244 | 244 | |
245 | - $pagamento->setEndereco($andress); |
|
245 | + $pagamento->setEndereco($andress); |
|
246 | 246 | |
247 | - $pagamento->setReference('#' . $id); |
|
247 | + $pagamento->setReference('#' . $id); |
|
248 | 248 | |
249 | - $pagamento->setValorFrete($shipping); |
|
249 | + $pagamento->setValorFrete($shipping); |
|
250 | 250 | |
251 | - return $this->redirect($pagamento->finalizarPedido()); |
|
251 | + return $this->redirect($pagamento->finalizarPedido()); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | public function prepareProductsSale($products) { |
255 | - $retorno = array(); |
|
255 | + $retorno = array(); |
|
256 | 256 | |
257 | - foreach ($products as $i => $product) { |
|
258 | - $retorno[$i]['id_produto'] = $product['Produto']['id']; |
|
259 | - $retorno[$i]['quantidade'] = $product['Produto']['quantidade']; |
|
260 | - $retorno[$i]['variacao'] = $product['Produto']['variacao']; |
|
261 | - } |
|
257 | + foreach ($products as $i => $product) { |
|
258 | + $retorno[$i]['id_produto'] = $product['Produto']['id']; |
|
259 | + $retorno[$i]['quantidade'] = $product['Produto']['quantidade']; |
|
260 | + $retorno[$i]['variacao'] = $product['Produto']['variacao']; |
|
261 | + } |
|
262 | 262 | |
263 | - return $retorno; |
|
263 | + return $retorno; |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | public function searchAndressByCep($cep) { |
267 | - $this->layout = 'ajax'; |
|
267 | + $this->layout = 'ajax'; |
|
268 | 268 | |
269 | - $curl = curl_init('http://cep.correiocontrol.com.br/'.$cep.'.js'); |
|
269 | + $curl = curl_init('http://cep.correiocontrol.com.br/'.$cep.'.js'); |
|
270 | 270 | |
271 | - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
|
271 | + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
|
272 | 272 | |
273 | - $resultado = curl_exec($curl); |
|
273 | + $resultado = curl_exec($curl); |
|
274 | 274 | |
275 | - echo $resultado; |
|
275 | + echo $resultado; |
|
276 | 276 | |
277 | - exit(); |
|
277 | + exit(); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | public function calcTransportAjax() { |
281 | - $this->layout = 'ajax'; |
|
281 | + $this->layout = 'ajax'; |
|
282 | 282 | |
283 | - $cep_destino = $this->request->data('cep_destino'); |
|
284 | - $cep_origem = $this->request->data('cep_origem'); |
|
283 | + $cep_destino = $this->request->data('cep_destino'); |
|
284 | + $cep_origem = $this->request->data('cep_origem'); |
|
285 | 285 | |
286 | - $dataProducts = $this->loadProductsAndValuesCart(); |
|
286 | + $dataProducts = $this->loadProductsAndValuesCart(); |
|
287 | 287 | |
288 | - (float) $peso = 0; |
|
289 | - foreach ($dataProducts['products_cart'] as $i => $product) { |
|
290 | - $peso += $product['Produto']['peso_bruto'] * $product['Produto']['quantidade']; |
|
291 | - } |
|
288 | + (float) $peso = 0; |
|
289 | + foreach ($dataProducts['products_cart'] as $i => $product) { |
|
290 | + $peso += $product['Produto']['peso_bruto'] * $product['Produto']['quantidade']; |
|
291 | + } |
|
292 | 292 | |
293 | - $fretes = $this->transport($cep_destino, $this->usuario['Usuario']['cep_origem'], $peso); |
|
293 | + $fretes = $this->transport($cep_destino, $this->usuario['Usuario']['cep_origem'], $peso); |
|
294 | 294 | |
295 | - $disponiveis = array(); |
|
295 | + $disponiveis = array(); |
|
296 | 296 | |
297 | - $cont = 0; |
|
298 | - foreach ($fretes as $i => $frete) { |
|
299 | - $disponiveis[$cont]['valor'] = (array) $frete->Valor; |
|
300 | - $disponiveis[$cont]['prazo'] = (array) $frete->PrazoEntrega; |
|
301 | - $disponiveis[$cont]['codigo'] = (array) $frete->Codigo; |
|
302 | - $disponiveis[$cont]['valor'] = array_shift($disponiveis[$cont]['valor']); |
|
303 | - $disponiveis[$cont]['prazo'] = array_shift($disponiveis[$cont]['prazo']); |
|
304 | - $disponiveis[$cont]['codigo'] = array_shift($disponiveis[$cont]['codigo']); |
|
297 | + $cont = 0; |
|
298 | + foreach ($fretes as $i => $frete) { |
|
299 | + $disponiveis[$cont]['valor'] = (array) $frete->Valor; |
|
300 | + $disponiveis[$cont]['prazo'] = (array) $frete->PrazoEntrega; |
|
301 | + $disponiveis[$cont]['codigo'] = (array) $frete->Codigo; |
|
302 | + $disponiveis[$cont]['valor'] = array_shift($disponiveis[$cont]['valor']); |
|
303 | + $disponiveis[$cont]['prazo'] = array_shift($disponiveis[$cont]['prazo']); |
|
304 | + $disponiveis[$cont]['codigo'] = array_shift($disponiveis[$cont]['codigo']); |
|
305 | 305 | |
306 | - $cont++; |
|
307 | - } |
|
306 | + $cont++; |
|
307 | + } |
|
308 | 308 | |
309 | - $this->Session->write('Frete.valor', $disponiveis[$cont - 1]['valor']); |
|
309 | + $this->Session->write('Frete.valor', $disponiveis[$cont - 1]['valor']); |
|
310 | 310 | |
311 | - (float) $total = $disponiveis[$cont - 1]['valor'] + $dataProducts['total']; |
|
311 | + (float) $total = $disponiveis[$cont - 1]['valor'] + $dataProducts['total']; |
|
312 | 312 | |
313 | - $total = number_format($total, 2, ',', '.'); |
|
313 | + $total = number_format($total, 2, ',', '.'); |
|
314 | 314 | |
315 | - $retorno = array('frete' => $disponiveis[$cont - 1]['valor'], 'total' => $total); |
|
315 | + $retorno = array('frete' => $disponiveis[$cont - 1]['valor'], 'total' => $total); |
|
316 | 316 | |
317 | - echo json_encode($retorno); |
|
318 | - exit(); |
|
317 | + echo json_encode($retorno); |
|
318 | + exit(); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | public function transport($cep_destino, $cep_origem, $peso) { |
322 | - $altura = '2'; |
|
323 | - $largura = '11'; |
|
324 | - $comprimento = '16'; |
|
325 | - |
|
326 | - $dados['sCepDestino'] = $cep_destino; |
|
327 | - $dados['sCepOrigem'] = $cep_origem; |
|
328 | - $dados['nVlPeso'] = $peso; |
|
329 | - $dados['nVlComprimento'] = $comprimento; |
|
330 | - $dados['nVlAltura'] = $altura; |
|
331 | - $dados['nVlLargura'] = $largura; |
|
332 | - $dados['nCdServico'] = '41106'; |
|
333 | - $dados['nVlDiametro'] = '2'; |
|
334 | - $dados['nCdFormato'] = '1'; |
|
335 | - $dados['sCdMaoPropria'] = 'n'; |
|
336 | - $dados['nVlValorDeclarado'] = '0'; |
|
337 | - $dados['StrRetorno'] = 'xml'; |
|
322 | + $altura = '2'; |
|
323 | + $largura = '11'; |
|
324 | + $comprimento = '16'; |
|
325 | + |
|
326 | + $dados['sCepDestino'] = $cep_destino; |
|
327 | + $dados['sCepOrigem'] = $cep_origem; |
|
328 | + $dados['nVlPeso'] = $peso; |
|
329 | + $dados['nVlComprimento'] = $comprimento; |
|
330 | + $dados['nVlAltura'] = $altura; |
|
331 | + $dados['nVlLargura'] = $largura; |
|
332 | + $dados['nCdServico'] = '41106'; |
|
333 | + $dados['nVlDiametro'] = '2'; |
|
334 | + $dados['nCdFormato'] = '1'; |
|
335 | + $dados['sCdMaoPropria'] = 'n'; |
|
336 | + $dados['nVlValorDeclarado'] = '0'; |
|
337 | + $dados['StrRetorno'] = 'xml'; |
|
338 | 338 | |
339 | - $dados = http_build_query($dados); |
|
339 | + $dados = http_build_query($dados); |
|
340 | 340 | |
341 | - $curl = curl_init('http://ws.correios.com.br/calculador/CalcPrecoPrazo.aspx' . '?' . $dados); |
|
341 | + $curl = curl_init('http://ws.correios.com.br/calculador/CalcPrecoPrazo.aspx' . '?' . $dados); |
|
342 | 342 | |
343 | - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
|
343 | + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
|
344 | 344 | |
345 | - $resultado = curl_exec($curl); |
|
346 | - $resultado = simplexml_load_string($resultado); |
|
345 | + $resultado = curl_exec($curl); |
|
346 | + $resultado = simplexml_load_string($resultado); |
|
347 | 347 | |
348 | - return $resultado; |
|
348 | + return $resultado; |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | public function saveEmailNewsletter() { |
352 | - $nome = $this->request->data('nome'); |
|
353 | - $email = $this->request->data('email'); |
|
352 | + $nome = $this->request->data('nome'); |
|
353 | + $email = $this->request->data('email'); |
|
354 | 354 | |
355 | - $objNewsletter = new NewsletterController(); |
|
355 | + $objNewsletter = new NewsletterController(); |
|
356 | 356 | |
357 | - if ($objNewsletter->newsletter_cadastro($nome, $email, $this->Session->read('Usuario.id'))) |
|
358 | - { |
|
359 | - echo json_encode(true); |
|
360 | - exit(); |
|
361 | - } |
|
357 | + if ($objNewsletter->newsletter_cadastro($nome, $email, $this->Session->read('Usuario.id'))) |
|
358 | + { |
|
359 | + echo json_encode(true); |
|
360 | + exit(); |
|
361 | + } |
|
362 | 362 | |
363 | - echo json_encode(false); |
|
364 | - exit(); |
|
363 | + echo json_encode(false); |
|
364 | + exit(); |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | public function useCoupon() { |
368 | - $this->layout = 'ajax'; |
|
368 | + $this->layout = 'ajax'; |
|
369 | 369 | |
370 | - $cupom = $this->request->data('cupom'); |
|
371 | - $valor = $this->request->data('valor'); |
|
370 | + $cupom = $this->request->data('cupom'); |
|
371 | + $valor = $this->request->data('valor'); |
|
372 | 372 | |
373 | - $objCupom = new CupomController(); |
|
374 | - $novo_valor = $objCupom->utilizar_cupom($cupom, $valor, $this->Session->read('Usuario.id')); |
|
373 | + $objCupom = new CupomController(); |
|
374 | + $novo_valor = $objCupom->utilizar_cupom($cupom, $valor, $this->Session->read('Usuario.id')); |
|
375 | 375 | |
376 | - if (!$novo_valor) |
|
377 | - { |
|
378 | - echo json_encode(false); |
|
379 | - exit(); |
|
380 | - } |
|
376 | + if (!$novo_valor) |
|
377 | + { |
|
378 | + echo json_encode(false); |
|
379 | + exit(); |
|
380 | + } |
|
381 | 381 | |
382 | - echo json_encode($novo_valor); |
|
383 | - exit(); |
|
382 | + echo json_encode($novo_valor); |
|
383 | + exit(); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | public function validateProduct($data) { |
387 | - $this->loadModel('Variacao'); |
|
387 | + $this->loadModel('Variacao'); |
|
388 | 388 | |
389 | - $params = array('conditions' => |
|
390 | - array( |
|
391 | - 'Variacao.id' => $data['variacao'] |
|
392 | - ) |
|
393 | - ); |
|
389 | + $params = array('conditions' => |
|
390 | + array( |
|
391 | + 'Variacao.id' => $data['variacao'] |
|
392 | + ) |
|
393 | + ); |
|
394 | 394 | |
395 | - $variacao = $this->Variacao->find('all', $params); |
|
395 | + $variacao = $this->Variacao->find('all', $params); |
|
396 | 396 | |
397 | - if ($variacao[0]['Variacao']['estoque'] <= 0 || $data['quantidade'] > $variacao[0]['Variacao']['estoque']) |
|
398 | - { |
|
399 | - return false; |
|
400 | - } |
|
397 | + if ($variacao[0]['Variacao']['estoque'] <= 0 || $data['quantidade'] > $variacao[0]['Variacao']['estoque']) |
|
398 | + { |
|
399 | + return false; |
|
400 | + } |
|
401 | 401 | |
402 | - return true; |
|
402 | + return true; |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | public function saveClientFromEcommerce($data) { |
406 | - $this->loadModel('Cliente'); |
|
406 | + $this->loadModel('Cliente'); |
|
407 | 407 | |
408 | - $data['senha'] = sha1($data['senha']); |
|
408 | + $data['senha'] = sha1($data['senha']); |
|
409 | 409 | |
410 | - $this->Cliente->set($data); |
|
410 | + $this->Cliente->set($data); |
|
411 | 411 | |
412 | - if (!$this->Cliente->validates()) |
|
413 | - { |
|
414 | - return false; |
|
415 | - } |
|
412 | + if (!$this->Cliente->validates()) |
|
413 | + { |
|
414 | + return false; |
|
415 | + } |
|
416 | 416 | |
417 | - if (!$this->Cliente->save()) |
|
418 | - { |
|
419 | - return false; |
|
420 | - } |
|
417 | + if (!$this->Cliente->save()) |
|
418 | + { |
|
419 | + return false; |
|
420 | + } |
|
421 | 421 | |
422 | - return $this->Cliente->getLastInsertId(); |
|
422 | + return $this->Cliente->getLastInsertId(); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | public function saveAndressClientFromEcommerce($data) { |
426 | - $this->loadModel('EnderecoClienteCadastro'); |
|
426 | + $this->loadModel('EnderecoClienteCadastro'); |
|
427 | 427 | |
428 | - $this->EnderecoClienteCadastro->set($data); |
|
428 | + $this->EnderecoClienteCadastro->set($data); |
|
429 | 429 | |
430 | - if (!$this->EnderecoClienteCadastro->validates()) |
|
431 | - { |
|
432 | - return false; |
|
433 | - } |
|
430 | + if (!$this->EnderecoClienteCadastro->validates()) |
|
431 | + { |
|
432 | + return false; |
|
433 | + } |
|
434 | 434 | |
435 | - return $this->EnderecoClienteCadastro->save(); |
|
435 | + return $this->EnderecoClienteCadastro->save(); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
439 | - * Views |
|
440 | - */ |
|
439 | + * Views |
|
440 | + */ |
|
441 | 441 | public function index() { |
442 | - $this->set('usuario', $this->usuario); |
|
443 | - $this->set('banners', $this->loadBanners()); |
|
444 | - $this->set('categorias', $this->loadCategoriesProducts()); |
|
445 | - $this->set('produtos', $this->loadProducts()); |
|
442 | + $this->set('usuario', $this->usuario); |
|
443 | + $this->set('banners', $this->loadBanners()); |
|
444 | + $this->set('categorias', $this->loadCategoriesProducts()); |
|
445 | + $this->set('produtos', $this->loadProducts()); |
|
446 | 446 | |
447 | - $this->render('/' . $this->usuario['Usuario']['folder_view'] . '/index'); |
|
447 | + $this->render('/' . $this->usuario['Usuario']['folder_view'] . '/index'); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | public function cart() { |
451 | - $this->set('usuario', $this->usuario); |
|
452 | - $this->set('categorias', $this->loadCategoriesProducts()); |
|
453 | - $products = $this->loadProductsAndValuesCart(); |
|
451 | + $this->set('usuario', $this->usuario); |
|
452 | + $this->set('categorias', $this->loadCategoriesProducts()); |
|
453 | + $products = $this->loadProductsAndValuesCart(); |
|
454 | 454 | |
455 | - $this->set('products', $products['products_cart']); |
|
456 | - $this->set('total', $products['total']); |
|
455 | + $this->set('products', $products['products_cart']); |
|
456 | + $this->set('total', $products['total']); |
|
457 | 457 | |
458 | - $this->render('/' . $this->usuario['Usuario']['folder_view'] . '/cart'); |
|
458 | + $this->render('/' . $this->usuario['Usuario']['folder_view'] . '/cart'); |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | public function checkout() { |
462 | - $this->set('usuario', $this->usuario); |
|
463 | - $this->set('categorias', $this->loadCategoriesProducts()); |
|
464 | - $products = $this->loadProductsAndValuesCart(); |
|
462 | + $this->set('usuario', $this->usuario); |
|
463 | + $this->set('categorias', $this->loadCategoriesProducts()); |
|
464 | + $products = $this->loadProductsAndValuesCart(); |
|
465 | 465 | |
466 | - $this->set('products', $products['products_cart']); |
|
467 | - $this->set('total', $products['total']); |
|
466 | + $this->set('products', $products['products_cart']); |
|
467 | + $this->set('total', $products['total']); |
|
468 | 468 | |
469 | - $this->render('/' . $this->usuario['Usuario']['folder_view'] . '/checkout'); |
|
469 | + $this->render('/' . $this->usuario['Usuario']['folder_view'] . '/checkout'); |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | public function category() { |
473 | - $this->set('usuario', $this->usuario); |
|
474 | - $id = $this->params['id']; |
|
475 | - $nome = $this->params['nome']; |
|
473 | + $this->set('usuario', $this->usuario); |
|
474 | + $id = $this->params['id']; |
|
475 | + $nome = $this->params['nome']; |
|
476 | 476 | |
477 | - $products = $this->loadProducts($id); |
|
477 | + $products = $this->loadProducts($id); |
|
478 | 478 | |
479 | - $this->set('categorias', $this->loadCategoriesProducts()); |
|
480 | - $this->set('produtos', $products); |
|
481 | - $this->set('nameCategory', $nome); |
|
479 | + $this->set('categorias', $this->loadCategoriesProducts()); |
|
480 | + $this->set('produtos', $products); |
|
481 | + $this->set('nameCategory', $nome); |
|
482 | 482 | |
483 | - $this->render('/' . $this->usuario['Usuario']['folder_view'] . '/category'); |
|
483 | + $this->render('/' . $this->usuario['Usuario']['folder_view'] . '/category'); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | public function product() { |
487 | - $this->set('usuario', $this->usuario); |
|
488 | - $this->loadModel('Produto'); |
|
487 | + $this->set('usuario', $this->usuario); |
|
488 | + $this->loadModel('Produto'); |
|
489 | 489 | |
490 | - $id = $this->params['id']; |
|
490 | + $id = $this->params['id']; |
|
491 | 491 | |
492 | - $this->set('categorias', $this->loadCategoriesProducts()); |
|
492 | + $this->set('categorias', $this->loadCategoriesProducts()); |
|
493 | 493 | |
494 | - $produto = $this->loadProducts(null, $id)[0]; |
|
495 | - |
|
496 | - $this->loadModel('Variacao'); |
|
497 | - |
|
498 | - $query = array ( |
|
499 | - 'joins' => array( |
|
500 | - array( |
|
501 | - 'table' => 'produtos', |
|
502 | - 'alias' => 'Produto', |
|
503 | - 'type' => 'LEFT', |
|
504 | - 'conditions' => array( |
|
505 | - 'Variacao.produto_id = Produto.id', |
|
506 | - ), |
|
507 | - ) |
|
508 | - ), |
|
509 | - 'conditions' => array('Variacao.produto_id' => $id, 'Variacao.ativo' => 1), |
|
510 | - 'fields' => array('Produto.id, Variacao.*'), |
|
511 | - ); |
|
512 | - |
|
513 | - $variacoes = $this->Variacao->find('all', $query); |
|
514 | - $this->set('variacoes', $variacoes); |
|
515 | - |
|
516 | - $this->set('produto', $produto); |
|
517 | - |
|
518 | - $this->render('/' . $this->usuario['Usuario']['folder_view'] . '/product'); |
|
494 | + $produto = $this->loadProducts(null, $id)[0]; |
|
495 | + |
|
496 | + $this->loadModel('Variacao'); |
|
497 | + |
|
498 | + $query = array ( |
|
499 | + 'joins' => array( |
|
500 | + array( |
|
501 | + 'table' => 'produtos', |
|
502 | + 'alias' => 'Produto', |
|
503 | + 'type' => 'LEFT', |
|
504 | + 'conditions' => array( |
|
505 | + 'Variacao.produto_id = Produto.id', |
|
506 | + ), |
|
507 | + ) |
|
508 | + ), |
|
509 | + 'conditions' => array('Variacao.produto_id' => $id, 'Variacao.ativo' => 1), |
|
510 | + 'fields' => array('Produto.id, Variacao.*'), |
|
511 | + ); |
|
512 | + |
|
513 | + $variacoes = $this->Variacao->find('all', $query); |
|
514 | + $this->set('variacoes', $variacoes); |
|
515 | + |
|
516 | + $this->set('produto', $produto); |
|
517 | + |
|
518 | + $this->render('/' . $this->usuario['Usuario']['folder_view'] . '/product'); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | public function retornopagseguro() { |
522 | - $code = $_GET['code']; |
|
522 | + $code = $_GET['code']; |
|
523 | 523 | |
524 | - pr($code,1); |
|
524 | + pr($code,1); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | } |
528 | 528 | \ No newline at end of file |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | */ |
27 | 27 | //Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home')); |
28 | 28 | /** |
29 | - * ...and connect the rest of 'Pages' controller's URLs. |
|
30 | - */ |
|
29 | + * ...and connect the rest of 'Pages' controller's URLs. |
|
30 | + */ |
|
31 | 31 | //Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display')); |
32 | 32 | |
33 | 33 | $dominio = verificar_dominio(); |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | |
49 | 49 | require($caminho); |
50 | 50 | /** |
51 | - * Load all plugin routes. See the CakePlugin documentation on |
|
52 | - * how to customize the loading of plugin routes. |
|
53 | - */ |
|
51 | + * Load all plugin routes. See the CakePlugin documentation on |
|
52 | + * how to customize the loading of plugin routes. |
|
53 | + */ |
|
54 | 54 | CakePlugin::routes(); |
55 | 55 | |
56 | 56 | /** |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | */ |
60 | 60 | require CAKE . 'Config' . DS . 'routes.php'; |
61 | 61 | /** |
62 | - * Função para verificar se o dominio pentece ao site, caso não pertença redireciona ao site correto |
|
63 | - */ |
|
62 | + * Função para verificar se o dominio pentece ao site, caso não pertença redireciona ao site correto |
|
63 | + */ |
|
64 | 64 | function verificar_dominio() { |
65 | 65 | $dominiosWinners = array ( |
66 | 66 | 'winners.local', |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | Router::connect('/', array('controller' => $dominio['controller'], 'action' => $dominio['funcao'])); |
39 | 39 | } |
40 | 40 | |
41 | - $caminho = APP . 'Config/routesshop.php'; |
|
41 | + $caminho = APP.'Config/routesshop.php'; |
|
42 | 42 | |
43 | 43 | Router::connect('/servicos', array('controller' => 'home', 'action', 'servicos')); |
44 | 44 | Router::connect('/linha-do-tempo-winners-opensource', array('controller' => 'home', 'action' => 'timeline')); |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | * Load the CakePHP default routes. Only remove this if you do not want to use |
58 | 58 | * the built-in default routes. |
59 | 59 | */ |
60 | - require CAKE . 'Config' . DS . 'routes.php'; |
|
60 | + require CAKE.'Config'.DS.'routes.php'; |
|
61 | 61 | /** |
62 | 62 | * Função para verificar se o dominio pentece ao site, caso não pertença redireciona ao site correto |
63 | 63 | */ |
64 | 64 | function verificar_dominio() { |
65 | - $dominiosWinners = array ( |
|
65 | + $dominiosWinners = array( |
|
66 | 66 | 'winners.local', |
67 | 67 | 'blog.winnersdesenvolvimento.com.br', |
68 | 68 | 'ciawn.com.br', |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | exit(); |
96 | 96 | } |
97 | 97 | |
98 | - $caminho = APP . 'Config/Domain/' . $varDominio . '.php'; |
|
99 | - if (!file_exists($caminho)) |
|
98 | + $caminho = APP.'Config/Domain/'.$varDominio.'.php'; |
|
99 | + if ( ! file_exists($caminho)) |
|
100 | 100 | { |
101 | 101 | $retorno['is_winners'] = true; |
102 | 102 | return $retorno; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $retorno['is_winners'] = false; |
108 | 108 | $retorno['id_usuario'] = $dominio['id_usuario']; |
109 | 109 | $retorno['controller'] = $dominio['controller']; |
110 | - $retorno['funcao'] = $dominio['funcao']; |
|
110 | + $retorno['funcao'] = $dominio['funcao']; |
|
111 | 111 | |
112 | 112 | return $retorno; |
113 | 113 | } |
114 | 114 | \ No newline at end of file |