@@ -79,6 +79,10 @@ |
||
| 79 | 79 | * Metodo que verifica se determinado modulo está ativo |
| 80 | 80 | * @param array modulo |
| 81 | 81 | */ |
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * @param string $modulo |
|
| 85 | + */ |
|
| 82 | 86 | function verificar_modulo_ativo($modulo) { |
| 83 | 87 | $retorno = array_key_exists($modulo, $this->modulos); |
| 84 | 88 | return $retorno; |
@@ -9,9 +9,6 @@ |
||
| 9 | 9 | |
| 10 | 10 | require_once(ROOT . DS . 'vendor' . DS . 'autoload.php'); |
| 11 | 11 | |
| 12 | -use FastShipping\Lib\Tracking; |
|
| 13 | -use FastShipping\Lib\Shipping; |
|
| 14 | - |
|
| 15 | 12 | class LojaController extends AppController { |
| 16 | 13 | public $layout = 'lojaexemplo'; |
| 17 | 14 | |
@@ -18,58 +18,58 @@ 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->layout = $this->usuario['Usuario']['layout_loja']; |
|
| 72 | - } |
|
| 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->layout = $this->usuario['Usuario']['layout_loja']; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | 74 | return true; |
| 75 | 75 | } |
@@ -77,21 +77,21 @@ discard block |
||
| 77 | 77 | public function loadProducts($id_categoria = null, $id_produto = null) { |
| 78 | 78 | $this->loadModel('Produto'); |
| 79 | 79 | |
| 80 | - $params = array('conditions' => |
|
| 81 | - array( |
|
| 82 | - 'Produto.ativo' => 1, |
|
| 83 | - 'Produto.id_usuario' => $this->Session->read('Usuario.id') |
|
| 84 | - ), |
|
| 85 | - 'limit' => 8 |
|
| 86 | - ); |
|
| 80 | + $params = array('conditions' => |
|
| 81 | + array( |
|
| 82 | + 'Produto.ativo' => 1, |
|
| 83 | + 'Produto.id_usuario' => $this->Session->read('Usuario.id') |
|
| 84 | + ), |
|
| 85 | + 'limit' => 8 |
|
| 86 | + ); |
|
| 87 | 87 | |
| 88 | - if ($id_categoria != null) { |
|
| 89 | - $params['conditions']['Produto.categoria_id'] = $id_categoria; |
|
| 90 | - } |
|
| 88 | + if ($id_categoria != null) { |
|
| 89 | + $params['conditions']['Produto.categoria_id'] = $id_categoria; |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - if ($id_produto != null) { |
|
| 93 | - $params['conditions']['Produto.id'] = $id_produto; |
|
| 94 | - } |
|
| 92 | + if ($id_produto != null) { |
|
| 93 | + $params['conditions']['Produto.id'] = $id_produto; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | 96 | $produtos = $this->Produto->find('all', $params); |
| 97 | 97 | |
@@ -99,28 +99,28 @@ discard block |
||
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | public function loadBanners($id_banner = null) { |
| 102 | - $this->loadModel('Banner'); |
|
| 103 | - |
|
| 104 | - $params = array( |
|
| 105 | - 'joins' => array( |
|
| 106 | - array( |
|
| 107 | - 'table' => 'categoria_banners', |
|
| 108 | - 'alias' => 'CategoriaBanner', |
|
| 109 | - 'type' => 'LEFT', |
|
| 110 | - 'conditions' => array( |
|
| 111 | - 'Banner.categoria_banner_id = CategoriaBanner.id', |
|
| 112 | - ), |
|
| 113 | - ) |
|
| 114 | - ), |
|
| 115 | - 'conditions' => array( |
|
| 116 | - 'Banner.ativo' => 1, |
|
| 117 | - 'Banner.usuario_id' => $this->Session->read('Usuario.id') |
|
| 118 | - ) |
|
| 119 | - ); |
|
| 120 | - |
|
| 121 | - $banners = $this->Banner->find('all', $params); |
|
| 122 | - |
|
| 123 | - return $banners; |
|
| 102 | + $this->loadModel('Banner'); |
|
| 103 | + |
|
| 104 | + $params = array( |
|
| 105 | + 'joins' => array( |
|
| 106 | + array( |
|
| 107 | + 'table' => 'categoria_banners', |
|
| 108 | + 'alias' => 'CategoriaBanner', |
|
| 109 | + 'type' => 'LEFT', |
|
| 110 | + 'conditions' => array( |
|
| 111 | + 'Banner.categoria_banner_id = CategoriaBanner.id', |
|
| 112 | + ), |
|
| 113 | + ) |
|
| 114 | + ), |
|
| 115 | + 'conditions' => array( |
|
| 116 | + 'Banner.ativo' => 1, |
|
| 117 | + 'Banner.usuario_id' => $this->Session->read('Usuario.id') |
|
| 118 | + ) |
|
| 119 | + ); |
|
| 120 | + |
|
| 121 | + $banners = $this->Banner->find('all', $params); |
|
| 122 | + |
|
| 123 | + return $banners; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | public function addCart() { |
@@ -130,26 +130,26 @@ discard block |
||
| 130 | 130 | $this->redirect('/' . $this->usuario['Usuario']['loja'] . '/'); |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - if (!$this->validateProduct($produto)) { |
|
| 134 | - $this->Session->setFlash('Quantidade de produtos escolhidas é maior do que a disponivel!'); |
|
| 135 | - $this->redirect('/' . $this->usuario['Usuario']['loja'] . '/'); |
|
| 136 | - } |
|
| 133 | + if (!$this->validateProduct($produto)) { |
|
| 134 | + $this->Session->setFlash('Quantidade de produtos escolhidas é maior do que a disponivel!'); |
|
| 135 | + $this->redirect('/' . $this->usuario['Usuario']['loja'] . '/'); |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | 138 | $cont = count($this->Session->read('Produto')); |
| 139 | 139 | |
| 140 | 140 | $this->Session->write('Produto.'.$produto['id'].'.id' , $produto['id']); |
| 141 | - $this->Session->write('Produto.'.$produto['id'].'.quantidade' , $produto['quantidade']); |
|
| 142 | - $this->Session->write('Produto.'.$produto['id'].'.variacao', $produto['variacao']); |
|
| 141 | + $this->Session->write('Produto.'.$produto['id'].'.quantidade' , $produto['quantidade']); |
|
| 142 | + $this->Session->write('Produto.'.$produto['id'].'.variacao', $produto['variacao']); |
|
| 143 | 143 | |
| 144 | 144 | $this->redirect('/' . $this->usuario['Usuario']['loja'] . '/cart'); |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | public function removeProductCart() { |
| 148 | - if ( ($this->Session->read('Produto.' . $this->params['id'])) !== null ) { |
|
| 149 | - $this->Session->delete( 'Produto.' . $this->params['id'] ); |
|
| 150 | - } |
|
| 148 | + if ( ($this->Session->read('Produto.' . $this->params['id'])) !== null ) { |
|
| 149 | + $this->Session->delete( 'Produto.' . $this->params['id'] ); |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - $this->redirect('/' . $this->usuario['Usuario']['loja'] . '/cart'); |
|
| 152 | + $this->redirect('/' . $this->usuario['Usuario']['loja'] . '/cart'); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | public function clearCart() { |
@@ -157,368 +157,368 @@ discard block |
||
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | public function loadProductsAndValuesCart() { |
| 160 | - $this->loadModel('Produto'); |
|
| 161 | - $this->loadModel('Variacao'); |
|
| 160 | + $this->loadModel('Produto'); |
|
| 161 | + $this->loadModel('Variacao'); |
|
| 162 | 162 | |
| 163 | - $productsSession = $this->Session->read('Produto'); |
|
| 163 | + $productsSession = $this->Session->read('Produto'); |
|
| 164 | 164 | |
| 165 | - (float) $total = 0.00; |
|
| 166 | - $produtos = array(); |
|
| 167 | - foreach ($productsSession as $indice => $item) { |
|
| 168 | - $produto = $this->Produto->find('all', |
|
| 169 | - array('conditions' => |
|
| 170 | - array('Produto.ativo' => 1, |
|
| 171 | - 'Produto.id' => $item['id'] |
|
| 172 | - ) |
|
| 173 | - ) |
|
| 174 | - ); |
|
| 165 | + (float) $total = 0.00; |
|
| 166 | + $produtos = array(); |
|
| 167 | + foreach ($productsSession as $indice => $item) { |
|
| 168 | + $produto = $this->Produto->find('all', |
|
| 169 | + array('conditions' => |
|
| 170 | + array('Produto.ativo' => 1, |
|
| 171 | + 'Produto.id' => $item['id'] |
|
| 172 | + ) |
|
| 173 | + ) |
|
| 174 | + ); |
|
| 175 | 175 | |
| 176 | - $total += $produto[0]['Produto']['preco'] * $item['quantidade']; |
|
| 176 | + $total += $produto[0]['Produto']['preco'] * $item['quantidade']; |
|
| 177 | 177 | |
| 178 | - $produto[0]['Produto']['quantidade'] = $item['quantidade']; |
|
| 178 | + $produto[0]['Produto']['quantidade'] = $item['quantidade']; |
|
| 179 | 179 | |
| 180 | - $variacao = $this->Variacao->find('all', |
|
| 181 | - array('conditions' => |
|
| 182 | - array('Variacao.id' => $item['variacao']) |
|
| 183 | - ), |
|
| 184 | - array('fields' => |
|
| 185 | - array('Variacao.nome_variacao') |
|
| 186 | - ) |
|
| 187 | - ); |
|
| 180 | + $variacao = $this->Variacao->find('all', |
|
| 181 | + array('conditions' => |
|
| 182 | + array('Variacao.id' => $item['variacao']) |
|
| 183 | + ), |
|
| 184 | + array('fields' => |
|
| 185 | + array('Variacao.nome_variacao') |
|
| 186 | + ) |
|
| 187 | + ); |
|
| 188 | 188 | |
| 189 | - $produto[0]['Produto']['variacao'] = $variacao[0]['Variacao']['nome_variacao']; |
|
| 189 | + $produto[0]['Produto']['variacao'] = $variacao[0]['Variacao']['nome_variacao']; |
|
| 190 | 190 | |
| 191 | - $produtos[] = $produto[0]; |
|
| 192 | - } |
|
| 191 | + $produtos[] = $produto[0]; |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | - return array('products_cart' => $produtos, 'total' => $total); |
|
| 194 | + return array('products_cart' => $produtos, 'total' => $total); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | public function loadCategoriesProducts($id_categoria = null) { |
| 198 | - $this->loadModel('Categoria'); |
|
| 198 | + $this->loadModel('Categoria'); |
|
| 199 | 199 | |
| 200 | - $params = array('conditions' => |
|
| 201 | - array('ativo' => 1, |
|
| 202 | - 'usuario_id' => $this->Session->read('Usuario.id') |
|
| 203 | - ) |
|
| 204 | - ); |
|
| 200 | + $params = array('conditions' => |
|
| 201 | + array('ativo' => 1, |
|
| 202 | + 'usuario_id' => $this->Session->read('Usuario.id') |
|
| 203 | + ) |
|
| 204 | + ); |
|
| 205 | 205 | |
| 206 | - $categorias = $this->Categoria->find('all', $params); |
|
| 206 | + $categorias = $this->Categoria->find('all', $params); |
|
| 207 | 207 | |
| 208 | - return $categorias; |
|
| 208 | + return $categorias; |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | public function payment() { |
| 212 | - $andress = $this->request->data('endereco'); |
|
| 212 | + $andress = $this->request->data('endereco'); |
|
| 213 | 213 | |
| 214 | - $client = $this->request->data('cliente'); |
|
| 214 | + $client = $this->request->data('cliente'); |
|
| 215 | 215 | |
| 216 | - $products = $this->loadProductsAndValuesCart(); |
|
| 216 | + $products = $this->loadProductsAndValuesCart(); |
|
| 217 | 217 | |
| 218 | - (float) $valor_frete = number_format($this->Session->read('Frete.valor'), 2, '.', ','); |
|
| 218 | + (float) $valor_frete = number_format($this->Session->read('Frete.valor'), 2, '.', ','); |
|
| 219 | 219 | |
| 220 | - $objVenda = new VendaController(); |
|
| 220 | + $objVenda = new VendaController(); |
|
| 221 | 221 | |
| 222 | - $productsSale = $this->prepareProductsSale($products['products_cart']); |
|
| 222 | + $productsSale = $this->prepareProductsSale($products['products_cart']); |
|
| 223 | 223 | |
| 224 | - $usuario_id = $this->Session->read('Usuario.id'); |
|
| 224 | + $usuario_id = $this->Session->read('Usuario.id'); |
|
| 225 | 225 | |
| 226 | - $retorno_venda = $objVenda->salvar_venda($productsSale, array('forma_pagamento' => 'pagseguro'), array('valor' => $valor_frete + $products['total']), $usuario_id); |
|
| 226 | + $retorno_venda = $objVenda->salvar_venda($productsSale, array('forma_pagamento' => 'pagseguro'), array('valor' => $valor_frete + $products['total']), $usuario_id); |
|
| 227 | 227 | |
| 228 | - $this->paymentPagSeguro($products['products_cart'], $andress, $client, $products['total'], $valor_frete, $retorno_venda['id']); |
|
| 228 | + $this->paymentPagSeguro($products['products_cart'], $andress, $client, $products['total'], $valor_frete, $retorno_venda['id']); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | public function paymentPagSeguro($products, $andress, $client, $total, $shipping, $id) { |
| 232 | - $pagamento = new PagamentoController('PagseguroController'); |
|
| 232 | + $pagamento = new PagamentoController('PagseguroController'); |
|
| 233 | 233 | |
| 234 | - $pagamento->setToken($this->usuario['Usuario']['token_pagseguro']); |
|
| 234 | + $pagamento->setToken($this->usuario['Usuario']['token_pagseguro']); |
|
| 235 | 235 | |
| 236 | - $pagamento->setEmail($this->usuario['Usuario']['email_pagseguro']); |
|
| 236 | + $pagamento->setEmail($this->usuario['Usuario']['email_pagseguro']); |
|
| 237 | 237 | |
| 238 | - $pagamento->setProdutos($products); |
|
| 238 | + $pagamento->setProdutos($products); |
|
| 239 | 239 | |
| 240 | - $pagamento->adicionarProdutosGateway(); |
|
| 240 | + $pagamento->adicionarProdutosGateway(); |
|
| 241 | 241 | |
| 242 | - $pagamento->setEndereco($andress); |
|
| 242 | + $pagamento->setEndereco($andress); |
|
| 243 | 243 | |
| 244 | - $pagamento->setReference('#' . $id); |
|
| 244 | + $pagamento->setReference('#' . $id); |
|
| 245 | 245 | |
| 246 | - $pagamento->setValorFrete($shipping); |
|
| 246 | + $pagamento->setValorFrete($shipping); |
|
| 247 | 247 | |
| 248 | - return $this->redirect($pagamento->finalizarPedido()); |
|
| 248 | + return $this->redirect($pagamento->finalizarPedido()); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | public function prepareProductsSale($products) { |
| 252 | - $retorno = array(); |
|
| 252 | + $retorno = array(); |
|
| 253 | 253 | |
| 254 | - foreach ($products as $i => $product) { |
|
| 255 | - $retorno[$i]['id_produto'] = $product['Produto']['id']; |
|
| 256 | - $retorno[$i]['quantidade'] = $product['Produto']['quantidade']; |
|
| 257 | - $retorno[$i]['variacao'] = $product['Produto']['variacao']; |
|
| 258 | - } |
|
| 254 | + foreach ($products as $i => $product) { |
|
| 255 | + $retorno[$i]['id_produto'] = $product['Produto']['id']; |
|
| 256 | + $retorno[$i]['quantidade'] = $product['Produto']['quantidade']; |
|
| 257 | + $retorno[$i]['variacao'] = $product['Produto']['variacao']; |
|
| 258 | + } |
|
| 259 | 259 | |
| 260 | - return $retorno; |
|
| 260 | + return $retorno; |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | public function searchAndressByCep($cep) { |
| 264 | - $this->layout = 'ajax'; |
|
| 264 | + $this->layout = 'ajax'; |
|
| 265 | 265 | |
| 266 | - $curl = curl_init('http://cep.correiocontrol.com.br/'.$cep.'.js'); |
|
| 266 | + $curl = curl_init('http://cep.correiocontrol.com.br/'.$cep.'.js'); |
|
| 267 | 267 | |
| 268 | - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
|
| 268 | + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
|
| 269 | 269 | |
| 270 | - $resultado = curl_exec($curl); |
|
| 270 | + $resultado = curl_exec($curl); |
|
| 271 | 271 | |
| 272 | - echo $resultado; |
|
| 272 | + echo $resultado; |
|
| 273 | 273 | |
| 274 | - exit(); |
|
| 274 | + exit(); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | public function calcTransportAjax() { |
| 278 | - $this->layout = 'ajax'; |
|
| 278 | + $this->layout = 'ajax'; |
|
| 279 | 279 | |
| 280 | - $cep_destino = $this->request->data('cep_destino'); |
|
| 281 | - $cep_origem = $this->request->data('cep_origem'); |
|
| 280 | + $cep_destino = $this->request->data('cep_destino'); |
|
| 281 | + $cep_origem = $this->request->data('cep_origem'); |
|
| 282 | 282 | |
| 283 | - $dataProducts = $this->loadProductsAndValuesCart(); |
|
| 283 | + $dataProducts = $this->loadProductsAndValuesCart(); |
|
| 284 | 284 | |
| 285 | - (float) $peso = 0; |
|
| 286 | - foreach ($dataProducts['products_cart'] as $i => $product) { |
|
| 287 | - $peso += $product['Produto']['peso_bruto'] * $product['Produto']['quantidade']; |
|
| 288 | - } |
|
| 285 | + (float) $peso = 0; |
|
| 286 | + foreach ($dataProducts['products_cart'] as $i => $product) { |
|
| 287 | + $peso += $product['Produto']['peso_bruto'] * $product['Produto']['quantidade']; |
|
| 288 | + } |
|
| 289 | 289 | |
| 290 | - $fretes = $this->transport($cep_destino, $this->usuario['Usuario']['cep_origem'], $peso); |
|
| 290 | + $fretes = $this->transport($cep_destino, $this->usuario['Usuario']['cep_origem'], $peso); |
|
| 291 | 291 | |
| 292 | - $disponiveis = array(); |
|
| 292 | + $disponiveis = array(); |
|
| 293 | 293 | |
| 294 | - $cont = 0; |
|
| 295 | - foreach ($fretes as $i => $frete) { |
|
| 296 | - $disponiveis[$cont]['valor'] = (array) $frete->Valor; |
|
| 297 | - $disponiveis[$cont]['prazo'] = (array) $frete->PrazoEntrega; |
|
| 298 | - $disponiveis[$cont]['codigo'] = (array) $frete->Codigo; |
|
| 299 | - $disponiveis[$cont]['valor'] = array_shift($disponiveis[$cont]['valor']); |
|
| 300 | - $disponiveis[$cont]['prazo'] = array_shift($disponiveis[$cont]['prazo']); |
|
| 301 | - $disponiveis[$cont]['codigo'] = array_shift($disponiveis[$cont]['codigo']); |
|
| 294 | + $cont = 0; |
|
| 295 | + foreach ($fretes as $i => $frete) { |
|
| 296 | + $disponiveis[$cont]['valor'] = (array) $frete->Valor; |
|
| 297 | + $disponiveis[$cont]['prazo'] = (array) $frete->PrazoEntrega; |
|
| 298 | + $disponiveis[$cont]['codigo'] = (array) $frete->Codigo; |
|
| 299 | + $disponiveis[$cont]['valor'] = array_shift($disponiveis[$cont]['valor']); |
|
| 300 | + $disponiveis[$cont]['prazo'] = array_shift($disponiveis[$cont]['prazo']); |
|
| 301 | + $disponiveis[$cont]['codigo'] = array_shift($disponiveis[$cont]['codigo']); |
|
| 302 | 302 | |
| 303 | - $cont++; |
|
| 304 | - } |
|
| 303 | + $cont++; |
|
| 304 | + } |
|
| 305 | 305 | |
| 306 | - $this->Session->write('Frete.valor', $disponiveis[$cont - 1]['valor']); |
|
| 306 | + $this->Session->write('Frete.valor', $disponiveis[$cont - 1]['valor']); |
|
| 307 | 307 | |
| 308 | - (float) $total = $disponiveis[$cont - 1]['valor'] + $dataProducts['total']; |
|
| 308 | + (float) $total = $disponiveis[$cont - 1]['valor'] + $dataProducts['total']; |
|
| 309 | 309 | |
| 310 | - $total = number_format($total, 2, ',', '.'); |
|
| 310 | + $total = number_format($total, 2, ',', '.'); |
|
| 311 | 311 | |
| 312 | - $retorno = array('frete' => $disponiveis[$cont - 1]['valor'], 'total' => $total); |
|
| 312 | + $retorno = array('frete' => $disponiveis[$cont - 1]['valor'], 'total' => $total); |
|
| 313 | 313 | |
| 314 | - echo json_encode($retorno); |
|
| 315 | - exit(); |
|
| 314 | + echo json_encode($retorno); |
|
| 315 | + exit(); |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | public function transport($cep_destino, $cep_origem, $peso) { |
| 319 | - $altura = '2'; |
|
| 320 | - $largura = '11'; |
|
| 321 | - $comprimento = '16'; |
|
| 322 | - |
|
| 323 | - $dados['sCepDestino'] = $cep_destino; |
|
| 324 | - $dados['sCepOrigem'] = $cep_origem; |
|
| 325 | - $dados['nVlPeso'] = $peso; |
|
| 326 | - $dados['nVlComprimento'] = $comprimento; |
|
| 327 | - $dados['nVlAltura'] = $altura; |
|
| 328 | - $dados['nVlLargura'] = $largura; |
|
| 329 | - $dados['nCdServico'] = '41106'; |
|
| 330 | - $dados['nVlDiametro'] = '2'; |
|
| 331 | - $dados['nCdFormato'] = '1'; |
|
| 332 | - $dados['sCdMaoPropria'] = 'n'; |
|
| 333 | - $dados['nVlValorDeclarado'] = '0'; |
|
| 334 | - $dados['StrRetorno'] = 'xml'; |
|
| 319 | + $altura = '2'; |
|
| 320 | + $largura = '11'; |
|
| 321 | + $comprimento = '16'; |
|
| 322 | + |
|
| 323 | + $dados['sCepDestino'] = $cep_destino; |
|
| 324 | + $dados['sCepOrigem'] = $cep_origem; |
|
| 325 | + $dados['nVlPeso'] = $peso; |
|
| 326 | + $dados['nVlComprimento'] = $comprimento; |
|
| 327 | + $dados['nVlAltura'] = $altura; |
|
| 328 | + $dados['nVlLargura'] = $largura; |
|
| 329 | + $dados['nCdServico'] = '41106'; |
|
| 330 | + $dados['nVlDiametro'] = '2'; |
|
| 331 | + $dados['nCdFormato'] = '1'; |
|
| 332 | + $dados['sCdMaoPropria'] = 'n'; |
|
| 333 | + $dados['nVlValorDeclarado'] = '0'; |
|
| 334 | + $dados['StrRetorno'] = 'xml'; |
|
| 335 | 335 | |
| 336 | - $dados = http_build_query($dados); |
|
| 336 | + $dados = http_build_query($dados); |
|
| 337 | 337 | |
| 338 | - $curl = curl_init('http://ws.correios.com.br/calculador/CalcPrecoPrazo.aspx' . '?' . $dados); |
|
| 338 | + $curl = curl_init('http://ws.correios.com.br/calculador/CalcPrecoPrazo.aspx' . '?' . $dados); |
|
| 339 | 339 | |
| 340 | - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
|
| 340 | + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
|
| 341 | 341 | |
| 342 | - $resultado = curl_exec($curl); |
|
| 343 | - $resultado = simplexml_load_string($resultado); |
|
| 342 | + $resultado = curl_exec($curl); |
|
| 343 | + $resultado = simplexml_load_string($resultado); |
|
| 344 | 344 | |
| 345 | - return $resultado; |
|
| 345 | + return $resultado; |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | public function saveEmailNewsletter() { |
| 349 | - $nome = $this->request->data('nome'); |
|
| 350 | - $email = $this->request->data('email'); |
|
| 349 | + $nome = $this->request->data('nome'); |
|
| 350 | + $email = $this->request->data('email'); |
|
| 351 | 351 | |
| 352 | - $objNewsletter = new NewsletterController(); |
|
| 352 | + $objNewsletter = new NewsletterController(); |
|
| 353 | 353 | |
| 354 | - if ($objNewsletter->newsletter_cadastro($nome, $email, $this->Session->read('Usuario.id'))) |
|
| 355 | - { |
|
| 356 | - echo json_encode(true); |
|
| 357 | - exit(); |
|
| 358 | - } |
|
| 354 | + if ($objNewsletter->newsletter_cadastro($nome, $email, $this->Session->read('Usuario.id'))) |
|
| 355 | + { |
|
| 356 | + echo json_encode(true); |
|
| 357 | + exit(); |
|
| 358 | + } |
|
| 359 | 359 | |
| 360 | - echo json_encode(false); |
|
| 361 | - exit(); |
|
| 360 | + echo json_encode(false); |
|
| 361 | + exit(); |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | public function useCoupon() { |
| 365 | - $this->layout = 'ajax'; |
|
| 365 | + $this->layout = 'ajax'; |
|
| 366 | 366 | |
| 367 | - $cupom = $this->request->data('cupom'); |
|
| 368 | - $valor = $this->request->data('valor'); |
|
| 367 | + $cupom = $this->request->data('cupom'); |
|
| 368 | + $valor = $this->request->data('valor'); |
|
| 369 | 369 | |
| 370 | - $objCupom = new CupomController(); |
|
| 371 | - $novo_valor = $objCupom->utilizar_cupom($cupom, $valor, $this->Session->read('Usuario.id')); |
|
| 370 | + $objCupom = new CupomController(); |
|
| 371 | + $novo_valor = $objCupom->utilizar_cupom($cupom, $valor, $this->Session->read('Usuario.id')); |
|
| 372 | 372 | |
| 373 | - if (!$novo_valor) |
|
| 374 | - { |
|
| 375 | - echo json_encode(false); |
|
| 376 | - exit(); |
|
| 377 | - } |
|
| 373 | + if (!$novo_valor) |
|
| 374 | + { |
|
| 375 | + echo json_encode(false); |
|
| 376 | + exit(); |
|
| 377 | + } |
|
| 378 | 378 | |
| 379 | - echo json_encode($novo_valor); |
|
| 380 | - exit(); |
|
| 379 | + echo json_encode($novo_valor); |
|
| 380 | + exit(); |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | public function validateProduct($data) { |
| 384 | - $this->loadModel('Variacao'); |
|
| 384 | + $this->loadModel('Variacao'); |
|
| 385 | 385 | |
| 386 | - $params = array('conditions' => |
|
| 387 | - array( |
|
| 388 | - 'Variacao.id' => $data['variacao'] |
|
| 389 | - ) |
|
| 390 | - ); |
|
| 386 | + $params = array('conditions' => |
|
| 387 | + array( |
|
| 388 | + 'Variacao.id' => $data['variacao'] |
|
| 389 | + ) |
|
| 390 | + ); |
|
| 391 | 391 | |
| 392 | - $variacao = $this->Variacao->find('all', $params); |
|
| 392 | + $variacao = $this->Variacao->find('all', $params); |
|
| 393 | 393 | |
| 394 | - if ($variacao[0]['Variacao']['estoque'] <= 0 || $data['quantidade'] > $variacao[0]['Variacao']['estoque']) |
|
| 395 | - { |
|
| 396 | - return false; |
|
| 397 | - } |
|
| 394 | + if ($variacao[0]['Variacao']['estoque'] <= 0 || $data['quantidade'] > $variacao[0]['Variacao']['estoque']) |
|
| 395 | + { |
|
| 396 | + return false; |
|
| 397 | + } |
|
| 398 | 398 | |
| 399 | - return true; |
|
| 399 | + return true; |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | public function saveClientFromEcommerce($data) { |
| 403 | - $this->loadModel('Cliente'); |
|
| 403 | + $this->loadModel('Cliente'); |
|
| 404 | 404 | |
| 405 | - $data['senha'] = sha1($data['senha']); |
|
| 405 | + $data['senha'] = sha1($data['senha']); |
|
| 406 | 406 | |
| 407 | - $this->Cliente->set($data); |
|
| 407 | + $this->Cliente->set($data); |
|
| 408 | 408 | |
| 409 | - if (!$this->Cliente->validates()) |
|
| 410 | - { |
|
| 411 | - return false; |
|
| 412 | - } |
|
| 409 | + if (!$this->Cliente->validates()) |
|
| 410 | + { |
|
| 411 | + return false; |
|
| 412 | + } |
|
| 413 | 413 | |
| 414 | - if (!$this->Cliente->save()) |
|
| 415 | - { |
|
| 416 | - return false; |
|
| 417 | - } |
|
| 414 | + if (!$this->Cliente->save()) |
|
| 415 | + { |
|
| 416 | + return false; |
|
| 417 | + } |
|
| 418 | 418 | |
| 419 | - return $this->Cliente->getLastInsertId(); |
|
| 419 | + return $this->Cliente->getLastInsertId(); |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | public function saveAndressClientFromEcommerce($data) { |
| 423 | - $this->loadModel('EnderecoClienteCadastro'); |
|
| 423 | + $this->loadModel('EnderecoClienteCadastro'); |
|
| 424 | 424 | |
| 425 | - $this->EnderecoClienteCadastro->set($data); |
|
| 425 | + $this->EnderecoClienteCadastro->set($data); |
|
| 426 | 426 | |
| 427 | - if (!$this->EnderecoClienteCadastro->validates()) |
|
| 428 | - { |
|
| 429 | - return false; |
|
| 430 | - } |
|
| 427 | + if (!$this->EnderecoClienteCadastro->validates()) |
|
| 428 | + { |
|
| 429 | + return false; |
|
| 430 | + } |
|
| 431 | 431 | |
| 432 | - return $this->EnderecoClienteCadastro->save(); |
|
| 432 | + return $this->EnderecoClienteCadastro->save(); |
|
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | /** |
| 436 | - * Views |
|
| 437 | - */ |
|
| 436 | + * Views |
|
| 437 | + */ |
|
| 438 | 438 | public function index() { |
| 439 | - $this->set('usuario', $this->usuario); |
|
| 440 | - $this->set('banners', $this->loadBanners()); |
|
| 441 | - $this->set('categorias', $this->loadCategoriesProducts()); |
|
| 442 | - $this->set('produtos', $this->loadProducts()); |
|
| 439 | + $this->set('usuario', $this->usuario); |
|
| 440 | + $this->set('banners', $this->loadBanners()); |
|
| 441 | + $this->set('categorias', $this->loadCategoriesProducts()); |
|
| 442 | + $this->set('produtos', $this->loadProducts()); |
|
| 443 | 443 | |
| 444 | - $this->render('/' . $this->usuario['Usuario']['folder_view'] . '/index'); |
|
| 444 | + $this->render('/' . $this->usuario['Usuario']['folder_view'] . '/index'); |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | public function cart() { |
| 448 | - $this->set('usuario', $this->usuario); |
|
| 449 | - $this->set('categorias', $this->loadCategoriesProducts()); |
|
| 450 | - $products = $this->loadProductsAndValuesCart(); |
|
| 448 | + $this->set('usuario', $this->usuario); |
|
| 449 | + $this->set('categorias', $this->loadCategoriesProducts()); |
|
| 450 | + $products = $this->loadProductsAndValuesCart(); |
|
| 451 | 451 | |
| 452 | - $this->set('products', $products['products_cart']); |
|
| 453 | - $this->set('total', $products['total']); |
|
| 452 | + $this->set('products', $products['products_cart']); |
|
| 453 | + $this->set('total', $products['total']); |
|
| 454 | 454 | |
| 455 | - $this->render('/' . $this->usuario['Usuario']['folder_view'] . '/cart'); |
|
| 455 | + $this->render('/' . $this->usuario['Usuario']['folder_view'] . '/cart'); |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | public function checkout() { |
| 459 | - $this->set('usuario', $this->usuario); |
|
| 460 | - $this->set('categorias', $this->loadCategoriesProducts()); |
|
| 461 | - $products = $this->loadProductsAndValuesCart(); |
|
| 459 | + $this->set('usuario', $this->usuario); |
|
| 460 | + $this->set('categorias', $this->loadCategoriesProducts()); |
|
| 461 | + $products = $this->loadProductsAndValuesCart(); |
|
| 462 | 462 | |
| 463 | - $this->set('products', $products['products_cart']); |
|
| 464 | - $this->set('total', $products['total']); |
|
| 463 | + $this->set('products', $products['products_cart']); |
|
| 464 | + $this->set('total', $products['total']); |
|
| 465 | 465 | |
| 466 | - $this->render('/' . $this->usuario['Usuario']['folder_view'] . '/checkout'); |
|
| 466 | + $this->render('/' . $this->usuario['Usuario']['folder_view'] . '/checkout'); |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | public function category() { |
| 470 | - $this->set('usuario', $this->usuario); |
|
| 471 | - $id = $this->params['id']; |
|
| 472 | - $nome = $this->params['nome']; |
|
| 470 | + $this->set('usuario', $this->usuario); |
|
| 471 | + $id = $this->params['id']; |
|
| 472 | + $nome = $this->params['nome']; |
|
| 473 | 473 | |
| 474 | - $products = $this->loadProducts($id); |
|
| 474 | + $products = $this->loadProducts($id); |
|
| 475 | 475 | |
| 476 | - $this->set('categorias', $this->loadCategoriesProducts()); |
|
| 477 | - $this->set('produtos', $products); |
|
| 478 | - $this->set('nameCategory', $nome); |
|
| 476 | + $this->set('categorias', $this->loadCategoriesProducts()); |
|
| 477 | + $this->set('produtos', $products); |
|
| 478 | + $this->set('nameCategory', $nome); |
|
| 479 | 479 | |
| 480 | - $this->render('/' . $this->usuario['Usuario']['folder_view'] . '/category'); |
|
| 480 | + $this->render('/' . $this->usuario['Usuario']['folder_view'] . '/category'); |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | public function product() { |
| 484 | - $this->set('usuario', $this->usuario); |
|
| 485 | - $this->loadModel('Produto'); |
|
| 484 | + $this->set('usuario', $this->usuario); |
|
| 485 | + $this->loadModel('Produto'); |
|
| 486 | 486 | |
| 487 | - $id = $this->params['id']; |
|
| 487 | + $id = $this->params['id']; |
|
| 488 | 488 | |
| 489 | - $this->set('categorias', $this->loadCategoriesProducts()); |
|
| 489 | + $this->set('categorias', $this->loadCategoriesProducts()); |
|
| 490 | 490 | |
| 491 | - $produto = $this->loadProducts(null, $id)[0]; |
|
| 492 | - |
|
| 493 | - $this->loadModel('Variacao'); |
|
| 494 | - |
|
| 495 | - $query = array ( |
|
| 496 | - 'joins' => array( |
|
| 497 | - array( |
|
| 498 | - 'table' => 'produtos', |
|
| 499 | - 'alias' => 'Produto', |
|
| 500 | - 'type' => 'LEFT', |
|
| 501 | - 'conditions' => array( |
|
| 502 | - 'Variacao.produto_id = Produto.id', |
|
| 503 | - ), |
|
| 504 | - ) |
|
| 505 | - ), |
|
| 506 | - 'conditions' => array('Variacao.produto_id' => $id, 'Variacao.ativo' => 1), |
|
| 507 | - 'fields' => array('Produto.id, Variacao.*'), |
|
| 508 | - ); |
|
| 509 | - |
|
| 510 | - $variacoes = $this->Variacao->find('all', $query); |
|
| 511 | - $this->set('variacoes', $variacoes); |
|
| 512 | - |
|
| 513 | - $this->set('produto', $produto); |
|
| 514 | - |
|
| 515 | - $this->render('/' . $this->usuario['Usuario']['folder_view'] . '/product'); |
|
| 491 | + $produto = $this->loadProducts(null, $id)[0]; |
|
| 492 | + |
|
| 493 | + $this->loadModel('Variacao'); |
|
| 494 | + |
|
| 495 | + $query = array ( |
|
| 496 | + 'joins' => array( |
|
| 497 | + array( |
|
| 498 | + 'table' => 'produtos', |
|
| 499 | + 'alias' => 'Produto', |
|
| 500 | + 'type' => 'LEFT', |
|
| 501 | + 'conditions' => array( |
|
| 502 | + 'Variacao.produto_id = Produto.id', |
|
| 503 | + ), |
|
| 504 | + ) |
|
| 505 | + ), |
|
| 506 | + 'conditions' => array('Variacao.produto_id' => $id, 'Variacao.ativo' => 1), |
|
| 507 | + 'fields' => array('Produto.id, Variacao.*'), |
|
| 508 | + ); |
|
| 509 | + |
|
| 510 | + $variacoes = $this->Variacao->find('all', $query); |
|
| 511 | + $this->set('variacoes', $variacoes); |
|
| 512 | + |
|
| 513 | + $this->set('produto', $produto); |
|
| 514 | + |
|
| 515 | + $this->render('/' . $this->usuario['Usuario']['folder_view'] . '/product'); |
|
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | public function retornopagseguro() { |
| 519 | - $code = $_GET['code']; |
|
| 519 | + $code = $_GET['code']; |
|
| 520 | 520 | |
| 521 | - pr($code,1); |
|
| 521 | + pr($code,1); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | } |
| 525 | 525 | \ No newline at end of file |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | require 'NewsletterController.php'; |
| 8 | 8 | require 'VendaController.php'; |
| 9 | 9 | |
| 10 | -require_once(ROOT . DS . 'vendor' . DS . 'autoload.php'); |
|
| 10 | +require_once(ROOT.DS.'vendor'.DS.'autoload.php'); |
|
| 11 | 11 | |
| 12 | 12 | use FastShipping\Lib\Tracking; |
| 13 | 13 | use FastShipping\Lib\Shipping; |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | protected $usuario; |
| 19 | 19 | |
| 20 | - public function beforeFilter(){ |
|
| 20 | + public function beforeFilter() { |
|
| 21 | 21 | $lojaSession = $this->Session->read('Usuario.loja'); |
| 22 | 22 | |
| 23 | 23 | if (isset($lojaSession)) |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | $loja = $this->params['loja']; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - if (!isset($loja)) |
|
| 46 | + if ( ! isset($loja)) |
|
| 47 | 47 | { |
| 48 | 48 | echo 'Loja não existe'; |
| 49 | 49 | exit; |
@@ -65,8 +65,8 @@ discard block |
||
| 65 | 65 | exit; |
| 66 | 66 | } |
| 67 | 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 |
|
| 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 | 70 | |
| 71 | 71 | $this->layout = $this->usuario['Usuario']['layout_loja']; |
| 72 | 72 | } |
@@ -127,29 +127,29 @@ discard block |
||
| 127 | 127 | $produto = $this->request->data('produto'); |
| 128 | 128 | |
| 129 | 129 | if (empty($produto)) { |
| 130 | - $this->redirect('/' . $this->usuario['Usuario']['loja'] . '/'); |
|
| 130 | + $this->redirect('/'.$this->usuario['Usuario']['loja'].'/'); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - if (!$this->validateProduct($produto)) { |
|
| 133 | + if ( ! $this->validateProduct($produto)) { |
|
| 134 | 134 | $this->Session->setFlash('Quantidade de produtos escolhidas é maior do que a disponivel!'); |
| 135 | - $this->redirect('/' . $this->usuario['Usuario']['loja'] . '/'); |
|
| 135 | + $this->redirect('/'.$this->usuario['Usuario']['loja'].'/'); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | $cont = count($this->Session->read('Produto')); |
| 139 | 139 | |
| 140 | - $this->Session->write('Produto.'.$produto['id'].'.id' , $produto['id']); |
|
| 141 | - $this->Session->write('Produto.'.$produto['id'].'.quantidade' , $produto['quantidade']); |
|
| 140 | + $this->Session->write('Produto.'.$produto['id'].'.id', $produto['id']); |
|
| 141 | + $this->Session->write('Produto.'.$produto['id'].'.quantidade', $produto['quantidade']); |
|
| 142 | 142 | $this->Session->write('Produto.'.$produto['id'].'.variacao', $produto['variacao']); |
| 143 | 143 | |
| 144 | - $this->redirect('/' . $this->usuario['Usuario']['loja'] . '/cart'); |
|
| 144 | + $this->redirect('/'.$this->usuario['Usuario']['loja'].'/cart'); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | public function removeProductCart() { |
| 148 | - if ( ($this->Session->read('Produto.' . $this->params['id'])) !== null ) { |
|
| 149 | - $this->Session->delete( 'Produto.' . $this->params['id'] ); |
|
| 148 | + if (($this->Session->read('Produto.'.$this->params['id'])) !== null) { |
|
| 149 | + $this->Session->delete('Produto.'.$this->params['id']); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - $this->redirect('/' . $this->usuario['Usuario']['loja'] . '/cart'); |
|
| 152 | + $this->redirect('/'.$this->usuario['Usuario']['loja'].'/cart'); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | public function clearCart() { |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | (float) $total = 0.00; |
| 166 | 166 | $produtos = array(); |
| 167 | 167 | foreach ($productsSession as $indice => $item) { |
| 168 | - $produto = $this->Produto->find('all', |
|
| 168 | + $produto = $this->Produto->find('all', |
|
| 169 | 169 | array('conditions' => |
| 170 | 170 | array('Produto.ativo' => 1, |
| 171 | 171 | 'Produto.id' => $item['id'] |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | ) |
| 174 | 174 | ); |
| 175 | 175 | |
| 176 | - $total += $produto[0]['Produto']['preco'] * $item['quantidade']; |
|
| 176 | + $total += $produto[0]['Produto']['preco'] * $item['quantidade']; |
|
| 177 | 177 | |
| 178 | 178 | $produto[0]['Produto']['quantidade'] = $item['quantidade']; |
| 179 | 179 | |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | |
| 242 | 242 | $pagamento->setEndereco($andress); |
| 243 | 243 | |
| 244 | - $pagamento->setReference('#' . $id); |
|
| 244 | + $pagamento->setReference('#'.$id); |
|
| 245 | 245 | |
| 246 | 246 | $pagamento->setValorFrete($shipping); |
| 247 | 247 | |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | |
| 336 | 336 | $dados = http_build_query($dados); |
| 337 | 337 | |
| 338 | - $curl = curl_init('http://ws.correios.com.br/calculador/CalcPrecoPrazo.aspx' . '?' . $dados); |
|
| 338 | + $curl = curl_init('http://ws.correios.com.br/calculador/CalcPrecoPrazo.aspx'.'?'.$dados); |
|
| 339 | 339 | |
| 340 | 340 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
| 341 | 341 | |
@@ -365,12 +365,12 @@ discard block |
||
| 365 | 365 | $this->layout = 'ajax'; |
| 366 | 366 | |
| 367 | 367 | $cupom = $this->request->data('cupom'); |
| 368 | - $valor = $this->request->data('valor'); |
|
| 368 | + $valor = $this->request->data('valor'); |
|
| 369 | 369 | |
| 370 | 370 | $objCupom = new CupomController(); |
| 371 | 371 | $novo_valor = $objCupom->utilizar_cupom($cupom, $valor, $this->Session->read('Usuario.id')); |
| 372 | 372 | |
| 373 | - if (!$novo_valor) |
|
| 373 | + if ( ! $novo_valor) |
|
| 374 | 374 | { |
| 375 | 375 | echo json_encode(false); |
| 376 | 376 | exit(); |
@@ -406,12 +406,12 @@ discard block |
||
| 406 | 406 | |
| 407 | 407 | $this->Cliente->set($data); |
| 408 | 408 | |
| 409 | - if (!$this->Cliente->validates()) |
|
| 409 | + if ( ! $this->Cliente->validates()) |
|
| 410 | 410 | { |
| 411 | 411 | return false; |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | - if (!$this->Cliente->save()) |
|
| 414 | + if ( ! $this->Cliente->save()) |
|
| 415 | 415 | { |
| 416 | 416 | return false; |
| 417 | 417 | } |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | |
| 425 | 425 | $this->EnderecoClienteCadastro->set($data); |
| 426 | 426 | |
| 427 | - if (!$this->EnderecoClienteCadastro->validates()) |
|
| 427 | + if ( ! $this->EnderecoClienteCadastro->validates()) |
|
| 428 | 428 | { |
| 429 | 429 | return false; |
| 430 | 430 | } |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | $this->set('categorias', $this->loadCategoriesProducts()); |
| 442 | 442 | $this->set('produtos', $this->loadProducts()); |
| 443 | 443 | |
| 444 | - $this->render('/' . $this->usuario['Usuario']['folder_view'] . '/index'); |
|
| 444 | + $this->render('/'.$this->usuario['Usuario']['folder_view'].'/index'); |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | public function cart() { |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | $this->set('products', $products['products_cart']); |
| 453 | 453 | $this->set('total', $products['total']); |
| 454 | 454 | |
| 455 | - $this->render('/' . $this->usuario['Usuario']['folder_view'] . '/cart'); |
|
| 455 | + $this->render('/'.$this->usuario['Usuario']['folder_view'].'/cart'); |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | public function checkout() { |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | $this->set('products', $products['products_cart']); |
| 464 | 464 | $this->set('total', $products['total']); |
| 465 | 465 | |
| 466 | - $this->render('/' . $this->usuario['Usuario']['folder_view'] . '/checkout'); |
|
| 466 | + $this->render('/'.$this->usuario['Usuario']['folder_view'].'/checkout'); |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | public function category() { |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | $this->set('produtos', $products); |
| 478 | 478 | $this->set('nameCategory', $nome); |
| 479 | 479 | |
| 480 | - $this->render('/' . $this->usuario['Usuario']['folder_view'] . '/category'); |
|
| 480 | + $this->render('/'.$this->usuario['Usuario']['folder_view'].'/category'); |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | public function product() { |
@@ -492,7 +492,7 @@ discard block |
||
| 492 | 492 | |
| 493 | 493 | $this->loadModel('Variacao'); |
| 494 | 494 | |
| 495 | - $query = array ( |
|
| 495 | + $query = array( |
|
| 496 | 496 | 'joins' => array( |
| 497 | 497 | array( |
| 498 | 498 | 'table' => 'produtos', |
@@ -512,13 +512,13 @@ discard block |
||
| 512 | 512 | |
| 513 | 513 | $this->set('produto', $produto); |
| 514 | 514 | |
| 515 | - $this->render('/' . $this->usuario['Usuario']['folder_view'] . '/product'); |
|
| 515 | + $this->render('/'.$this->usuario['Usuario']['folder_view'].'/product'); |
|
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | public function retornopagseguro() { |
| 519 | 519 | $code = $_GET['code']; |
| 520 | 520 | |
| 521 | - pr($code,1); |
|
| 521 | + pr($code, 1); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | } |
| 525 | 525 | \ No newline at end of file |
@@ -27,18 +27,15 @@ discard block |
||
| 27 | 27 | if ($this->params['loja'] != $lojaSession) |
| 28 | 28 | { |
| 29 | 29 | $loja = $this->params['loja']; |
| 30 | - } |
|
| 31 | - else |
|
| 30 | + } else |
|
| 32 | 31 | { |
| 33 | 32 | $loja = $lojaSession; |
| 34 | 33 | } |
| 35 | - } |
|
| 36 | - else |
|
| 34 | + } else |
|
| 37 | 35 | { |
| 38 | 36 | $loja = $lojaSession; |
| 39 | 37 | } |
| 40 | - } |
|
| 41 | - else |
|
| 38 | + } else |
|
| 42 | 39 | { |
| 43 | 40 | $loja = $this->params['loja']; |
| 44 | 41 | } |
@@ -47,8 +44,7 @@ discard block |
||
| 47 | 44 | { |
| 48 | 45 | echo 'Loja não existe'; |
| 49 | 46 | exit; |
| 50 | - } |
|
| 51 | - else |
|
| 47 | + } else |
|
| 52 | 48 | { |
| 53 | 49 | $this->loadModel('Usuario'); |
| 54 | 50 | |
@@ -197,6 +197,9 @@ discard block |
||
| 197 | 197 | /** |
| 198 | 198 | * Armazena os valores RGB para redimensionamento com fill |
| 199 | 199 | * @param Valores R, G e B |
| 200 | + * @param integer $r |
|
| 201 | + * @param integer $g |
|
| 202 | + * @param integer $b |
|
| 200 | 203 | * @return Void |
| 201 | 204 | */ |
| 202 | 205 | public function rgb( $r, $g, $b ) |
@@ -537,7 +540,7 @@ discard block |
||
| 537 | 540 | * @param String $posicao posição/orientação fixa da marca d'água |
| 538 | 541 | * [topo, meio, baixo] + [esquerda, centro, direita] |
| 539 | 542 | * @param Int $alfa valor para transparência (0-100) |
| 540 | - * @return void |
|
| 543 | + * @return false|null |
|
| 541 | 544 | */ |
| 542 | 545 | public function marcaFixa( $imagem, $posicao, $alfa = 100 ) |
| 543 | 546 | { |
@@ -602,7 +605,7 @@ discard block |
||
| 602 | 605 | * retorna saída para tela ou arquivo |
| 603 | 606 | * @param String $destino caminho e nome do arquivo a serem criados |
| 604 | 607 | * @param Int $qualidade qualidade da imagem no caso de JPEG (0-100) |
| 605 | - * @return void |
|
| 608 | + * @return false|null |
|
| 606 | 609 | */ |
| 607 | 610 | public function grava( $destino='', $qualidade = 100 ) |
| 608 | 611 | { |
@@ -701,6 +704,9 @@ discard block |
||
| 701 | 704 | /* Version: 2.0B */ |
| 702 | 705 | /*********************************************/ |
| 703 | 706 | |
| 707 | +/** |
|
| 708 | + * @param string $filename |
|
| 709 | + */ |
|
| 704 | 710 | function imagecreatefrombmp($filename) { |
| 705 | 711 | //Ouverture du fichier en mode binaire |
| 706 | 712 | if (! $f1 = fopen($filename,"rb")) return FALSE; |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * Construtor |
| 31 | 31 | * @param $string caminho da imagem a ser carregada |
| 32 | 32 | * @return void |
| 33 | - */ |
|
| 33 | + */ |
|
| 34 | 34 | public function m2brimagem( $origem = '', $extensoes_validas = array( 'jpg', 'jpeg', 'jpe', 'gif', 'bmp', 'png' ) ) |
| 35 | 35 | { |
| 36 | 36 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * Retorna dados da imagem |
| 51 | 51 | * @param |
| 52 | 52 | * @return void |
| 53 | - */ |
|
| 53 | + */ |
|
| 54 | 54 | private function dados() |
| 55 | 55 | { |
| 56 | 56 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * Retorna validação da imagem |
| 89 | 89 | * @param |
| 90 | 90 | * @return String string com erro de mensagem ou 'OK' para imagem válida |
| 91 | - */ |
|
| 91 | + */ |
|
| 92 | 92 | public function valida() |
| 93 | 93 | { |
| 94 | 94 | return $this->erro; |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * Carrega uma nova imagem, fora do construtor |
| 99 | 99 | * @param String caminho da imagem a ser carregada |
| 100 | 100 | * @return void |
| 101 | - */ |
|
| 101 | + */ |
|
| 102 | 102 | public function carrega( $origem = '' ) |
| 103 | 103 | { |
| 104 | 104 | $this->origem = $origem; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * Busca dimensões e formato real da imagem |
| 113 | 113 | * @param |
| 114 | 114 | * @return void |
| 115 | - */ |
|
| 115 | + */ |
|
| 116 | 116 | private function dimensoes() |
| 117 | 117 | { |
| 118 | 118 | $dimensoes = getimagesize( $this->origem ); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * Busca dados do arquivo |
| 129 | 129 | * @param |
| 130 | 130 | * @return void |
| 131 | - */ |
|
| 131 | + */ |
|
| 132 | 132 | private function dadosArquivo() |
| 133 | 133 | { |
| 134 | 134 | // imagem de origem |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * Verifica se o arquivo indicado é uma imagem |
| 144 | 144 | * @param |
| 145 | 145 | * @return Boolean true/false |
| 146 | - */ |
|
| 146 | + */ |
|
| 147 | 147 | private function eImagem() |
| 148 | 148 | { |
| 149 | 149 | // filtra extensão |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | * Cria objeto de imagem para manipulação no GD |
| 165 | 165 | * @param |
| 166 | 166 | * @return void |
| 167 | - */ |
|
| 167 | + */ |
|
| 168 | 168 | private function criaImagem() |
| 169 | 169 | { |
| 170 | 170 | switch ( $this->formato ) |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | * Armazena os valores RGB para redimensionamento com fill |
| 199 | 199 | * @param Valores R, G e B |
| 200 | 200 | * @return Void |
| 201 | - */ |
|
| 201 | + */ |
|
| 202 | 202 | public function rgb( $r, $g, $b ) |
| 203 | 203 | { |
| 204 | 204 | $this->rgb = array( $r, $g, $b ); |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | * Armazena posições x e y para crop |
| 209 | 209 | * @param Array valores x e y |
| 210 | 210 | * @return Void |
| 211 | - */ |
|
| 211 | + */ |
|
| 212 | 212 | public function posicaoCrop( $x, $y ) |
| 213 | 213 | { |
| 214 | 214 | $this->posicao_crop = array( $x, $y, $this->largura, $this->altura ); |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | * @param Int $nova_altura valor em pixels da nova altura da imagem |
| 221 | 221 | * @param String $tipo método para redimensionamento (padrão [vazio], 'fill' [preenchimento] ou 'crop') |
| 222 | 222 | * @return Boolean/void |
| 223 | - */ |
|
| 223 | + */ |
|
| 224 | 224 | public function redimensiona( $nova_largura = 0, $nova_altura = 0, $tipo = '' ) |
| 225 | 225 | { |
| 226 | 226 | |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | * Redimensiona imagem, modo padrão, sem crop ou fill (distorcendo) |
| 285 | 285 | * @param |
| 286 | 286 | * @return void |
| 287 | - */ |
|
| 287 | + */ |
|
| 288 | 288 | private function resize() |
| 289 | 289 | { |
| 290 | 290 | // cria imagem de destino temporária |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | * Adiciona cor de fundo à imagem |
| 299 | 299 | * @param |
| 300 | 300 | * @return void |
| 301 | - */ |
|
| 301 | + */ |
|
| 302 | 302 | private function preencheImagem() |
| 303 | 303 | { |
| 304 | 304 | $corfundo = imagecolorallocate( $this->img_temp, $this->rgb[0], $this->rgb[1], $this->rgb[2] ); |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | * preenchendo espaço vazio com cor rgb especificada |
| 311 | 311 | * @param |
| 312 | 312 | * @return void |
| 313 | - */ |
|
| 313 | + */ |
|
| 314 | 314 | private function resizeFill() |
| 315 | 315 | { |
| 316 | 316 | // cria imagem de destino temporária |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | * Os índices 2 e 3 correspondem ao tamanho do crop |
| 347 | 347 | * @param |
| 348 | 348 | * @return void |
| 349 | - */ |
|
| 349 | + */ |
|
| 350 | 350 | private function calculaPosicaoCrop() |
| 351 | 351 | { |
| 352 | 352 | // média altura/largura |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | * http://www.findmotive.com/2006/12/13/php-crop-image/ |
| 385 | 385 | * atualizado para receber o posicionamento X e Y do crop na imagem |
| 386 | 386 | * @return void |
| 387 | - */ |
|
| 387 | + */ |
|
| 388 | 388 | private function resizeCrop() |
| 389 | 389 | { |
| 390 | 390 | // calcula posicionamento do crop |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | * http://www.php.net/manual/en/ref.image.php#62029 |
| 411 | 411 | * @param String $tipo tipo de espelhamento: h - horizontal, v - vertical |
| 412 | 412 | * @return void |
| 413 | - */ |
|
| 413 | + */ |
|
| 414 | 414 | public function flip( $tipo = 'h' ) |
| 415 | 415 | { |
| 416 | 416 | $w = imagesx( $this->img ); |
@@ -445,7 +445,7 @@ discard block |
||
| 445 | 445 | * @param Int $graus grau para giro |
| 446 | 446 | * @param Array $rgb cor RGB para preenchimento |
| 447 | 447 | * @return void |
| 448 | - */ |
|
| 448 | + */ |
|
| 449 | 449 | public function girar( $graus, $rgb = array( 255,255,255 ) ) |
| 450 | 450 | { |
| 451 | 451 | $corfundo = imagecolorallocate( $this->img, $rgb[0], $rgb[1], $rgb[2] ); |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | * @param Boolean $truetype true para utilizar fonte truetype, false para fonte do sistema |
| 463 | 463 | * @param String $fonte nome da fonte truetype a ser utilizada |
| 464 | 464 | * @return void |
| 465 | - */ |
|
| 465 | + */ |
|
| 466 | 466 | public function legenda( $texto, $tamanho = 10, $x = 0, $y = 0, $rgb = array( 255,255,255 ), $truetype = false, $fonte = '' ) |
| 467 | 467 | { |
| 468 | 468 | $cortexto = imagecolorallocate( $this->img, $rgb[0], $rgb[1], $rgb[2] ); |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | * [topo, meio, baixo] + [esquerda, centro, direita] |
| 539 | 539 | * @param Int $alfa valor para transparência (0-100) |
| 540 | 540 | * @return void |
| 541 | - */ |
|
| 541 | + */ |
|
| 542 | 542 | public function marcaFixa( $imagem, $posicao, $alfa = 100 ) |
| 543 | 543 | { |
| 544 | 544 | |
@@ -603,7 +603,7 @@ discard block |
||
| 603 | 603 | * @param String $destino caminho e nome do arquivo a serem criados |
| 604 | 604 | * @param Int $qualidade qualidade da imagem no caso de JPEG (0-100) |
| 605 | 605 | * @return void |
| 606 | - */ |
|
| 606 | + */ |
|
| 607 | 607 | public function grava( $destino='', $qualidade = 100 ) |
| 608 | 608 | { |
| 609 | 609 | // dados do arquivo de destino |
@@ -31,18 +31,18 @@ discard block |
||
| 31 | 31 | * @param $string caminho da imagem a ser carregada |
| 32 | 32 | * @return void |
| 33 | 33 | */ |
| 34 | - public function m2brimagem( $origem = '', $extensoes_validas = array( 'jpg', 'jpeg', 'jpe', 'gif', 'bmp', 'png' ) ) |
|
| 34 | + public function m2brimagem($origem = '', $extensoes_validas = array('jpg', 'jpeg', 'jpe', 'gif', 'bmp', 'png')) |
|
| 35 | 35 | { |
| 36 | 36 | |
| 37 | - $this->origem = $origem; |
|
| 38 | - $this->extensoes_validas = $extensoes_validas; |
|
| 37 | + $this->origem = $origem; |
|
| 38 | + $this->extensoes_validas = $extensoes_validas; |
|
| 39 | 39 | |
| 40 | - if ( $this->origem ) |
|
| 40 | + if ($this->origem) |
|
| 41 | 41 | { |
| 42 | 42 | $this->dados(); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - $this->rgb( 0, 0, 0 ); |
|
| 45 | + $this->rgb(0, 0, 0); |
|
| 46 | 46 | |
| 47 | 47 | } // fim construtor |
| 48 | 48 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | $this->erro = 'OK'; |
| 59 | 59 | |
| 60 | 60 | // verifica se imagem existe |
| 61 | - if ( !is_file( $this->origem ) ) |
|
| 61 | + if ( ! is_file($this->origem)) |
|
| 62 | 62 | { |
| 63 | 63 | $this->erro = 'Erro: Arquivo de imagem não encontrado!'; |
| 64 | 64 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $this->dadosArquivo(); |
| 69 | 69 | |
| 70 | 70 | // verifica se é imagem |
| 71 | - if (!$this->eImagem()) |
|
| 71 | + if ( ! $this->eImagem()) |
|
| 72 | 72 | { |
| 73 | 73 | $this->erro = 'Erro: Arquivo '.$this->origem.' não é uma imagem!'; |
| 74 | 74 | } |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | * @param String caminho da imagem a ser carregada |
| 100 | 100 | * @return void |
| 101 | 101 | */ |
| 102 | - public function carrega( $origem = '' ) |
|
| 102 | + public function carrega($origem = '') |
|
| 103 | 103 | { |
| 104 | - $this->origem = $origem; |
|
| 104 | + $this->origem = $origem; |
|
| 105 | 105 | $this->dados(); |
| 106 | 106 | } // fim carrega |
| 107 | 107 | |
@@ -115,13 +115,13 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | private function dimensoes() |
| 117 | 117 | { |
| 118 | - $dimensoes = getimagesize( $this->origem ); |
|
| 119 | - $this->largura = $dimensoes[0]; |
|
| 118 | + $dimensoes = getimagesize($this->origem); |
|
| 119 | + $this->largura = $dimensoes[0]; |
|
| 120 | 120 | $this->altura = $dimensoes[1]; |
| 121 | 121 | // 1 = gif, 2 = jpeg, 3 = png, 6 = BMP |
| 122 | 122 | // http://br2.php.net/manual/en/function.exif-imagetype.php |
| 123 | 123 | $this->formato = $dimensoes[2]; |
| 124 | - $this->tamanho_html = $dimensoes[3]; |
|
| 124 | + $this->tamanho_html = $dimensoes[3]; |
|
| 125 | 125 | } // fim dimensoes |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -132,11 +132,11 @@ discard block |
||
| 132 | 132 | private function dadosArquivo() |
| 133 | 133 | { |
| 134 | 134 | // imagem de origem |
| 135 | - $pathinfo = pathinfo( $this->origem ); |
|
| 136 | - $this->extensao = strtolower( $pathinfo['extension'] ); |
|
| 135 | + $pathinfo = pathinfo($this->origem); |
|
| 136 | + $this->extensao = strtolower($pathinfo['extension']); |
|
| 137 | 137 | $this->arquivo = $pathinfo['basename']; |
| 138 | 138 | $this->diretorio = $pathinfo['dirname']; |
| 139 | - $this->tamanho = filesize( $this->origem ); |
|
| 139 | + $this->tamanho = filesize($this->origem); |
|
| 140 | 140 | } // fim dadosArquivo |
| 141 | 141 | |
| 142 | 142 | /** |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | private function eImagem() |
| 148 | 148 | { |
| 149 | 149 | // filtra extensão |
| 150 | - if ( !in_array( $this->extensao, $this->extensoes_validas ) ) |
|
| 150 | + if ( ! in_array($this->extensao, $this->extensoes_validas)) |
|
| 151 | 151 | { |
| 152 | 152 | return false; |
| 153 | 153 | } |
@@ -167,26 +167,26 @@ discard block |
||
| 167 | 167 | */ |
| 168 | 168 | private function criaImagem() |
| 169 | 169 | { |
| 170 | - switch ( $this->formato ) |
|
| 170 | + switch ($this->formato) |
|
| 171 | 171 | { |
| 172 | 172 | case 1: |
| 173 | - $this->img = imagecreatefromgif( $this->origem ); |
|
| 173 | + $this->img = imagecreatefromgif($this->origem); |
|
| 174 | 174 | $this->extensao = 'gif'; |
| 175 | 175 | break; |
| 176 | 176 | case 2: |
| 177 | - $this->img = imagecreatefromjpeg( $this->origem ); |
|
| 177 | + $this->img = imagecreatefromjpeg($this->origem); |
|
| 178 | 178 | $this->extensao = 'jpg'; |
| 179 | 179 | break; |
| 180 | 180 | case 3: |
| 181 | - $this->img = imagecreatefrompng( $this->origem ); |
|
| 181 | + $this->img = imagecreatefrompng($this->origem); |
|
| 182 | 182 | $this->extensao = 'png'; |
| 183 | 183 | break; |
| 184 | 184 | case 6: |
| 185 | - $this->img = imagecreatefrombmp( $this->origem ); |
|
| 185 | + $this->img = imagecreatefrombmp($this->origem); |
|
| 186 | 186 | $this->extensao = 'bmp'; |
| 187 | 187 | break; |
| 188 | 188 | default: |
| 189 | - trigger_error( 'Arquivo inválido!', E_USER_WARNING ); |
|
| 189 | + trigger_error('Arquivo inválido!', E_USER_WARNING); |
|
| 190 | 190 | break; |
| 191 | 191 | } |
| 192 | 192 | } // fim criaImagem |
@@ -199,9 +199,9 @@ discard block |
||
| 199 | 199 | * @param Valores R, G e B |
| 200 | 200 | * @return Void |
| 201 | 201 | */ |
| 202 | - public function rgb( $r, $g, $b ) |
|
| 202 | + public function rgb($r, $g, $b) |
|
| 203 | 203 | { |
| 204 | - $this->rgb = array( $r, $g, $b ); |
|
| 204 | + $this->rgb = array($r, $g, $b); |
|
| 205 | 205 | } // fim rgb |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -209,9 +209,9 @@ discard block |
||
| 209 | 209 | * @param Array valores x e y |
| 210 | 210 | * @return Void |
| 211 | 211 | */ |
| 212 | - public function posicaoCrop( $x, $y ) |
|
| 212 | + public function posicaoCrop($x, $y) |
|
| 213 | 213 | { |
| 214 | - $this->posicao_crop = array( $x, $y, $this->largura, $this->altura ); |
|
| 214 | + $this->posicao_crop = array($x, $y, $this->largura, $this->altura); |
|
| 215 | 215 | } // fim posicao_crop |
| 216 | 216 | |
| 217 | 217 | /** |
@@ -221,47 +221,47 @@ discard block |
||
| 221 | 221 | * @param String $tipo método para redimensionamento (padrão [vazio], 'fill' [preenchimento] ou 'crop') |
| 222 | 222 | * @return Boolean/void |
| 223 | 223 | */ |
| 224 | - public function redimensiona( $nova_largura = 0, $nova_altura = 0, $tipo = '' ) |
|
| 224 | + public function redimensiona($nova_largura = 0, $nova_altura = 0, $tipo = '') |
|
| 225 | 225 | { |
| 226 | 226 | |
| 227 | 227 | // seta variáveis passadas via parâmetro |
| 228 | - $this->nova_largura = $nova_largura; |
|
| 229 | - $this->nova_altura = $nova_altura; |
|
| 228 | + $this->nova_largura = $nova_largura; |
|
| 229 | + $this->nova_altura = $nova_altura; |
|
| 230 | 230 | |
| 231 | 231 | // verifica se passou altura ou largura como porcentagem |
| 232 | 232 | // largura % |
| 233 | - $pos = strpos( $this->nova_largura, '%' ); |
|
| 234 | - if( $pos !== false && $pos > 0 ) |
|
| 233 | + $pos = strpos($this->nova_largura, '%'); |
|
| 234 | + if ($pos !== false && $pos > 0) |
|
| 235 | 235 | { |
| 236 | - $porcentagem = ( ( int ) str_replace( '%', '', $this->nova_largura ) ) / 100; |
|
| 237 | - $this->nova_largura = round( $this->largura * $porcentagem ); |
|
| 236 | + $porcentagem = ((int) str_replace('%', '', $this->nova_largura)) / 100; |
|
| 237 | + $this->nova_largura = round($this->largura * $porcentagem); |
|
| 238 | 238 | } |
| 239 | 239 | // altura % |
| 240 | - $pos = strpos( $this->nova_altura, '%' ); |
|
| 241 | - if( $pos !== false && $pos > 0 ) |
|
| 240 | + $pos = strpos($this->nova_altura, '%'); |
|
| 241 | + if ($pos !== false && $pos > 0) |
|
| 242 | 242 | { |
| 243 | - $porcentagem = ( ( int ) str_replace( '%', '', $this->nova_altura ) ) / 100; |
|
| 244 | - $this->nova_altura = $this->altura * $porcentagem; |
|
| 243 | + $porcentagem = ((int) str_replace('%', '', $this->nova_altura)) / 100; |
|
| 244 | + $this->nova_altura = $this->altura * $porcentagem; |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | // define se só passou nova largura ou altura |
| 248 | - if ( !$this->nova_largura && !$this->nova_altura ) |
|
| 248 | + if ( ! $this->nova_largura && ! $this->nova_altura) |
|
| 249 | 249 | { |
| 250 | 250 | return false; |
| 251 | 251 | } |
| 252 | 252 | // só passou altura |
| 253 | - elseif ( !$this->nova_largura ) |
|
| 253 | + elseif ( ! $this->nova_largura) |
|
| 254 | 254 | { |
| 255 | - $this->nova_largura = $this->largura / ( $this->altura/$this->nova_altura ); |
|
| 255 | + $this->nova_largura = $this->largura / ($this->altura / $this->nova_altura); |
|
| 256 | 256 | } |
| 257 | 257 | // só passou largura |
| 258 | - elseif ( !$this->nova_altura ) |
|
| 258 | + elseif ( ! $this->nova_altura) |
|
| 259 | 259 | { |
| 260 | - $this->nova_altura = $this->altura / ( $this->largura/$this->nova_largura ); |
|
| 260 | + $this->nova_altura = $this->altura / ($this->largura / $this->nova_largura); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | // redimensiona de acordo com tipo |
| 264 | - switch( $tipo ) |
|
| 264 | + switch ($tipo) |
|
| 265 | 265 | { |
| 266 | 266 | case 'crop': |
| 267 | 267 | $this->resizeCrop(); |
@@ -288,10 +288,10 @@ discard block |
||
| 288 | 288 | private function resize() |
| 289 | 289 | { |
| 290 | 290 | // cria imagem de destino temporária |
| 291 | - $this->img_temp = imagecreatetruecolor( $this->nova_largura, $this->nova_altura ); |
|
| 291 | + $this->img_temp = imagecreatetruecolor($this->nova_largura, $this->nova_altura); |
|
| 292 | 292 | |
| 293 | - imagecopyresampled( $this->img_temp, $this->img, 0, 0, 0, 0, $this->nova_largura, $this->nova_altura, $this->largura, $this->altura ); |
|
| 294 | - $this->img = $this->img_temp; |
|
| 293 | + imagecopyresampled($this->img_temp, $this->img, 0, 0, 0, 0, $this->nova_largura, $this->nova_altura, $this->largura, $this->altura); |
|
| 294 | + $this->img = $this->img_temp; |
|
| 295 | 295 | } // fim resize() |
| 296 | 296 | |
| 297 | 297 | /** |
@@ -301,8 +301,8 @@ discard block |
||
| 301 | 301 | */ |
| 302 | 302 | private function preencheImagem() |
| 303 | 303 | { |
| 304 | - $corfundo = imagecolorallocate( $this->img_temp, $this->rgb[0], $this->rgb[1], $this->rgb[2] ); |
|
| 305 | - imagefill( $this->img_temp, 0, 0, $corfundo ); |
|
| 304 | + $corfundo = imagecolorallocate($this->img_temp, $this->rgb[0], $this->rgb[1], $this->rgb[2]); |
|
| 305 | + imagefill($this->img_temp, 0, 0, $corfundo); |
|
| 306 | 306 | } // fim preencheImagem |
| 307 | 307 | |
| 308 | 308 | /** |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | private function resizeFill() |
| 315 | 315 | { |
| 316 | 316 | // cria imagem de destino temporária |
| 317 | - $this->img_temp = imagecreatetruecolor( $this->nova_largura, $this->nova_altura ); |
|
| 317 | + $this->img_temp = imagecreatetruecolor($this->nova_largura, $this->nova_altura); |
|
| 318 | 318 | |
| 319 | 319 | // adiciona cor de fundo à nova imagem |
| 320 | 320 | $this->preencheImagem(); |
@@ -324,20 +324,20 @@ discard block |
||
| 324 | 324 | $dif_x = $this->nova_largura; |
| 325 | 325 | |
| 326 | 326 | // verifica altura e largura |
| 327 | - if ( $this->largura > $this->altura ) |
|
| 327 | + if ($this->largura > $this->altura) |
|
| 328 | 328 | { |
| 329 | - $this->nova_altura = ( ( $this->altura * $this->nova_largura ) / $this->largura ); |
|
| 329 | + $this->nova_altura = (($this->altura * $this->nova_largura) / $this->largura); |
|
| 330 | 330 | } |
| 331 | - elseif ( $this->largura <= $this->altura ) |
|
| 331 | + elseif ($this->largura <= $this->altura) |
|
| 332 | 332 | { |
| 333 | - $this->nova_largura = ( ( $this->largura * $this->nova_altura ) / $this->altura ); |
|
| 333 | + $this->nova_largura = (($this->largura * $this->nova_altura) / $this->altura); |
|
| 334 | 334 | } // fim do if verifica altura largura |
| 335 | 335 | |
| 336 | 336 | // copia com o novo tamanho, centralizando |
| 337 | - $dif_x = ( $dif_x - $this->nova_largura ) / 2; |
|
| 338 | - $dif_y = ( $dif_y - $this->nova_altura ) / 2; |
|
| 339 | - imagecopyresampled( $this->img_temp, $this->img, $dif_x, $dif_y, 0, 0, $this->nova_largura, $this->nova_altura, $this->largura, $this->altura ); |
|
| 340 | - $this->img = $this->img_temp; |
|
| 337 | + $dif_x = ($dif_x - $this->nova_largura) / 2; |
|
| 338 | + $dif_y = ($dif_y - $this->nova_altura) / 2; |
|
| 339 | + imagecopyresampled($this->img_temp, $this->img, $dif_x, $dif_y, 0, 0, $this->nova_largura, $this->nova_altura, $this->largura, $this->altura); |
|
| 340 | + $this->img = $this->img_temp; |
|
| 341 | 341 | } // fim resizeFill() |
| 342 | 342 | |
| 343 | 343 | /** |
@@ -358,22 +358,22 @@ discard block |
||
| 358 | 358 | $h_width = $this->nova_largura / 2; |
| 359 | 359 | |
| 360 | 360 | // calcula novas largura e altura |
| 361 | - if( !is_array( $this->posicao_crop ) ) |
|
| 361 | + if ( ! is_array($this->posicao_crop)) |
|
| 362 | 362 | { |
| 363 | - if ( $wm > $hm ) |
|
| 363 | + if ($wm > $hm) |
|
| 364 | 364 | { |
| 365 | 365 | $this->posicao_crop[2] = $this->largura / $hm; |
| 366 | 366 | $this->posicao_crop[3] = $this->nova_altura; |
| 367 | - $this->posicao_crop[0] = ( $this->posicao_crop[2] / 2 ) - $h_width; |
|
| 368 | - $this->posicao_crop[1] = 0; |
|
| 367 | + $this->posicao_crop[0] = ($this->posicao_crop[2] / 2) - $h_width; |
|
| 368 | + $this->posicao_crop[1] = 0; |
|
| 369 | 369 | } |
| 370 | 370 | // largura <= altura |
| 371 | - elseif ( ( $wm <= $hm ) ) |
|
| 371 | + elseif (($wm <= $hm)) |
|
| 372 | 372 | { |
| 373 | 373 | $this->posicao_crop[2] = $this->nova_largura; |
| 374 | 374 | $this->posicao_crop[3] = $this->altura / $wm; |
| 375 | 375 | $this->posicao_crop[0] = 0; |
| 376 | - $this->posicao_crop[1] = ( $this->posicao_crop[3] / 2 ) - $h_height; |
|
| 376 | + $this->posicao_crop[1] = ($this->posicao_crop[3] / 2) - $h_height; |
|
| 377 | 377 | } |
| 378 | 378 | } |
| 379 | 379 | } // fim calculaPosicaoCrop |
@@ -391,14 +391,14 @@ discard block |
||
| 391 | 391 | $this->calculaPosicaoCrop(); |
| 392 | 392 | |
| 393 | 393 | // cria imagem de destino temporária |
| 394 | - $this->img_temp = imagecreatetruecolor( $this->nova_largura, $this->nova_altura ); |
|
| 394 | + $this->img_temp = imagecreatetruecolor($this->nova_largura, $this->nova_altura); |
|
| 395 | 395 | |
| 396 | 396 | // adiciona cor de fundo à nova imagem |
| 397 | 397 | $this->preencheImagem(); |
| 398 | 398 | |
| 399 | - imagecopyresampled( $this->img_temp, $this->img, -$this->posicao_crop[0], -$this->posicao_crop[1], 0, 0, $this->posicao_crop[2], $this->posicao_crop[3], $this->largura, $this->altura ); |
|
| 399 | + imagecopyresampled($this->img_temp, $this->img, -$this->posicao_crop[0], -$this->posicao_crop[1], 0, 0, $this->posicao_crop[2], $this->posicao_crop[3], $this->largura, $this->altura); |
|
| 400 | 400 | |
| 401 | - $this->img = $this->img_temp; |
|
| 401 | + $this->img = $this->img_temp; |
|
| 402 | 402 | } // fim resizeCrop |
| 403 | 403 | |
| 404 | 404 | //------------------------------------------------------------------------------ |
@@ -411,32 +411,32 @@ discard block |
||
| 411 | 411 | * @param String $tipo tipo de espelhamento: h - horizontal, v - vertical |
| 412 | 412 | * @return void |
| 413 | 413 | */ |
| 414 | - public function flip( $tipo = 'h' ) |
|
| 414 | + public function flip($tipo = 'h') |
|
| 415 | 415 | { |
| 416 | - $w = imagesx( $this->img ); |
|
| 417 | - $h = imagesy( $this->img ); |
|
| 416 | + $w = imagesx($this->img); |
|
| 417 | + $h = imagesy($this->img); |
|
| 418 | 418 | |
| 419 | - $this->img_temp = imagecreatetruecolor( $w, $h ); |
|
| 419 | + $this->img_temp = imagecreatetruecolor($w, $h); |
|
| 420 | 420 | |
| 421 | 421 | // vertical |
| 422 | - if ( 'v' == $tipo ) |
|
| 422 | + if ('v' == $tipo) |
|
| 423 | 423 | { |
| 424 | - for ( $y = 0; $y < $h; $y++ ) |
|
| 424 | + for ($y = 0; $y < $h; $y++) |
|
| 425 | 425 | { |
| 426 | - imagecopy( $this->img_temp, $this->img, 0, $y, 0, $h - $y - 1, $w, 1 ); |
|
| 426 | + imagecopy($this->img_temp, $this->img, 0, $y, 0, $h - $y - 1, $w, 1); |
|
| 427 | 427 | } |
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | // horizontal |
| 431 | - if ( 'h' == $tipo ) |
|
| 431 | + if ('h' == $tipo) |
|
| 432 | 432 | { |
| 433 | - for ( $x = 0; $x < $w; $x++ ) |
|
| 433 | + for ($x = 0; $x < $w; $x++) |
|
| 434 | 434 | { |
| 435 | - imagecopy( $this->img_temp, $this->img, $x, 0, $w - $x - 1, 0, 1, $h ); |
|
| 435 | + imagecopy($this->img_temp, $this->img, $x, 0, $w - $x - 1, 0, 1, $h); |
|
| 436 | 436 | } |
| 437 | 437 | } |
| 438 | 438 | |
| 439 | - $this->img = $this->img_temp; |
|
| 439 | + $this->img = $this->img_temp; |
|
| 440 | 440 | |
| 441 | 441 | } // fim flip |
| 442 | 442 | |
@@ -446,10 +446,10 @@ discard block |
||
| 446 | 446 | * @param Array $rgb cor RGB para preenchimento |
| 447 | 447 | * @return void |
| 448 | 448 | */ |
| 449 | - public function girar( $graus, $rgb = array( 255,255,255 ) ) |
|
| 449 | + public function girar($graus, $rgb = array(255, 255, 255)) |
|
| 450 | 450 | { |
| 451 | - $corfundo = imagecolorallocate( $this->img, $rgb[0], $rgb[1], $rgb[2] ); |
|
| 452 | - $this->img = imagerotate( $this->img, $graus, $corfundo ); |
|
| 451 | + $corfundo = imagecolorallocate($this->img, $rgb[0], $rgb[1], $rgb[2]); |
|
| 452 | + $this->img = imagerotate($this->img, $graus, $corfundo); |
|
| 453 | 453 | } // fim girar |
| 454 | 454 | |
| 455 | 455 | /** |
@@ -463,18 +463,18 @@ discard block |
||
| 463 | 463 | * @param String $fonte nome da fonte truetype a ser utilizada |
| 464 | 464 | * @return void |
| 465 | 465 | */ |
| 466 | - public function legenda( $texto, $tamanho = 10, $x = 0, $y = 0, $rgb = array( 255,255,255 ), $truetype = false, $fonte = '' ) |
|
| 466 | + public function legenda($texto, $tamanho = 10, $x = 0, $y = 0, $rgb = array(255, 255, 255), $truetype = false, $fonte = '') |
|
| 467 | 467 | { |
| 468 | - $cortexto = imagecolorallocate( $this->img, $rgb[0], $rgb[1], $rgb[2] ); |
|
| 468 | + $cortexto = imagecolorallocate($this->img, $rgb[0], $rgb[1], $rgb[2]); |
|
| 469 | 469 | |
| 470 | 470 | // truetype ou fonte do sistema? |
| 471 | - if ( $truetype === true ) |
|
| 471 | + if ($truetype === true) |
|
| 472 | 472 | { |
| 473 | - imagettftext( $this->img, $tamanho, 0, $x, $y, $cortexto, $fonte, $texto ); |
|
| 473 | + imagettftext($this->img, $tamanho, 0, $x, $y, $cortexto, $fonte, $texto); |
|
| 474 | 474 | } |
| 475 | 475 | else |
| 476 | 476 | { |
| 477 | - imagestring( $this->img, $tamanho, $x, $y, $texto, $cortexto ); |
|
| 477 | + imagestring($this->img, $tamanho, $x, $y, $texto, $cortexto); |
|
| 478 | 478 | } |
| 479 | 479 | } // fim legenda |
| 480 | 480 | |
@@ -488,25 +488,25 @@ discard block |
||
| 488 | 488 | -> se utilizar alfa, a função imagecopymerge não preserva |
| 489 | 489 | -> o alfa nativo do PNG |
| 490 | 490 | */ |
| 491 | - public function marca( $imagem, $x = 0, $y = 0, $alfa = 100 ) |
|
| 491 | + public function marca($imagem, $x = 0, $y = 0, $alfa = 100) |
|
| 492 | 492 | { |
| 493 | 493 | // cria imagem temporária para merge |
| 494 | - if ( $imagem ) { |
|
| 495 | - $pathinfo = pathinfo( $imagem ); |
|
| 496 | - switch( strtolower( $pathinfo['extension'] ) ) |
|
| 494 | + if ($imagem) { |
|
| 495 | + $pathinfo = pathinfo($imagem); |
|
| 496 | + switch (strtolower($pathinfo['extension'])) |
|
| 497 | 497 | { |
| 498 | 498 | case 'jpg': |
| 499 | 499 | case 'jpeg': |
| 500 | - $marcadagua = imagecreatefromjpeg( $imagem ); |
|
| 500 | + $marcadagua = imagecreatefromjpeg($imagem); |
|
| 501 | 501 | break; |
| 502 | 502 | case 'png': |
| 503 | - $marcadagua = imagecreatefrompng( $imagem ); |
|
| 503 | + $marcadagua = imagecreatefrompng($imagem); |
|
| 504 | 504 | break; |
| 505 | 505 | case 'gif': |
| 506 | - $marcadagua = imagecreatefromgif( $imagem ); |
|
| 506 | + $marcadagua = imagecreatefromgif($imagem); |
|
| 507 | 507 | break; |
| 508 | 508 | case 'bmp': |
| 509 | - $marcadagua = imagecreatefrombmp( $imagem ); |
|
| 509 | + $marcadagua = imagecreatefrombmp($imagem); |
|
| 510 | 510 | break; |
| 511 | 511 | default: |
| 512 | 512 | $this->erro = 'Arquivo de marca d\'água inválido.'; |
@@ -518,13 +518,13 @@ discard block |
||
| 518 | 518 | return false; |
| 519 | 519 | } |
| 520 | 520 | // dimensões |
| 521 | - $marca_w = imagesx( $marcadagua ); |
|
| 522 | - $marca_h = imagesy( $marcadagua ); |
|
| 521 | + $marca_w = imagesx($marcadagua); |
|
| 522 | + $marca_h = imagesy($marcadagua); |
|
| 523 | 523 | // retorna imagens com marca d'água |
| 524 | - if ( is_numeric( $alfa ) && ( ( $alfa > 0 ) && ( $alfa < 100 ) ) ) { |
|
| 525 | - imagecopymerge( $this->img, $marcadagua, $x, $y, 0, 0, $marca_w, $marca_h, $alfa ); |
|
| 524 | + if (is_numeric($alfa) && (($alfa > 0) && ($alfa < 100))) { |
|
| 525 | + imagecopymerge($this->img, $marcadagua, $x, $y, 0, 0, $marca_w, $marca_h, $alfa); |
|
| 526 | 526 | } else { |
| 527 | - imagecopy( $this->img, $marcadagua, $x, $y, 0, 0, $marca_w, $marca_h ); |
|
| 527 | + imagecopy($this->img, $marcadagua, $x, $y, 0, 0, $marca_w, $marca_h); |
|
| 528 | 528 | } |
| 529 | 529 | return true; |
| 530 | 530 | } // fim marca |
@@ -539,21 +539,21 @@ discard block |
||
| 539 | 539 | * @param Int $alfa valor para transparência (0-100) |
| 540 | 540 | * @return void |
| 541 | 541 | */ |
| 542 | - public function marcaFixa( $imagem, $posicao, $alfa = 100 ) |
|
| 542 | + public function marcaFixa($imagem, $posicao, $alfa = 100) |
|
| 543 | 543 | { |
| 544 | 544 | |
| 545 | 545 | // dimensões da marca d'água |
| 546 | - list( $marca_w, $marca_h ) = getimagesize( $imagem ); |
|
| 546 | + list($marca_w, $marca_h) = getimagesize($imagem); |
|
| 547 | 547 | |
| 548 | 548 | // define X e Y para posicionamento |
| 549 | - switch( $posicao ) |
|
| 549 | + switch ($posicao) |
|
| 550 | 550 | { |
| 551 | 551 | case 'topo_esquerda': |
| 552 | 552 | $x = 0; |
| 553 | 553 | $y = 0; |
| 554 | 554 | break; |
| 555 | 555 | case 'topo_centro': |
| 556 | - $x = ( $this->largura - $marca_w ) / 2; |
|
| 556 | + $x = ($this->largura - $marca_w) / 2; |
|
| 557 | 557 | $y = 0; |
| 558 | 558 | break; |
| 559 | 559 | case 'topo_direita': |
@@ -562,22 +562,22 @@ discard block |
||
| 562 | 562 | break; |
| 563 | 563 | case 'meio_esquerda': |
| 564 | 564 | $x = 0; |
| 565 | - $y = ( $this->altura / 2 ) - ( $marca_h / 2 ); |
|
| 565 | + $y = ($this->altura / 2) - ($marca_h / 2); |
|
| 566 | 566 | break; |
| 567 | 567 | case 'meio_centro': |
| 568 | - $x = ( $this->largura - $marca_w ) / 2; |
|
| 569 | - $y = ( $this->altura / 2 ) - ( $marca_h / 2 ); |
|
| 568 | + $x = ($this->largura - $marca_w) / 2; |
|
| 569 | + $y = ($this->altura / 2) - ($marca_h / 2); |
|
| 570 | 570 | break; |
| 571 | 571 | case 'meio_direita': |
| 572 | 572 | $x = $this->largura - $marca_w; |
| 573 | - $y = ( $this->altura / 2) - ( $marca_h / 2 ); |
|
| 573 | + $y = ($this->altura / 2) - ($marca_h / 2); |
|
| 574 | 574 | break; |
| 575 | 575 | case 'baixo_esquerda': |
| 576 | 576 | $x = 0; |
| 577 | 577 | $y = $this->altura - $marca_h; |
| 578 | 578 | break; |
| 579 | 579 | case 'baixo_centro': |
| 580 | - $x = ( $this->largura - $marca_w ) / 2; |
|
| 580 | + $x = ($this->largura - $marca_w) / 2; |
|
| 581 | 581 | $y = $this->altura - $marca_h; |
| 582 | 582 | break; |
| 583 | 583 | case 'baixo_direita': |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | } // end switch posicao |
| 591 | 591 | |
| 592 | 592 | // cria marca |
| 593 | - $this->marca( $imagem, $x, $y, $alfa ); |
|
| 593 | + $this->marca($imagem, $x, $y, $alfa); |
|
| 594 | 594 | |
| 595 | 595 | } // fim marcaFixa |
| 596 | 596 | |
@@ -604,78 +604,78 @@ discard block |
||
| 604 | 604 | * @param Int $qualidade qualidade da imagem no caso de JPEG (0-100) |
| 605 | 605 | * @return void |
| 606 | 606 | */ |
| 607 | - public function grava( $destino='', $qualidade = 100 ) |
|
| 607 | + public function grava($destino = '', $qualidade = 100) |
|
| 608 | 608 | { |
| 609 | 609 | // dados do arquivo de destino |
| 610 | - if ( $destino ) |
|
| 610 | + if ($destino) |
|
| 611 | 611 | { |
| 612 | - $pathinfo = pathinfo( $destino ); |
|
| 613 | - $dir_destino = $pathinfo['dirname']; |
|
| 614 | - $extensao_destino = strtolower( $pathinfo['extension'] ); |
|
| 612 | + $pathinfo = pathinfo($destino); |
|
| 613 | + $dir_destino = $pathinfo['dirname']; |
|
| 614 | + $extensao_destino = strtolower($pathinfo['extension']); |
|
| 615 | 615 | |
| 616 | 616 | // valida diretório |
| 617 | - if ( !is_dir( $dir_destino ) ) |
|
| 617 | + if ( ! is_dir($dir_destino)) |
|
| 618 | 618 | { |
| 619 | - $this->erro = 'Diretório de destino inválido ou inexistente'; |
|
| 619 | + $this->erro = 'Diretório de destino inválido ou inexistente'; |
|
| 620 | 620 | return false; |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | } |
| 624 | 624 | |
| 625 | 625 | // valida extensão de destino |
| 626 | - if ( !isset( $extensao_destino ) ) |
|
| 626 | + if ( ! isset($extensao_destino)) |
|
| 627 | 627 | { |
| 628 | 628 | $extensao_destino = $this->extensao; |
| 629 | 629 | } |
| 630 | 630 | else |
| 631 | 631 | { |
| 632 | - if ( !in_array( $extensao_destino, $this->extensoes_validas ) ) |
|
| 632 | + if ( ! in_array($extensao_destino, $this->extensoes_validas)) |
|
| 633 | 633 | { |
| 634 | 634 | $this->erro = 'Extensão inválida para o arquivo de destino'; |
| 635 | 635 | return false; |
| 636 | 636 | } |
| 637 | 637 | } |
| 638 | 638 | |
| 639 | - switch( $extensao_destino ) |
|
| 639 | + switch ($extensao_destino) |
|
| 640 | 640 | { |
| 641 | 641 | case 'jpg': |
| 642 | 642 | case 'jpeg': |
| 643 | 643 | case 'bmp': |
| 644 | - if ( $destino ) |
|
| 644 | + if ($destino) |
|
| 645 | 645 | { |
| 646 | - imagejpeg( $this->img, $destino, $qualidade ); |
|
| 646 | + imagejpeg($this->img, $destino, $qualidade); |
|
| 647 | 647 | } |
| 648 | 648 | else |
| 649 | 649 | { |
| 650 | - header( "Content-type: image/jpeg" ); |
|
| 651 | - imagejpeg( $this->img, NULL, $qualidade ); |
|
| 652 | - imagedestroy( $this->img ); |
|
| 650 | + header("Content-type: image/jpeg"); |
|
| 651 | + imagejpeg($this->img, NULL, $qualidade); |
|
| 652 | + imagedestroy($this->img); |
|
| 653 | 653 | exit; |
| 654 | 654 | } |
| 655 | 655 | break; |
| 656 | 656 | case 'png': |
| 657 | - if ( $destino ) |
|
| 657 | + if ($destino) |
|
| 658 | 658 | { |
| 659 | - imagepng( $this->img, $destino ); |
|
| 659 | + imagepng($this->img, $destino); |
|
| 660 | 660 | } |
| 661 | 661 | else |
| 662 | 662 | { |
| 663 | - header( "Content-type: image/png" ); |
|
| 664 | - imagepng( $this->img ); |
|
| 665 | - imagedestroy( $this->img ); |
|
| 663 | + header("Content-type: image/png"); |
|
| 664 | + imagepng($this->img); |
|
| 665 | + imagedestroy($this->img); |
|
| 666 | 666 | exit; |
| 667 | 667 | } |
| 668 | 668 | break; |
| 669 | 669 | case 'gif': |
| 670 | - if ( $destino ) |
|
| 670 | + if ($destino) |
|
| 671 | 671 | { |
| 672 | - imagegif( $this->img, $destino ); |
|
| 672 | + imagegif($this->img, $destino); |
|
| 673 | 673 | } |
| 674 | 674 | else |
| 675 | 675 | { |
| 676 | - header( "Content-type: image/gif" ); |
|
| 677 | - imagegif( $this->img ); |
|
| 678 | - imagedestroy( $this->img ); |
|
| 676 | + header("Content-type: image/gif"); |
|
| 677 | + imagegif($this->img); |
|
| 678 | + imagedestroy($this->img); |
|
| 679 | 679 | exit; |
| 680 | 680 | } |
| 681 | 681 | break; |
@@ -703,83 +703,83 @@ discard block |
||
| 703 | 703 | |
| 704 | 704 | function imagecreatefrombmp($filename) { |
| 705 | 705 | //Ouverture du fichier en mode binaire |
| 706 | - if (! $f1 = fopen($filename,"rb")) return FALSE; |
|
| 706 | + if ( ! $f1 = fopen($filename, "rb")) return FALSE; |
|
| 707 | 707 | |
| 708 | 708 | //1 : Chargement des ent?tes FICHIER |
| 709 | - $FILE = unpack("vfile_type/Vfile_size/Vreserved/Vbitmap_offset", fread($f1,14)); |
|
| 709 | + $FILE = unpack("vfile_type/Vfile_size/Vreserved/Vbitmap_offset", fread($f1, 14)); |
|
| 710 | 710 | if ($FILE['file_type'] != 19778) return FALSE; |
| 711 | 711 | |
| 712 | 712 | //2 : Chargement des ent?tes BMP |
| 713 | 713 | $BMP = unpack('Vheader_size/Vwidth/Vheight/vplanes/vbits_per_pixel'. |
| 714 | 714 | '/Vcompression/Vsize_bitmap/Vhoriz_resolution'. |
| 715 | - '/Vvert_resolution/Vcolors_used/Vcolors_important', fread($f1,40)); |
|
| 716 | - $BMP['colors'] = pow(2,$BMP['bits_per_pixel']); |
|
| 715 | + '/Vvert_resolution/Vcolors_used/Vcolors_important', fread($f1, 40)); |
|
| 716 | + $BMP['colors'] = pow(2, $BMP['bits_per_pixel']); |
|
| 717 | 717 | if ($BMP['size_bitmap'] == 0) $BMP['size_bitmap'] = $FILE['file_size'] - $FILE['bitmap_offset']; |
| 718 | - $BMP['bytes_per_pixel'] = $BMP['bits_per_pixel']/8; |
|
| 718 | + $BMP['bytes_per_pixel'] = $BMP['bits_per_pixel'] / 8; |
|
| 719 | 719 | $BMP['bytes_per_pixel2'] = ceil($BMP['bytes_per_pixel']); |
| 720 | - $BMP['decal'] = ($BMP['width']*$BMP['bytes_per_pixel']/4); |
|
| 721 | - $BMP['decal'] -= floor($BMP['width']*$BMP['bytes_per_pixel']/4); |
|
| 722 | - $BMP['decal'] = 4-(4*$BMP['decal']); |
|
| 720 | + $BMP['decal'] = ($BMP['width'] * $BMP['bytes_per_pixel'] / 4); |
|
| 721 | + $BMP['decal'] -= floor($BMP['width'] * $BMP['bytes_per_pixel'] / 4); |
|
| 722 | + $BMP['decal'] = 4 - (4 * $BMP['decal']); |
|
| 723 | 723 | if ($BMP['decal'] == 4) $BMP['decal'] = 0; |
| 724 | 724 | |
| 725 | 725 | //3 : Chargement des couleurs de la palette |
| 726 | 726 | $PALETTE = array(); |
| 727 | 727 | if ($BMP['colors'] < 16777216) |
| 728 | 728 | { |
| 729 | - $PALETTE = unpack('V'.$BMP['colors'], fread($f1,$BMP['colors']*4)); |
|
| 729 | + $PALETTE = unpack('V'.$BMP['colors'], fread($f1, $BMP['colors'] * 4)); |
|
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | //4 : Cr?ation de l'image |
| 733 | - $IMG = fread($f1,$BMP['size_bitmap']); |
|
| 733 | + $IMG = fread($f1, $BMP['size_bitmap']); |
|
| 734 | 734 | $VIDE = chr(0); |
| 735 | 735 | |
| 736 | - $res = imagecreatetruecolor($BMP['width'],$BMP['height']); |
|
| 736 | + $res = imagecreatetruecolor($BMP['width'], $BMP['height']); |
|
| 737 | 737 | $P = 0; |
| 738 | - $Y = $BMP['height']-1; |
|
| 738 | + $Y = $BMP['height'] - 1; |
|
| 739 | 739 | while ($Y >= 0) |
| 740 | 740 | { |
| 741 | - $X=0; |
|
| 741 | + $X = 0; |
|
| 742 | 742 | while ($X < $BMP['width']) |
| 743 | 743 | { |
| 744 | 744 | if ($BMP['bits_per_pixel'] == 24) |
| 745 | - $COLOR = @unpack("V",substr($IMG,$P,3).$VIDE); |
|
| 745 | + $COLOR = @unpack("V", substr($IMG, $P, 3).$VIDE); |
|
| 746 | 746 | elseif ($BMP['bits_per_pixel'] == 16) |
| 747 | 747 | { |
| 748 | - $COLOR = @unpack("n",substr($IMG,$P,2)); |
|
| 749 | - $COLOR[1] = $PALETTE[$COLOR[1]+1]; |
|
| 748 | + $COLOR = @unpack("n", substr($IMG, $P, 2)); |
|
| 749 | + $COLOR[1] = $PALETTE[$COLOR[1] + 1]; |
|
| 750 | 750 | } |
| 751 | 751 | elseif ($BMP['bits_per_pixel'] == 8) |
| 752 | 752 | { |
| 753 | - $COLOR = @unpack("n",$VIDE.substr($IMG,$P,1)); |
|
| 754 | - $COLOR[1] = $PALETTE[$COLOR[1]+1]; |
|
| 753 | + $COLOR = @unpack("n", $VIDE.substr($IMG, $P, 1)); |
|
| 754 | + $COLOR[1] = $PALETTE[$COLOR[1] + 1]; |
|
| 755 | 755 | } |
| 756 | 756 | elseif ($BMP['bits_per_pixel'] == 4) |
| 757 | 757 | { |
| 758 | - $COLOR = @unpack("n",$VIDE.substr($IMG,floor($P),1)); |
|
| 759 | - if (($P*2)%2 == 0) $COLOR[1] = ($COLOR[1] >> 4) ; else $COLOR[1] = ($COLOR[1] & 0x0F); |
|
| 760 | - $COLOR[1] = $PALETTE[$COLOR[1]+1]; |
|
| 758 | + $COLOR = @unpack("n", $VIDE.substr($IMG, floor($P), 1)); |
|
| 759 | + if (($P * 2) % 2 == 0) $COLOR[1] = ($COLOR[1] >> 4); else $COLOR[1] = ($COLOR[1] & 0x0F); |
|
| 760 | + $COLOR[1] = $PALETTE[$COLOR[1] + 1]; |
|
| 761 | 761 | } |
| 762 | 762 | elseif ($BMP['bits_per_pixel'] == 1) |
| 763 | 763 | { |
| 764 | - $COLOR = @unpack("n",$VIDE.substr($IMG,floor($P),1)); |
|
| 765 | - if (($P*8)%8 == 0) $COLOR[1] = $COLOR[1] >>7; |
|
| 766 | - elseif (($P*8)%8 == 1) $COLOR[1] = ($COLOR[1] & 0x40)>>6; |
|
| 767 | - elseif (($P*8)%8 == 2) $COLOR[1] = ($COLOR[1] & 0x20)>>5; |
|
| 768 | - elseif (($P*8)%8 == 3) $COLOR[1] = ($COLOR[1] & 0x10)>>4; |
|
| 769 | - elseif (($P*8)%8 == 4) $COLOR[1] = ($COLOR[1] & 0x8)>>3; |
|
| 770 | - elseif (($P*8)%8 == 5) $COLOR[1] = ($COLOR[1] & 0x4)>>2; |
|
| 771 | - elseif (($P*8)%8 == 6) $COLOR[1] = ($COLOR[1] & 0x2)>>1; |
|
| 772 | - elseif (($P*8)%8 == 7) $COLOR[1] = ($COLOR[1] & 0x1); |
|
| 773 | - $COLOR[1] = $PALETTE[$COLOR[1]+1]; |
|
| 764 | + $COLOR = @unpack("n", $VIDE.substr($IMG, floor($P), 1)); |
|
| 765 | + if (($P * 8) % 8 == 0) $COLOR[1] = $COLOR[1] >> 7; |
|
| 766 | + elseif (($P * 8) % 8 == 1) $COLOR[1] = ($COLOR[1] & 0x40) >> 6; |
|
| 767 | + elseif (($P * 8) % 8 == 2) $COLOR[1] = ($COLOR[1] & 0x20) >> 5; |
|
| 768 | + elseif (($P * 8) % 8 == 3) $COLOR[1] = ($COLOR[1] & 0x10) >> 4; |
|
| 769 | + elseif (($P * 8) % 8 == 4) $COLOR[1] = ($COLOR[1] & 0x8) >> 3; |
|
| 770 | + elseif (($P * 8) % 8 == 5) $COLOR[1] = ($COLOR[1] & 0x4) >> 2; |
|
| 771 | + elseif (($P * 8) % 8 == 6) $COLOR[1] = ($COLOR[1] & 0x2) >> 1; |
|
| 772 | + elseif (($P * 8) % 8 == 7) $COLOR[1] = ($COLOR[1] & 0x1); |
|
| 773 | + $COLOR[1] = $PALETTE[$COLOR[1] + 1]; |
|
| 774 | 774 | } |
| 775 | 775 | else |
| 776 | 776 | return FALSE; |
| 777 | - imagesetpixel($res,$X,$Y,$COLOR[1]); |
|
| 777 | + imagesetpixel($res, $X, $Y, $COLOR[1]); |
|
| 778 | 778 | $X++; |
| 779 | 779 | $P += $BMP['bytes_per_pixel']; |
| 780 | 780 | } |
| 781 | 781 | $Y--; |
| 782 | - $P+=$BMP['decal']; |
|
| 782 | + $P += $BMP['decal']; |
|
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | //Fermeture du fichier |
@@ -61,8 +61,7 @@ discard block |
||
| 61 | 61 | if ( !is_file( $this->origem ) ) |
| 62 | 62 | { |
| 63 | 63 | $this->erro = 'Erro: Arquivo de imagem não encontrado!'; |
| 64 | - } |
|
| 65 | - else |
|
| 64 | + } else |
|
| 66 | 65 | { |
| 67 | 66 | // dados do arquivo |
| 68 | 67 | $this->dadosArquivo(); |
@@ -71,8 +70,7 @@ discard block |
||
| 71 | 70 | if (!$this->eImagem()) |
| 72 | 71 | { |
| 73 | 72 | $this->erro = 'Erro: Arquivo '.$this->origem.' não é uma imagem!'; |
| 74 | - } |
|
| 75 | - else |
|
| 73 | + } else |
|
| 76 | 74 | { |
| 77 | 75 | // pega dimensões |
| 78 | 76 | $this->dimensoes(); |
@@ -150,8 +148,7 @@ discard block |
||
| 150 | 148 | if ( !in_array( $this->extensao, $this->extensoes_validas ) ) |
| 151 | 149 | { |
| 152 | 150 | return false; |
| 153 | - } |
|
| 154 | - else |
|
| 151 | + } else |
|
| 155 | 152 | { |
| 156 | 153 | return true; |
| 157 | 154 | } |
@@ -327,8 +324,7 @@ discard block |
||
| 327 | 324 | if ( $this->largura > $this->altura ) |
| 328 | 325 | { |
| 329 | 326 | $this->nova_altura = ( ( $this->altura * $this->nova_largura ) / $this->largura ); |
| 330 | - } |
|
| 331 | - elseif ( $this->largura <= $this->altura ) |
|
| 327 | + } elseif ( $this->largura <= $this->altura ) |
|
| 332 | 328 | { |
| 333 | 329 | $this->nova_largura = ( ( $this->largura * $this->nova_altura ) / $this->altura ); |
| 334 | 330 | } // fim do if verifica altura largura |
@@ -471,8 +467,7 @@ discard block |
||
| 471 | 467 | if ( $truetype === true ) |
| 472 | 468 | { |
| 473 | 469 | imagettftext( $this->img, $tamanho, 0, $x, $y, $cortexto, $fonte, $texto ); |
| 474 | - } |
|
| 475 | - else |
|
| 470 | + } else |
|
| 476 | 471 | { |
| 477 | 472 | imagestring( $this->img, $tamanho, $x, $y, $texto, $cortexto ); |
| 478 | 473 | } |
@@ -512,8 +507,7 @@ discard block |
||
| 512 | 507 | $this->erro = 'Arquivo de marca d\'água inválido.'; |
| 513 | 508 | return false; |
| 514 | 509 | } |
| 515 | - } |
|
| 516 | - else |
|
| 510 | + } else |
|
| 517 | 511 | { |
| 518 | 512 | return false; |
| 519 | 513 | } |
@@ -626,8 +620,7 @@ discard block |
||
| 626 | 620 | if ( !isset( $extensao_destino ) ) |
| 627 | 621 | { |
| 628 | 622 | $extensao_destino = $this->extensao; |
| 629 | - } |
|
| 630 | - else |
|
| 623 | + } else |
|
| 631 | 624 | { |
| 632 | 625 | if ( !in_array( $extensao_destino, $this->extensoes_validas ) ) |
| 633 | 626 | { |
@@ -644,8 +637,7 @@ discard block |
||
| 644 | 637 | if ( $destino ) |
| 645 | 638 | { |
| 646 | 639 | imagejpeg( $this->img, $destino, $qualidade ); |
| 647 | - } |
|
| 648 | - else |
|
| 640 | + } else |
|
| 649 | 641 | { |
| 650 | 642 | header( "Content-type: image/jpeg" ); |
| 651 | 643 | imagejpeg( $this->img, NULL, $qualidade ); |
@@ -657,8 +649,7 @@ discard block |
||
| 657 | 649 | if ( $destino ) |
| 658 | 650 | { |
| 659 | 651 | imagepng( $this->img, $destino ); |
| 660 | - } |
|
| 661 | - else |
|
| 652 | + } else |
|
| 662 | 653 | { |
| 663 | 654 | header( "Content-type: image/png" ); |
| 664 | 655 | imagepng( $this->img ); |
@@ -670,8 +661,7 @@ discard block |
||
| 670 | 661 | if ( $destino ) |
| 671 | 662 | { |
| 672 | 663 | imagegif( $this->img, $destino ); |
| 673 | - } |
|
| 674 | - else |
|
| 664 | + } else |
|
| 675 | 665 | { |
| 676 | 666 | header( "Content-type: image/gif" ); |
| 677 | 667 | imagegif( $this->img ); |
@@ -703,24 +693,32 @@ discard block |
||
| 703 | 693 | |
| 704 | 694 | function imagecreatefrombmp($filename) { |
| 705 | 695 | //Ouverture du fichier en mode binaire |
| 706 | - if (! $f1 = fopen($filename,"rb")) return FALSE; |
|
| 696 | + if (! $f1 = fopen($filename,"rb")) { |
|
| 697 | + return FALSE; |
|
| 698 | + } |
|
| 707 | 699 | |
| 708 | 700 | //1 : Chargement des ent?tes FICHIER |
| 709 | 701 | $FILE = unpack("vfile_type/Vfile_size/Vreserved/Vbitmap_offset", fread($f1,14)); |
| 710 | - if ($FILE['file_type'] != 19778) return FALSE; |
|
| 702 | + if ($FILE['file_type'] != 19778) { |
|
| 703 | + return FALSE; |
|
| 704 | + } |
|
| 711 | 705 | |
| 712 | 706 | //2 : Chargement des ent?tes BMP |
| 713 | 707 | $BMP = unpack('Vheader_size/Vwidth/Vheight/vplanes/vbits_per_pixel'. |
| 714 | 708 | '/Vcompression/Vsize_bitmap/Vhoriz_resolution'. |
| 715 | 709 | '/Vvert_resolution/Vcolors_used/Vcolors_important', fread($f1,40)); |
| 716 | 710 | $BMP['colors'] = pow(2,$BMP['bits_per_pixel']); |
| 717 | - if ($BMP['size_bitmap'] == 0) $BMP['size_bitmap'] = $FILE['file_size'] - $FILE['bitmap_offset']; |
|
| 711 | + if ($BMP['size_bitmap'] == 0) { |
|
| 712 | + $BMP['size_bitmap'] = $FILE['file_size'] - $FILE['bitmap_offset']; |
|
| 713 | + } |
|
| 718 | 714 | $BMP['bytes_per_pixel'] = $BMP['bits_per_pixel']/8; |
| 719 | 715 | $BMP['bytes_per_pixel2'] = ceil($BMP['bytes_per_pixel']); |
| 720 | 716 | $BMP['decal'] = ($BMP['width']*$BMP['bytes_per_pixel']/4); |
| 721 | 717 | $BMP['decal'] -= floor($BMP['width']*$BMP['bytes_per_pixel']/4); |
| 722 | 718 | $BMP['decal'] = 4-(4*$BMP['decal']); |
| 723 | - if ($BMP['decal'] == 4) $BMP['decal'] = 0; |
|
| 719 | + if ($BMP['decal'] == 4) { |
|
| 720 | + $BMP['decal'] = 0; |
|
| 721 | + } |
|
| 724 | 722 | |
| 725 | 723 | //3 : Chargement des couleurs de la palette |
| 726 | 724 | $PALETTE = array(); |
@@ -741,39 +739,49 @@ discard block |
||
| 741 | 739 | $X=0; |
| 742 | 740 | while ($X < $BMP['width']) |
| 743 | 741 | { |
| 744 | - if ($BMP['bits_per_pixel'] == 24) |
|
| 745 | - $COLOR = @unpack("V",substr($IMG,$P,3).$VIDE); |
|
| 746 | - elseif ($BMP['bits_per_pixel'] == 16) |
|
| 742 | + if ($BMP['bits_per_pixel'] == 24) { |
|
| 743 | + $COLOR = @unpack("V",substr($IMG,$P,3).$VIDE); |
|
| 744 | + } elseif ($BMP['bits_per_pixel'] == 16) |
|
| 747 | 745 | { |
| 748 | 746 | $COLOR = @unpack("n",substr($IMG,$P,2)); |
| 749 | 747 | $COLOR[1] = $PALETTE[$COLOR[1]+1]; |
| 750 | - } |
|
| 751 | - elseif ($BMP['bits_per_pixel'] == 8) |
|
| 748 | + } elseif ($BMP['bits_per_pixel'] == 8) |
|
| 752 | 749 | { |
| 753 | 750 | $COLOR = @unpack("n",$VIDE.substr($IMG,$P,1)); |
| 754 | 751 | $COLOR[1] = $PALETTE[$COLOR[1]+1]; |
| 755 | - } |
|
| 756 | - elseif ($BMP['bits_per_pixel'] == 4) |
|
| 752 | + } elseif ($BMP['bits_per_pixel'] == 4) |
|
| 757 | 753 | { |
| 758 | 754 | $COLOR = @unpack("n",$VIDE.substr($IMG,floor($P),1)); |
| 759 | - if (($P*2)%2 == 0) $COLOR[1] = ($COLOR[1] >> 4) ; else $COLOR[1] = ($COLOR[1] & 0x0F); |
|
| 755 | + if (($P*2)%2 == 0) { |
|
| 756 | + $COLOR[1] = ($COLOR[1] >> 4) ; |
|
| 757 | + } else { |
|
| 758 | + $COLOR[1] = ($COLOR[1] & 0x0F); |
|
| 759 | + } |
|
| 760 | 760 | $COLOR[1] = $PALETTE[$COLOR[1]+1]; |
| 761 | - } |
|
| 762 | - elseif ($BMP['bits_per_pixel'] == 1) |
|
| 761 | + } elseif ($BMP['bits_per_pixel'] == 1) |
|
| 763 | 762 | { |
| 764 | 763 | $COLOR = @unpack("n",$VIDE.substr($IMG,floor($P),1)); |
| 765 | - if (($P*8)%8 == 0) $COLOR[1] = $COLOR[1] >>7; |
|
| 766 | - elseif (($P*8)%8 == 1) $COLOR[1] = ($COLOR[1] & 0x40)>>6; |
|
| 767 | - elseif (($P*8)%8 == 2) $COLOR[1] = ($COLOR[1] & 0x20)>>5; |
|
| 768 | - elseif (($P*8)%8 == 3) $COLOR[1] = ($COLOR[1] & 0x10)>>4; |
|
| 769 | - elseif (($P*8)%8 == 4) $COLOR[1] = ($COLOR[1] & 0x8)>>3; |
|
| 770 | - elseif (($P*8)%8 == 5) $COLOR[1] = ($COLOR[1] & 0x4)>>2; |
|
| 771 | - elseif (($P*8)%8 == 6) $COLOR[1] = ($COLOR[1] & 0x2)>>1; |
|
| 772 | - elseif (($P*8)%8 == 7) $COLOR[1] = ($COLOR[1] & 0x1); |
|
| 764 | + if (($P*8)%8 == 0) { |
|
| 765 | + $COLOR[1] = $COLOR[1] >>7; |
|
| 766 | + } elseif (($P*8)%8 == 1) { |
|
| 767 | + $COLOR[1] = ($COLOR[1] & 0x40)>>6; |
|
| 768 | + } elseif (($P*8)%8 == 2) { |
|
| 769 | + $COLOR[1] = ($COLOR[1] & 0x20)>>5; |
|
| 770 | + } elseif (($P*8)%8 == 3) { |
|
| 771 | + $COLOR[1] = ($COLOR[1] & 0x10)>>4; |
|
| 772 | + } elseif (($P*8)%8 == 4) { |
|
| 773 | + $COLOR[1] = ($COLOR[1] & 0x8)>>3; |
|
| 774 | + } elseif (($P*8)%8 == 5) { |
|
| 775 | + $COLOR[1] = ($COLOR[1] & 0x4)>>2; |
|
| 776 | + } elseif (($P*8)%8 == 6) { |
|
| 777 | + $COLOR[1] = ($COLOR[1] & 0x2)>>1; |
|
| 778 | + } elseif (($P*8)%8 == 7) { |
|
| 779 | + $COLOR[1] = ($COLOR[1] & 0x1); |
|
| 780 | + } |
|
| 773 | 781 | $COLOR[1] = $PALETTE[$COLOR[1]+1]; |
| 782 | + } else { |
|
| 783 | + return FALSE; |
|
| 774 | 784 | } |
| 775 | - else |
|
| 776 | - return FALSE; |
|
| 777 | 785 | imagesetpixel($res,$X,$Y,$COLOR[1]); |
| 778 | 786 | $X++; |
| 779 | 787 | $P += $BMP['bytes_per_pixel']; |
@@ -79,10 +79,10 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | if ($this->Banner->save($dados)) { |
| 81 | 81 | $this->Session->setFlash('Banner editado com sucesso!','default','good'); |
| 82 | - return $this->redirect('/banner/listar_cadastros'); |
|
| 82 | + return $this->redirect('/banner/listar_cadastros'); |
|
| 83 | 83 | } else { |
| 84 | 84 | $this->Session->setFlash('Ocorreu um erro ao editar o Banner!','default','good'); |
| 85 | - return $this->redirect('/banner/listar_cadastros'); |
|
| 85 | + return $this->redirect('/banner/listar_cadastros'); |
|
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
@@ -111,10 +111,10 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | if($this->Banner->save($dados)) { |
| 113 | 113 | $this->Session->setFlash('Banner salvo com sucesso!'); |
| 114 | - return $this->redirect('/banner/listar_cadastros'); |
|
| 114 | + return $this->redirect('/banner/listar_cadastros'); |
|
| 115 | 115 | } else { |
| 116 | 116 | $this->Session->setFlash('Ocorreu um erro ao salva o banner!'); |
| 117 | - return $this->redirect('/banner/listar_cadastros'); |
|
| 117 | + return $this->redirect('/banner/listar_cadastros'); |
|
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | $oImg->redimensiona($categoriaBanner['CategoriaBanner']['width'], $categoriaBanner['CategoriaBanner']['height'], 'crop'); |
| 137 | 137 | |
| 138 | - $oImg->grava($dir . $nameImage); |
|
| 138 | + $oImg->grava($dir . $nameImage); |
|
| 139 | 139 | |
| 140 | 140 | } else { |
| 141 | 141 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -require ROOT . DS . 'app/Vendor/m2brimagem.php'; |
|
| 3 | +require ROOT.DS.'app/Vendor/m2brimagem.php'; |
|
| 4 | 4 | |
| 5 | 5 | class BannerController extends AppController { |
| 6 | 6 | |
@@ -60,12 +60,12 @@ discard block |
||
| 60 | 60 | public function s_editar_cadastro($id) { |
| 61 | 61 | $dados = $this->request->data('dados'); |
| 62 | 62 | |
| 63 | - $image = $_FILES['imagem']; |
|
| 63 | + $image = $_FILES['imagem']; |
|
| 64 | 64 | |
| 65 | - if (!empty($image['name'])) { |
|
| 65 | + if ( ! empty($image['name'])) { |
|
| 66 | 66 | $retorno = $this->uploadImage($image); |
| 67 | 67 | |
| 68 | - if (!$retorno['status']) |
|
| 68 | + if ( ! $retorno['status']) |
|
| 69 | 69 | $this->Session->setFlash('Não foi possivel salvar a imagem tente novamente'); |
| 70 | 70 | |
| 71 | 71 | $dados['imagem'] = $retorno['nome']; |
@@ -78,10 +78,10 @@ discard block |
||
| 78 | 78 | $this->Banner->id = $id; |
| 79 | 79 | |
| 80 | 80 | if ($this->Banner->save($dados)) { |
| 81 | - $this->Session->setFlash('Banner editado com sucesso!','default','good'); |
|
| 81 | + $this->Session->setFlash('Banner editado com sucesso!', 'default', 'good'); |
|
| 82 | 82 | return $this->redirect('/banner/listar_cadastros'); |
| 83 | 83 | } else { |
| 84 | - $this->Session->setFlash('Ocorreu um erro ao editar o Banner!','default','good'); |
|
| 84 | + $this->Session->setFlash('Ocorreu um erro ao editar o Banner!', 'default', 'good'); |
|
| 85 | 85 | return $this->redirect('/banner/listar_cadastros'); |
| 86 | 86 | } |
| 87 | 87 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | public function s_adicionar_cadastro() { |
| 90 | 90 | $this->loadModel('CategoriaBanner'); |
| 91 | 91 | |
| 92 | - $dados = $this->request->data('dados'); |
|
| 92 | + $dados = $this->request->data('dados'); |
|
| 93 | 93 | |
| 94 | 94 | $categoriaBanner = $this->CategoriaBanner->find('first', array( |
| 95 | 95 | 'conditions' => array( |
@@ -98,18 +98,18 @@ discard block |
||
| 98 | 98 | ) |
| 99 | 99 | ); |
| 100 | 100 | |
| 101 | - $image = $_FILES['imagem']; |
|
| 101 | + $image = $_FILES['imagem']; |
|
| 102 | 102 | |
| 103 | 103 | $retorno = $this->uploadImage($image, $categoriaBanner); |
| 104 | 104 | |
| 105 | - if (!$retorno['status']) |
|
| 105 | + if ( ! $retorno['status']) |
|
| 106 | 106 | $this->Session->setFlash('Não foi possivel salvar a imagem tente novamente'); |
| 107 | 107 | |
| 108 | 108 | $dados['src'] = $retorno['nome']; |
| 109 | 109 | $dados['usuario_id'] = $this->instancia; |
| 110 | 110 | $dados['ativo'] = 1; |
| 111 | 111 | |
| 112 | - if($this->Banner->save($dados)) { |
|
| 112 | + if ($this->Banner->save($dados)) { |
|
| 113 | 113 | $this->Session->setFlash('Banner salvo com sucesso!'); |
| 114 | 114 | return $this->redirect('/banner/listar_cadastros'); |
| 115 | 115 | } else { |
@@ -121,13 +121,13 @@ discard block |
||
| 121 | 121 | public function uploadImage(&$image, $categoriaBanner) { |
| 122 | 122 | $type = substr($image['name'], -4); |
| 123 | 123 | |
| 124 | - $nameImage = uniqid() . md5($image['name']) . $type; |
|
| 124 | + $nameImage = uniqid().md5($image['name']).$type; |
|
| 125 | 125 | |
| 126 | - $dir = APP . 'webroot/uploads/banner/imagens/'; |
|
| 126 | + $dir = APP.'webroot/uploads/banner/imagens/'; |
|
| 127 | 127 | |
| 128 | - $returnUpload = move_uploaded_file($image['tmp_name'], $dir . $nameImage); |
|
| 128 | + $returnUpload = move_uploaded_file($image['tmp_name'], $dir.$nameImage); |
|
| 129 | 129 | |
| 130 | - $oImg = new m2brimagem($dir . $nameImage); |
|
| 130 | + $oImg = new m2brimagem($dir.$nameImage); |
|
| 131 | 131 | |
| 132 | 132 | $valida = $oImg->valida(); |
| 133 | 133 | |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | $oImg->redimensiona($categoriaBanner['CategoriaBanner']['width'], $categoriaBanner['CategoriaBanner']['height'], 'crop'); |
| 137 | 137 | |
| 138 | - $oImg->grava($dir . $nameImage); |
|
| 138 | + $oImg->grava($dir.$nameImage); |
|
| 139 | 139 | |
| 140 | 140 | } else { |
| 141 | 141 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - if (!$returnUpload) |
|
| 146 | + if ( ! $returnUpload) |
|
| 147 | 147 | return array('nome' => null, 'status' => false); |
| 148 | 148 | |
| 149 | 149 | return array('nome' => $nameImage, 'status' => true); |
@@ -154,8 +154,8 @@ discard block |
||
| 154 | 154 | |
| 155 | 155 | $id = $this->request->data('id'); |
| 156 | 156 | |
| 157 | - $dados = array ('ativo' => '0'); |
|
| 158 | - $parametros = array ('id' => $id); |
|
| 157 | + $dados = array('ativo' => '0'); |
|
| 158 | + $parametros = array('id' => $id); |
|
| 159 | 159 | |
| 160 | 160 | if ($this->Banner->updateAll($dados, $parametros)) { |
| 161 | 161 | echo json_encode(true); |
@@ -1,28 +1,28 @@ 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 | |
@@ -36,10 +36,10 @@ discard block |
||
| 36 | 36 | $dados = $this->request->data('dados'); |
| 37 | 37 | |
| 38 | 38 | // Check for empty fields |
| 39 | - if(empty($dados['name']) || |
|
| 40 | - empty($dados['email']) || |
|
| 41 | - empty($dados['message']) || |
|
| 42 | - !filter_var($dados['email'], FILTER_VALIDATE_EMAIL)) { |
|
| 39 | + if (empty($dados['name']) || |
|
| 40 | + empty($dados['email']) || |
|
| 41 | + empty($dados['message']) || |
|
| 42 | + ! filter_var($dados['email'], FILTER_VALIDATE_EMAIL)) { |
|
| 43 | 43 | $this->Session->setFlash('Você deve preencher todos os dados!'); |
| 44 | 44 | return $this->redirect('/'); |
| 45 | 45 | } |
@@ -54,14 +54,14 @@ discard block |
||
| 54 | 54 | $email_body = "Mensagem site: ".$message; |
| 55 | 55 | $headers = "From: [email protected]\n"; // This is the email address the generated message will be from. We recommend using something like [email protected]. |
| 56 | 56 | $headers .= "Reply-To: $email_address"; |
| 57 | - mail($to,$email_subject,$email_body,$headers); |
|
| 57 | + mail($to, $email_subject, $email_body, $headers); |
|
| 58 | 58 | //resposta automatica ao cliente |
| 59 | 59 | $to = $email_address; |
| 60 | 60 | $email_subject = '[email protected]'; |
| 61 | 61 | $email_body = "A sua mensagem foi recebida, em breve responderemos"; |
| 62 | 62 | $headers = "From: [email protected]\n"; // This is the email address the generated message will be from. We recommend using something like [email protected]. |
| 63 | 63 | $headers .= "Reply-To: $email_address"; |
| 64 | - mail($to,$email_subject,$email_body,$headers); |
|
| 64 | + mail($to, $email_subject, $email_body, $headers); |
|
| 65 | 65 | |
| 66 | 66 | $this->Session->setFlash('Seu e-mail foi enviado com sucesso em breve responderemos!'); |
| 67 | 67 | return $this->redirect('/'); |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -require_once(ROOT . DS . 'vendor' . DS . 'autoload.php'); |
|
| 3 | +require_once(ROOT.DS.'vendor'.DS.'autoload.php'); |
|
| 4 | 4 | |
| 5 | 5 | use Dompdf\Dompdf; |
| 6 | 6 | |
| 7 | -class ProdutoController extends AppController{ |
|
| 7 | +class ProdutoController extends AppController { |
|
| 8 | 8 | |
| 9 | 9 | public function listar_cadastros() { |
| 10 | 10 | $this->layout = 'wadmin'; |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | public function listar_cadastros_ajax() { |
| 14 | 14 | $this->layout = 'ajax'; |
| 15 | 15 | |
| 16 | - $aColumns = array( 'sku', 'imagem', 'nome', 'preco', 'estoque' ); |
|
| 16 | + $aColumns = array('sku', 'imagem', 'nome', 'preco', 'estoque'); |
|
| 17 | 17 | |
| 18 | 18 | $conditions = array('conditions' => |
| 19 | 19 | array( |
@@ -24,26 +24,26 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | $allProdutos = $this->Produto->find('all', $conditions); |
| 26 | 26 | |
| 27 | - if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' ) |
|
| 27 | + if (isset($_GET['iDisplayStart']) && $_GET['iDisplayLength'] != '-1') |
|
| 28 | 28 | { |
| 29 | 29 | $conditions['offset'] = $_GET['iDisplayStart']; |
| 30 | 30 | $conditions['limit'] = $_GET['iDisplayLength']; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - if ( isset( $_GET['iSortCol_0'] ) ) |
|
| 33 | + if (isset($_GET['iSortCol_0'])) |
|
| 34 | 34 | { |
| 35 | - for ( $i=0 ; $i < intval( $_GET['iSortingCols'] ) ; $i++ ) |
|
| 35 | + for ($i = 0; $i < intval($_GET['iSortingCols']); $i++) |
|
| 36 | 36 | { |
| 37 | - if ( $_GET[ 'bSortable_' . intval($_GET['iSortCol_' . $i]) ] == "true" ) |
|
| 37 | + if ($_GET['bSortable_'.intval($_GET['iSortCol_'.$i])] == "true") |
|
| 38 | 38 | { |
| 39 | - $conditions['order'] = array('Produto.' . $aColumns[intval($_GET['iSortCol_' . $i])] => $_GET['sSortDir_'.$i]); |
|
| 39 | + $conditions['order'] = array('Produto.'.$aColumns[intval($_GET['iSortCol_'.$i])] => $_GET['sSortDir_'.$i]); |
|
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - if ( isset( $_GET['sSearch'] ) && !empty( $_GET['sSearch'] ) ) |
|
| 44 | + if (isset($_GET['sSearch']) && ! empty($_GET['sSearch'])) |
|
| 45 | 45 | { |
| 46 | - $conditions['conditions']['Produto.nome LIKE '] = '%' . $_GET['sSearch'] . '%'; |
|
| 46 | + $conditions['conditions']['Produto.nome LIKE '] = '%'.$_GET['sSearch'].'%'; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | $produtos = $this->Produto->find('all', $conditions); |
@@ -55,19 +55,19 @@ discard block |
||
| 55 | 55 | "aaData" => array() |
| 56 | 56 | ); |
| 57 | 57 | |
| 58 | - foreach ( $produtos as $i => $produto ) |
|
| 58 | + foreach ($produtos as $i => $produto) |
|
| 59 | 59 | { |
| 60 | 60 | $row = array(); |
| 61 | 61 | |
| 62 | - for ( $i=0 ; $i < count($aColumns) ; $i++ ) |
|
| 62 | + for ($i = 0; $i < count($aColumns); $i++) |
|
| 63 | 63 | { |
| 64 | 64 | $value = $produto['Produto'][$aColumns[$i]]; |
| 65 | 65 | |
| 66 | 66 | if ($aColumns[$i] == "imagem") |
| 67 | 67 | { |
| 68 | - $value = '<img src="/uploads/produto/imagens/' . $produto['Produto'][$aColumns[$i]] . '" width="120" height="120">'; |
|
| 68 | + $value = '<img src="/uploads/produto/imagens/'.$produto['Produto'][$aColumns[$i]].'" width="120" height="120">'; |
|
| 69 | 69 | |
| 70 | - if (!isset($produto['Produto'][$aColumns[$i]]) || empty($produto['Produto'][$aColumns[$i]])) |
|
| 70 | + if ( ! isset($produto['Produto'][$aColumns[$i]]) || empty($produto['Produto'][$aColumns[$i]])) |
|
| 71 | 71 | { |
| 72 | 72 | $value = '<img src="/images/no_image.png" width="120" height="120">'; |
| 73 | 73 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $row[] = $value; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - $btEdit = '<a class="btn btn-info" href="/produto/editar_cadastro/' . $produto['Produto']['id'] . '"><i class="fa fa-pencil"></i></a>'; |
|
| 79 | + $btEdit = '<a class="btn btn-info" href="/produto/editar_cadastro/'.$produto['Produto']['id'].'"><i class="fa fa-pencil"></i></a>'; |
|
| 80 | 80 | |
| 81 | 81 | $row[] = $btEdit; |
| 82 | 82 | |
@@ -87,15 +87,15 @@ discard block |
||
| 87 | 87 | exit; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - public function listar_cadastros_estoque_minimo(){ |
|
| 90 | + public function listar_cadastros_estoque_minimo() { |
|
| 91 | 91 | $this->layout = 'wadmin'; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - public function listar_cadastros_estoque_minimo_ajax(){ |
|
| 94 | + public function listar_cadastros_estoque_minimo_ajax() { |
|
| 95 | 95 | |
| 96 | 96 | $this->layout = 'ajax'; |
| 97 | 97 | |
| 98 | - $aColumns = array( 'sku', 'imagem', 'nome', 'preco', 'estoque' ); |
|
| 98 | + $aColumns = array('sku', 'imagem', 'nome', 'preco', 'estoque'); |
|
| 99 | 99 | |
| 100 | 100 | $this->loadModel('Usuario'); |
| 101 | 101 | |
@@ -117,30 +117,30 @@ discard block |
||
| 117 | 117 | ) |
| 118 | 118 | ); |
| 119 | 119 | |
| 120 | - $allProdutos = $this->Produto->query("select * from produtos where estoque < quantidade_minima and id_usuario = " . $this->instancia . " and ativo = 1"); |
|
| 120 | + $allProdutos = $this->Produto->query("select * from produtos where estoque < quantidade_minima and id_usuario = ".$this->instancia." and ativo = 1"); |
|
| 121 | 121 | |
| 122 | 122 | |
| 123 | - $sql = "select * from produtos as Produto where estoque < quantidade_minima and id_usuario = " . $this->instancia . " and ativo = 1"; |
|
| 123 | + $sql = "select * from produtos as Produto where estoque < quantidade_minima and id_usuario = ".$this->instancia." and ativo = 1"; |
|
| 124 | 124 | |
| 125 | - if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' ) |
|
| 125 | + if (isset($_GET['iDisplayStart']) && $_GET['iDisplayLength'] != '-1') |
|
| 126 | 126 | { |
| 127 | - $sql .= ' LIMIT ' . $_GET['iDisplayLength'] . ' OFFSET ' . $_GET['iDisplayStart']; |
|
| 127 | + $sql .= ' LIMIT '.$_GET['iDisplayLength'].' OFFSET '.$_GET['iDisplayStart']; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - if ( isset( $_GET['iSortCol_0'] ) ) |
|
| 130 | + if (isset($_GET['iSortCol_0'])) |
|
| 131 | 131 | { |
| 132 | - for ( $i=0 ; $i < intval( $_GET['iSortingCols'] ) ; $i++ ) |
|
| 132 | + for ($i = 0; $i < intval($_GET['iSortingCols']); $i++) |
|
| 133 | 133 | { |
| 134 | - if ( $_GET[ 'bSortable_' . intval($_GET['iSortCol_' . $i]) ] == "true" ) |
|
| 134 | + if ($_GET['bSortable_'.intval($_GET['iSortCol_'.$i])] == "true") |
|
| 135 | 135 | { |
| 136 | - $conditions['order'] = array('Produto.' . $aColumns[intval($_GET['iSortCol_' . $i])] => $_GET['sSortDir_'.$i]); |
|
| 136 | + $conditions['order'] = array('Produto.'.$aColumns[intval($_GET['iSortCol_'.$i])] => $_GET['sSortDir_'.$i]); |
|
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if ( isset( $_GET['sSearch'] ) && !empty( $_GET['sSearch'] ) ) |
|
| 141 | + if (isset($_GET['sSearch']) && ! empty($_GET['sSearch'])) |
|
| 142 | 142 | { |
| 143 | - $conditions['conditions']['Produto.nome LIKE '] = '%' . $_GET['sSearch'] . '%'; |
|
| 143 | + $conditions['conditions']['Produto.nome LIKE '] = '%'.$_GET['sSearch'].'%'; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | $produtos = $this->Produto->query($sql); |
@@ -152,19 +152,19 @@ discard block |
||
| 152 | 152 | "aaData" => array() |
| 153 | 153 | ); |
| 154 | 154 | |
| 155 | - foreach ( $produtos as $i => $produto ) |
|
| 155 | + foreach ($produtos as $i => $produto) |
|
| 156 | 156 | { |
| 157 | 157 | $row = array(); |
| 158 | 158 | |
| 159 | - for ( $i=0 ; $i < count($aColumns) ; $i++ ) |
|
| 159 | + for ($i = 0; $i < count($aColumns); $i++) |
|
| 160 | 160 | { |
| 161 | 161 | $value = $produto['Produto'][$aColumns[$i]]; |
| 162 | 162 | |
| 163 | 163 | if ($aColumns[$i] == "imagem") |
| 164 | 164 | { |
| 165 | - $value = '<img src="/uploads/produto/imagens/' . $produto['Produto'][$aColumns[$i]] . '" width="120" height="120">'; |
|
| 165 | + $value = '<img src="/uploads/produto/imagens/'.$produto['Produto'][$aColumns[$i]].'" width="120" height="120">'; |
|
| 166 | 166 | |
| 167 | - if (!isset($produto['Produto'][$aColumns[$i]]) || empty($produto['Produto'][$aColumns[$i]])) |
|
| 167 | + if ( ! isset($produto['Produto'][$aColumns[$i]]) || empty($produto['Produto'][$aColumns[$i]])) |
|
| 168 | 168 | { |
| 169 | 169 | $value = '<img src="/images/no_image.png" width="120" height="120">'; |
| 170 | 170 | } |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | ) |
| 205 | 205 | ); |
| 206 | 206 | |
| 207 | - $produtos = $this->Produto->query("select * from produtos as Produto where estoque < quantidade_minima and id_usuario = " . $this->instancia . " and ativo = 1"); |
|
| 207 | + $produtos = $this->Produto->query("select * from produtos as Produto where estoque < quantidade_minima and id_usuario = ".$this->instancia." and ativo = 1"); |
|
| 208 | 208 | |
| 209 | 209 | $html = $this->getProdutosEstoqueMinimoComoHtml($produtos); |
| 210 | 210 | |
@@ -259,9 +259,9 @@ discard block |
||
| 259 | 259 | |
| 260 | 260 | foreach ($produtos as $i => $produto) { |
| 261 | 261 | $html .= ' <tr>'; |
| 262 | - $html .= ' <td>' . $produto['Produto']['nome'] . '</td>'; |
|
| 263 | - $html .= ' <td>' . $produto['Produto']['estoque'] . '</td>'; |
|
| 264 | - $html .= ' <td>R$ ' . number_format($produto['Produto']['custo'], 2, ',', '.') . '</td>'; |
|
| 262 | + $html .= ' <td>'.$produto['Produto']['nome'].'</td>'; |
|
| 263 | + $html .= ' <td>'.$produto['Produto']['estoque'].'</td>'; |
|
| 264 | + $html .= ' <td>R$ '.number_format($produto['Produto']['custo'], 2, ',', '.').'</td>'; |
|
| 265 | 265 | $html .= ' </tr>'; |
| 266 | 266 | } |
| 267 | 267 | |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | $html .= ''; |
| 274 | 274 | $html .= '</body>'; |
| 275 | 275 | $html .= '</html>'; |
| 276 | - echo $html;exit; |
|
| 276 | + echo $html; exit; |
|
| 277 | 277 | return $html; |
| 278 | 278 | } |
| 279 | 279 | |
@@ -293,15 +293,15 @@ discard block |
||
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | public function s_adicionar_cadastro() { |
| 296 | - $dados = $this->request->data('dados'); |
|
| 296 | + $dados = $this->request->data('dados'); |
|
| 297 | 297 | |
| 298 | 298 | $variacoes = $this->request->data('variacao'); |
| 299 | 299 | |
| 300 | - $image = $_FILES['imagem']; |
|
| 300 | + $image = $_FILES['imagem']; |
|
| 301 | 301 | |
| 302 | 302 | $retorno = $this->uploadImage($image); |
| 303 | 303 | |
| 304 | - if (!$retorno['status']) |
|
| 304 | + if ( ! $retorno['status']) |
|
| 305 | 305 | $this->Session->setFlash('Não foi possivel salvar a imagem tente novamente'); |
| 306 | 306 | |
| 307 | 307 | $dados['imagem'] = $retorno['nome']; |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | $dados['ativo'] = 1; |
| 310 | 310 | $dados['id_alias'] = $this->id_alias(); |
| 311 | 311 | |
| 312 | - if($this->Produto->save($dados)) { |
|
| 312 | + if ($this->Produto->save($dados)) { |
|
| 313 | 313 | $produto_id = $this->Produto->getLastInsertId(); |
| 314 | 314 | |
| 315 | 315 | require 'VariacaoController.php'; |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | $objPluggTo = new PluggtoController(); |
| 325 | 325 | $produto_pluggto = $objPluggTo->enviar_produto($dados, $variacoes); |
| 326 | 326 | |
| 327 | - if (!isset($produto_pluggto->Product->id)) |
|
| 327 | + if ( ! isset($produto_pluggto->Product->id)) |
|
| 328 | 328 | { |
| 329 | 329 | $this->Session->setFlash('Produto não foi enviado para o Plugg.to!'); |
| 330 | 330 | } |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | |
| 346 | 346 | $this->loadModel('Variacao'); |
| 347 | 347 | |
| 348 | - $query = array ( |
|
| 348 | + $query = array( |
|
| 349 | 349 | 'joins' => array( |
| 350 | 350 | array( |
| 351 | 351 | 'table' => 'produtos', |
@@ -388,12 +388,12 @@ discard block |
||
| 388 | 388 | |
| 389 | 389 | $variacoes = $this->request->data('variacao'); |
| 390 | 390 | |
| 391 | - $image = $_FILES['imagem']; |
|
| 391 | + $image = $_FILES['imagem']; |
|
| 392 | 392 | |
| 393 | - if (!empty($image['name'])) { |
|
| 393 | + if ( ! empty($image['name'])) { |
|
| 394 | 394 | $retorno = $this->uploadImage($image); |
| 395 | 395 | |
| 396 | - if (!$retorno['status']) |
|
| 396 | + if ( ! $retorno['status']) |
|
| 397 | 397 | $this->Session->setFlash('Não foi possivel salvar a imagem tente novamente'); |
| 398 | 398 | |
| 399 | 399 | $dados['imagem'] = $retorno['nome']; |
@@ -413,10 +413,10 @@ discard block |
||
| 413 | 413 | $objVariacaoController->desativar_variacoes($id); |
| 414 | 414 | $objVariacaoController->s_adicionar_variacao($variacoes, $id, $this->instancia); |
| 415 | 415 | |
| 416 | - $this->Session->setFlash('Produto editado com sucesso!','default','good'); |
|
| 416 | + $this->Session->setFlash('Produto editado com sucesso!', 'default', 'good'); |
|
| 417 | 417 | return $this->redirect('/produto/listar_cadastros'); |
| 418 | 418 | } else { |
| 419 | - $this->Session->setFlash('Ocorreu um erro ao editar o produto!','default','good'); |
|
| 419 | + $this->Session->setFlash('Ocorreu um erro ao editar o produto!', 'default', 'good'); |
|
| 420 | 420 | return $this->redirect('/produto/listar_cadastros'); |
| 421 | 421 | } |
| 422 | 422 | } |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | ) |
| 459 | 459 | ); |
| 460 | 460 | |
| 461 | - if (!$this->validar_estoque($retorno)) { |
|
| 461 | + if ( ! $this->validar_estoque($retorno)) { |
|
| 462 | 462 | return false; |
| 463 | 463 | } |
| 464 | 464 | |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | if ($user_active[0]['Usuario']['sale_without_stock']) |
| 489 | 489 | return true; |
| 490 | 490 | |
| 491 | - if (empty($produto) && !isset($produto)) { |
|
| 491 | + if (empty($produto) && ! isset($produto)) { |
|
| 492 | 492 | return false; |
| 493 | 493 | } |
| 494 | 494 | |
@@ -500,11 +500,11 @@ discard block |
||
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | public function calcular_preco_produto_venda($preco, $qnt) { |
| 503 | - if (empty($preco) || !isset($preco)) { |
|
| 503 | + if (empty($preco) || ! isset($preco)) { |
|
| 504 | 504 | return false; |
| 505 | 505 | } |
| 506 | 506 | |
| 507 | - if (!is_numeric($qnt)) { |
|
| 507 | + if ( ! is_numeric($qnt)) { |
|
| 508 | 508 | return false; |
| 509 | 509 | } |
| 510 | 510 | |
@@ -515,12 +515,12 @@ discard block |
||
| 515 | 515 | |
| 516 | 516 | public function uploadImage(&$image) { |
| 517 | 517 | $type = substr($image['name'], -4); |
| 518 | - $nameImage = uniqid() . md5($image['name']) . $type; |
|
| 519 | - $dir = APP . 'webroot/uploads/produto/imagens/'; |
|
| 518 | + $nameImage = uniqid().md5($image['name']).$type; |
|
| 519 | + $dir = APP.'webroot/uploads/produto/imagens/'; |
|
| 520 | 520 | |
| 521 | - $returnUpload = move_uploaded_file($image['tmp_name'], $dir . $nameImage); |
|
| 521 | + $returnUpload = move_uploaded_file($image['tmp_name'], $dir.$nameImage); |
|
| 522 | 522 | |
| 523 | - if (!$returnUpload) |
|
| 523 | + if ( ! $returnUpload) |
|
| 524 | 524 | return array('nome' => null, 'status' => false); |
| 525 | 525 | |
| 526 | 526 | return array('nome' => $nameImage, 'status' => true); |
@@ -546,8 +546,8 @@ discard block |
||
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | public function exportar_excel_exemplo() { |
| 549 | - include(APP . 'Vendor/PHPExcel/PHPExcel.php'); |
|
| 550 | - include(APP . 'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
| 549 | + include(APP.'Vendor/PHPExcel/PHPExcel.php'); |
|
| 550 | + include(APP.'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
| 551 | 551 | |
| 552 | 552 | $objPHPExcel = new PHPExcel(); |
| 553 | 553 | // Definimos o estilo da fonte |
@@ -584,7 +584,7 @@ discard block |
||
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | public function importar_produtos_planilha() { |
| 587 | - if (!isset($_FILES['arquivo']['tmp_name']) && empty($_FILES['arquivo']['tmp_name'])) |
|
| 587 | + if ( ! isset($_FILES['arquivo']['tmp_name']) && empty($_FILES['arquivo']['tmp_name'])) |
|
| 588 | 588 | { |
| 589 | 589 | $this->Session->setFlash("Erro ao subir a planilha, tente novamente."); |
| 590 | 590 | $this->redirect("/produto/listar_cadastros"); |
@@ -592,13 +592,13 @@ discard block |
||
| 592 | 592 | |
| 593 | 593 | $typesPermissions = ['application/vnd.ms-excel']; |
| 594 | 594 | |
| 595 | - if (!in_array($_FILES['arquivo']['type'], $typesPermissions)) |
|
| 595 | + if ( ! in_array($_FILES['arquivo']['type'], $typesPermissions)) |
|
| 596 | 596 | { |
| 597 | 597 | $this->Session->setFlash("O arquivo deve ser no formato .xls."); |
| 598 | 598 | $this->redirect("/produto/listar_cadastros"); |
| 599 | 599 | } |
| 600 | 600 | |
| 601 | - $caminho = APP . 'webroot/uploads/produto/planilhas/' . uniqid() . '.xls'; |
|
| 601 | + $caminho = APP.'webroot/uploads/produto/planilhas/'.uniqid().'.xls'; |
|
| 602 | 602 | |
| 603 | 603 | $inputFileName = $_FILES['arquivo']['tmp_name']; |
| 604 | 604 | |
@@ -639,17 +639,17 @@ discard block |
||
| 639 | 639 | } |
| 640 | 640 | |
| 641 | 641 | public function processar_planilhas($inputFileName, $usuarioId, $planilhaId) { |
| 642 | - include(APP . 'Vendor/PHPExcel/PHPExcel.php'); |
|
| 643 | - include(APP . 'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
| 642 | + include(APP.'Vendor/PHPExcel/PHPExcel.php'); |
|
| 643 | + include(APP.'Vendor/PHPExcel/PHPExcel/IOFactory.php'); |
|
| 644 | 644 | |
| 645 | 645 | $objPHPExcel = new PHPExcel(); |
| 646 | 646 | |
| 647 | 647 | try { |
| 648 | - $inputFileType = PHPExcel_IOFactory::identify($inputFileName); |
|
| 649 | - $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
|
| 650 | - $objPHPExcel = $objReader->load($inputFileName); |
|
| 651 | - } catch(Exception $e) { |
|
| 652 | - die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage()); |
|
| 648 | + $inputFileType = PHPExcel_IOFactory::identify($inputFileName); |
|
| 649 | + $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
|
| 650 | + $objPHPExcel = $objReader->load($inputFileName); |
|
| 651 | + } catch (Exception $e) { |
|
| 652 | + die('Error loading file "'.pathinfo($inputFileName, PATHINFO_BASENAME).'": '.$e->getMessage()); |
|
| 653 | 653 | } |
| 654 | 654 | |
| 655 | 655 | $dados = []; |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | |
| 697 | 697 | $errors = $this->processar_lista_produtos($dados); |
| 698 | 698 | |
| 699 | - if (isset($errors) && !empty($errors)) |
|
| 699 | + if (isset($errors) && ! empty($errors)) |
|
| 700 | 700 | { |
| 701 | 701 | $this->QueueProduct->planilhaProcessedIncomplete($planilhaId); |
| 702 | 702 | } |
@@ -722,7 +722,7 @@ discard block |
||
| 722 | 722 | ) |
| 723 | 723 | ); |
| 724 | 724 | |
| 725 | - if (isset($existProduto) && !empty($existProduto)) |
|
| 725 | + if (isset($existProduto) && ! empty($existProduto)) |
|
| 726 | 726 | { |
| 727 | 727 | $this->Produto->id = $existProduto[0]['Produto']['id']; |
| 728 | 728 | $this->Produto->save($dado); |
@@ -731,7 +731,7 @@ discard block |
||
| 731 | 731 | |
| 732 | 732 | $this->Produto->create(); |
| 733 | 733 | |
| 734 | - if (!$this->Produto->save($dado)) |
|
| 734 | + if ( ! $this->Produto->save($dado)) |
|
| 735 | 735 | { |
| 736 | 736 | $errors[] = $dado; |
| 737 | 737 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | if (isset($dados['id'])) |
| 33 | 33 | $this->PluggtoConfiguracoes->id = $dados['id']; |
| 34 | 34 | |
| 35 | - if (!$this->PluggtoConfiguracoes->save($dados)) |
|
| 35 | + if ( ! $this->PluggtoConfiguracoes->save($dados)) |
|
| 36 | 36 | { |
| 37 | 37 | $this->Session->setFlash("Ocorreu um erro ao salvar as configurações."); |
| 38 | 38 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $PluggProduct->name = $dados['nome']; |
| 71 | 71 | $PluggProduct->photos = [ |
| 72 | 72 | [ |
| 73 | - 'url' => 'http://www.ciawn.com.br/uploads/produto/imagens/' . $dados['imagem'] |
|
| 73 | + 'url' => 'http://www.ciawn.com.br/uploads/produto/imagens/'.$dados['imagem'] |
|
| 74 | 74 | ] |
| 75 | 75 | ]; |
| 76 | 76 | $PluggProduct->sku = $dados['sku']; |
@@ -29,8 +29,9 @@ |
||
| 29 | 29 | |
| 30 | 30 | $dados['usuario_id'] = $this->instancia; |
| 31 | 31 | |
| 32 | - if (isset($dados['id'])) |
|
| 33 | - $this->PluggtoConfiguracoes->id = $dados['id']; |
|
| 32 | + if (isset($dados['id'])) { |
|
| 33 | + $this->PluggtoConfiguracoes->id = $dados['id']; |
|
| 34 | + } |
|
| 34 | 35 | |
| 35 | 36 | if (!$this->PluggtoConfiguracoes->save($dados)) |
| 36 | 37 | { |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | if (count($resposta) < 1) { |
| 32 | 32 | $this->Session->setFlash('Ocorreu um erro ao logar na sua conta, verifique seus dados!'); |
| 33 | - return $this->redirect('/home/login'); |
|
| 33 | + return $this->redirect('/home/login'); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | //faz o foreach com o array de dados do usuario |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $this->Session->setFlash('Bem vindo, '.$this->Session->read('Usuario.nome').'!'); |
| 49 | - return $this->redirect('/dashboard/home'); |
|
| 49 | + return $this->redirect('/dashboard/home'); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | public function processar_logout() { |
@@ -214,12 +214,12 @@ discard block |
||
| 214 | 214 | if(!$retorno) { |
| 215 | 215 | $this->Session->setFlash('Ocorreu um erro ao salvar as novas infomações, tente novamente!'); |
| 216 | 216 | |
| 217 | - return $this->redirect('/usuario/meus_dados'); |
|
| 217 | + return $this->redirect('/usuario/meus_dados'); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | $this->Session->setFlash('Dados atualizados com sucesso!'); |
| 221 | 221 | |
| 222 | - return $this->redirect('/usuario/meus_dados'); |
|
| 222 | + return $this->redirect('/usuario/meus_dados'); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | public function meus_dados() { |
@@ -234,8 +234,8 @@ discard block |
||
| 234 | 234 | ) |
| 235 | 235 | ); |
| 236 | 236 | |
| 237 | - $this->set('modulos', $this->modulos); |
|
| 238 | - $this->set('usuario', $dadosUsuario); |
|
| 237 | + $this->set('modulos', $this->modulos); |
|
| 238 | + $this->set('usuario', $dadosUsuario); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | public function new_token() { |
@@ -269,27 +269,27 @@ discard block |
||
| 269 | 269 | |
| 270 | 270 | if ($abriu === true) { |
| 271 | 271 | |
| 272 | - // Listando os nomes dos elementos |
|
| 273 | - for ($i = 0; $i < $z->numFiles; $i++) { |
|
| 272 | + // Listando os nomes dos elementos |
|
| 273 | + for ($i = 0; $i < $z->numFiles; $i++) { |
|
| 274 | 274 | |
| 275 | - $nome = $z->getNameIndex($i); |
|
| 275 | + $nome = $z->getNameIndex($i); |
|
| 276 | 276 | |
| 277 | - $response = $z->extractTo(ROOT . DS . "app/View/"); |
|
| 277 | + $response = $z->extractTo(ROOT . DS . "app/View/"); |
|
| 278 | 278 | |
| 279 | - } |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | - // Fechando o arquivo |
|
| 281 | + // Fechando o arquivo |
|
| 282 | 282 | |
| 283 | - $z->close(); |
|
| 283 | + $z->close(); |
|
| 284 | 284 | |
| 285 | 285 | } else { |
| 286 | - echo 'Erro: ' . $abriu; |
|
| 286 | + echo 'Erro: ' . $abriu; |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - $nomeLayout = substr($template['name'], 0, -4); |
|
| 289 | + $nomeLayout = substr($template['name'], 0, -4); |
|
| 290 | 290 | |
| 291 | - $origem = ROOT . DS . "app/View/" . $nomeLayout . DS . "Layouts" . DS . $nomeLayout . ".ctp"; |
|
| 292 | - $destino = ROOT . DS . "app/View/" . "Layouts" . DS . $nomeLayout . ".ctp"; |
|
| 291 | + $origem = ROOT . DS . "app/View/" . $nomeLayout . DS . "Layouts" . DS . $nomeLayout . ".ctp"; |
|
| 292 | + $destino = ROOT . DS . "app/View/" . "Layouts" . DS . $nomeLayout . ".ctp"; |
|
| 293 | 293 | |
| 294 | 294 | shell_exec("mv " . $origem . " " . $destino); |
| 295 | 295 | |
@@ -1,16 +1,16 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class UsuarioController extends AppController{ |
|
| 4 | - public function beforeFilter(){ |
|
| 3 | +class UsuarioController extends AppController { |
|
| 4 | + public function beforeFilter() { |
|
| 5 | 5 | return true; |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | //faz o login no sistema, com a função autentica_email |
| 9 | - public function login(){ |
|
| 10 | - $this->layout = 'ajax';//chama o layout para executar uma função ajax |
|
| 9 | + public function login() { |
|
| 10 | + $this->layout = 'ajax'; //chama o layout para executar uma função ajax |
|
| 11 | 11 | |
| 12 | - $login_email = $this->request->data['email'];//recebe o post email |
|
| 13 | - $login_senha = $this->request->data['senha'];//recebe o post senha |
|
| 12 | + $login_email = $this->request->data['email']; //recebe o post email |
|
| 13 | + $login_senha = $this->request->data['senha']; //recebe o post senha |
|
| 14 | 14 | echo json_encode(true); |
| 15 | 15 | } |
| 16 | 16 | |
@@ -34,15 +34,15 @@ discard block |
||
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | //faz o foreach com o array de dados do usuario |
| 37 | - foreach($resposta as $valor) { |
|
| 37 | + foreach ($resposta as $valor) { |
|
| 38 | 38 | //escreve a sessao do usuario |
| 39 | - $this->Session->write('Usuario.id', $valor['Usuario']['id']); |
|
| 40 | - $this->Session->write('Usuario.nome', $valor['Usuario']['nome']);//nome do usuario |
|
| 41 | - $this->Session->write('Usuario.email',$valor['Usuario']['email']);//email do usuario |
|
| 42 | - $this->Session->write('Usuario.senha',$valor['Usuario']['senha']);//senha do usuario criptografada |
|
| 43 | - $this->Session->write('Usuario.erp', $valor['Usuario']['erp']);//situacao ativa(1) ou nao(0) no erp |
|
| 44 | - $this->Session->write('Usuario.ead', $valor['Usuario']['ead']);//situacao ativa(1) ou nao(0) no ead |
|
| 45 | - $this->Session->write('Usuario.site', $valor['Usuario']['site']);//situacao ativa(1) ou nao(0) no site |
|
| 39 | + $this->Session->write('Usuario.id', $valor['Usuario']['id']); |
|
| 40 | + $this->Session->write('Usuario.nome', $valor['Usuario']['nome']); //nome do usuario |
|
| 41 | + $this->Session->write('Usuario.email', $valor['Usuario']['email']); //email do usuario |
|
| 42 | + $this->Session->write('Usuario.senha', $valor['Usuario']['senha']); //senha do usuario criptografada |
|
| 43 | + $this->Session->write('Usuario.erp', $valor['Usuario']['erp']); //situacao ativa(1) ou nao(0) no erp |
|
| 44 | + $this->Session->write('Usuario.ead', $valor['Usuario']['ead']); //situacao ativa(1) ou nao(0) no ead |
|
| 45 | + $this->Session->write('Usuario.site', $valor['Usuario']['site']); //situacao ativa(1) ou nao(0) no site |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $this->Session->setFlash('Bem vindo, '.$this->Session->read('Usuario.nome').'!'); |
@@ -54,14 +54,14 @@ discard block |
||
| 54 | 54 | return $this->redirect('/home/login'); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - public function logout(){ |
|
| 57 | + public function logout() { |
|
| 58 | 58 | $this->Session->Destroy(); |
| 59 | 59 | |
| 60 | 60 | echo '<script>location.href="/winners/framework/"</script>'; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | //autentica email verifica se o email e senha existem para efetuar o login, ou outra acao. |
| 64 | - public function autentica_email($email,$senha){ |
|
| 64 | + public function autentica_email($email, $senha) { |
|
| 65 | 65 | $this->loadModel('Usuario'); |
| 66 | 66 | $resposta = $this->Usuario->find('count', |
| 67 | 67 | array('conditions' => array('AND' => array('Usuario.email' => $email, 'Usuario.senha' => sha1($senha)) |
@@ -74,10 +74,10 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | //se o email estiver livre retorna false, senão retorna true |
| 77 | - public function verificar_email($email){ |
|
| 77 | + public function verificar_email($email) { |
|
| 78 | 78 | $this->layout = 'ajax'; |
| 79 | 79 | |
| 80 | - if(empty($email)){ |
|
| 80 | + if (empty($email)) { |
|
| 81 | 81 | $email = $this->request->data['email']; |
| 82 | 82 | } |
| 83 | 83 | |
@@ -87,14 +87,14 @@ discard block |
||
| 87 | 87 | ); |
| 88 | 88 | $this->set('resposta', $resposta); |
| 89 | 89 | |
| 90 | - if($resposta >= 1){ |
|
| 90 | + if ($resposta >= 1) { |
|
| 91 | 91 | return true; |
| 92 | - }else{ |
|
| 92 | + } else { |
|
| 93 | 93 | return false; |
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - public function recuperar_dados($email,$senha){ |
|
| 97 | + public function recuperar_dados($email, $senha) { |
|
| 98 | 98 | $this->loadModel('Usuario'); |
| 99 | 99 | $resposta = $this->Usuario->find('all', |
| 100 | 100 | array('conditions' => array('AND' => array('Usuario.email' => $email, 'Usuario.senha' => sha1($senha)) |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | public function notificar_cadastro($nome, $email) { |
| 144 | 144 | $headers = "From: [email protected]\n"; // This is the email address the generated message will be from. We recommend using something like [email protected]. |
| 145 | 145 | $headers .= "Reply-To: $email_address"; |
| 146 | - mail('[email protected], [email protected], [email protected], [email protected]', 'Notificação de cadastro', 'O usuario ' . $nome . ' email ' . $email . ' ', $headers); |
|
| 146 | + mail('[email protected], [email protected], [email protected], [email protected]', 'Notificação de cadastro', 'O usuario '.$nome.' email '.$email.' ', $headers); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | public function relacionar_modulos_teste($id) { |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | |
| 191 | 191 | $layout_loja = $this->request->data['layout_loja']; |
| 192 | 192 | |
| 193 | - if (!empty($template['name']) && isset($template['name'])) |
|
| 193 | + if ( ! empty($template['name']) && isset($template['name'])) |
|
| 194 | 194 | $layout_loja = $this->uploadZipTemplate($template); |
| 195 | 195 | |
| 196 | 196 | $data = array( |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | 'sale_without_stock' => $sale_without_stock, |
| 199 | 199 | 'loja_active' => $this->request->data['loja_active'], |
| 200 | 200 | 'loja' => $this->request->data['loja'], |
| 201 | - 'layout_loja' => $layout_loja , |
|
| 201 | + 'layout_loja' => $layout_loja, |
|
| 202 | 202 | 'cep_origem' => $this->request->data['cep_origem'], |
| 203 | 203 | 'descricao' => $this->request->data['descricao'], |
| 204 | 204 | 'token_pagseguro' => $this->request->data['token_pagseguro'], |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | |
| 212 | 212 | $retorno = $this->Usuario->save($data); |
| 213 | 213 | |
| 214 | - if(!$retorno) { |
|
| 214 | + if ( ! $retorno) { |
|
| 215 | 215 | $this->Session->setFlash('Ocorreu um erro ao salvar as novas infomações, tente novamente!'); |
| 216 | 216 | |
| 217 | 217 | return $this->redirect('/usuario/meus_dados'); |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | |
| 275 | 275 | $nome = $z->getNameIndex($i); |
| 276 | 276 | |
| 277 | - $response = $z->extractTo(ROOT . DS . "app/View/"); |
|
| 277 | + $response = $z->extractTo(ROOT.DS."app/View/"); |
|
| 278 | 278 | |
| 279 | 279 | } |
| 280 | 280 | |
@@ -283,17 +283,17 @@ discard block |
||
| 283 | 283 | $z->close(); |
| 284 | 284 | |
| 285 | 285 | } else { |
| 286 | - echo 'Erro: ' . $abriu; |
|
| 286 | + echo 'Erro: '.$abriu; |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | $nomeLayout = substr($template['name'], 0, -4); |
| 290 | 290 | |
| 291 | - $origem = ROOT . DS . "app/View/" . $nomeLayout . DS . "Layouts" . DS . $nomeLayout . ".ctp"; |
|
| 292 | - $destino = ROOT . DS . "app/View/" . "Layouts" . DS . $nomeLayout . ".ctp"; |
|
| 291 | + $origem = ROOT.DS."app/View/".$nomeLayout.DS."Layouts".DS.$nomeLayout.".ctp"; |
|
| 292 | + $destino = ROOT.DS."app/View/"."Layouts".DS.$nomeLayout.".ctp"; |
|
| 293 | 293 | |
| 294 | - shell_exec("mv " . $origem . " " . $destino); |
|
| 294 | + shell_exec("mv ".$origem." ".$destino); |
|
| 295 | 295 | |
| 296 | - shell_exec("rm -R " . ROOT . DS . "app/View/" . $nomeLayout . "Layouts/"); |
|
| 296 | + shell_exec("rm -R ".ROOT.DS."app/View/".$nomeLayout."Layouts/"); |
|
| 297 | 297 | |
| 298 | 298 | return $nomeLayout; |
| 299 | 299 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | if($resposta >= 1){ |
| 91 | 91 | return true; |
| 92 | - }else{ |
|
| 92 | + } else{ |
|
| 93 | 93 | return false; |
| 94 | 94 | } |
| 95 | 95 | } |
@@ -190,8 +190,9 @@ discard block |
||
| 190 | 190 | |
| 191 | 191 | $layout_loja = $this->request->data['layout_loja']; |
| 192 | 192 | |
| 193 | - if (!empty($template['name']) && isset($template['name'])) |
|
| 194 | - $layout_loja = $this->uploadZipTemplate($template); |
|
| 193 | + if (!empty($template['name']) && isset($template['name'])) { |
|
| 194 | + $layout_loja = $this->uploadZipTemplate($template); |
|
| 195 | + } |
|
| 195 | 196 | |
| 196 | 197 | $data = array( |
| 197 | 198 | 'estoque_minimo' => $estoque_minimo, |
@@ -5,26 +5,26 @@ |
||
| 5 | 5 | |
| 6 | 6 | Router::connect('/:loja/produto/:id', array('controller' => 'loja', 'action' => 'product')); |
| 7 | 7 | |
| 8 | -Router::connect('/:loja/addCart', array('controller' => 'loja', 'action' => 'addCart')); |
|
| 8 | +Router::connect('/:loja/addCart', array('controller' => 'loja', 'action' => 'addCart')); |
|
| 9 | 9 | |
| 10 | -Router::connect('/:loja/clearCart', array('controller' => 'loja', 'action' => 'clearCart')); |
|
| 10 | +Router::connect('/:loja/clearCart', array('controller' => 'loja', 'action' => 'clearCart')); |
|
| 11 | 11 | |
| 12 | -Router::connect('/:loja/cart', array('controller' => 'loja', 'action' => 'cart')); |
|
| 12 | +Router::connect('/:loja/cart', array('controller' => 'loja', 'action' => 'cart')); |
|
| 13 | 13 | |
| 14 | -Router::connect('/:loja/checkout', array('controller' => 'loja', 'action' => 'checkout')); |
|
| 14 | +Router::connect('/:loja/checkout', array('controller' => 'loja', 'action' => 'checkout')); |
|
| 15 | 15 | |
| 16 | -Router::connect('/:loja/payment', array('controller' => 'loja', 'action' => 'payment')); |
|
| 16 | +Router::connect('/:loja/payment', array('controller' => 'loja', 'action' => 'payment')); |
|
| 17 | 17 | |
| 18 | 18 | Router::connect('/:loja/category/:id/:nome', array('controller' => 'loja', 'action' => 'category')); |
| 19 | 19 | |
| 20 | 20 | Router::connect('/:loja/calcTransportAjax', array('controller' => 'loja', 'action' => 'calcTransportAjax')); |
| 21 | 21 | |
| 22 | -Router::connect('/:loja/removeProductCart/:id', array('controller' => 'loja', 'action' => 'removeProductCart')); |
|
| 22 | +Router::connect('/:loja/removeProductCart/:id', array('controller' => 'loja', 'action' => 'removeProductCart')); |
|
| 23 | 23 | |
| 24 | 24 | Router::connect('/:loja/product/:id', array('controller' => 'loja', 'action' => 'product')); |
| 25 | 25 | |
| 26 | 26 | Router::connect('/:loja/retornopagseguro', array('controller' => 'loja', 'action' => 'retornopagseguro')); |
| 27 | 27 | |
| 28 | -require CAKE . 'Config' . DS . 'routes.php'; |
|
| 28 | +require CAKE.'Config'.DS.'routes.php'; |
|
| 29 | 29 | |
| 30 | 30 | CakePlugin::routes(); |
| 31 | 31 | \ No newline at end of file |