public static function debug($message) { if (self::$log == null) { return; } self::$log->LogDebug(self::getTime() . ' ' . $message); }
//return "empty_cell"; //search row error } else { // $row1['counter']=$row['counter']; //$row['epc']=substr($tb_name,6,strlen($tb_name)); array_push($data2, $row['encrypted_phone']); } //} //print_r($data2); } } $con->mysqlclose(); $data3 = array(); foreach ($data2 as $key => $value) { $log = new KLogger("lbs_debug.log", KLogger::DEBUG); $subscriberId = "tel:" . $value; $log->LogDebug("Received msisdn = " . $subscriberId); $LBS_QUERY_SERVER_URL = 'http://127.0.0.1:7000/lbs/locate'; $APP_ID = "APP_001768"; $PASSWORD = "******"; $SERVICE_TYPE = "IMMEDIATE"; $FRESHNESS = "HIGH"; $HORIZONTAL_ACCURACY = "1500"; $RESPONSE_TIME = "NO_DELAY"; $request = new LbsRequest($LBS_QUERY_SERVER_URL); $request->setAppId($APP_ID); $request->setAppPassword($PASSWORD); $request->setSubscriberId($subscriberId); $request->setServiceType($SERVICE_TYPE); $request->setFreshness($FRESHNESS); $request->setHorizontalAccuracy($HORIZONTAL_ACCURACY); $request->setResponseTime($RESPONSE_TIME);
public static function requestSaveVenda() { try { $dados = $_POST; $VendaDao = new VendaDao(); $VendaTO = new VendaTO(); $ReferenciaIntegracaoDao = new ReferenciaIntegracaoDao(); $PrestaShopDao = new PrestaShopDao($dados['id_empreendimento']); $ProdutoCombinacaoDao = new ProdutoCombinacaoDao(); $ItemVendaDao = new ItemVendaDao(); $ItemVendaTO = new ItemVendaTO(); $refCliente = $ReferenciaIntegracaoDao->get(array('sistema_integrado' => 'PrestaShop', 'tabela' => 'tbl_usuarios', 'id_item_referencia' => $dados['customer']['id'], 'tipo' => 'usuario', 'id_empreendimento' => $dados['id_empreendimento'], 'flg_excluido' => 0)); if ($refCliente) { $id_cliente = $refCliente['id_item']; } else { $id_cliente = NULL; } $PagamentoClienteTO = new PagamentoClienteTO(); $PagamentoClienteDao = new PagamentoClienteDao(); $ControlePagamentoVendaTO = new ControlePagamentoVendaTO(); $ControlePagamentoVendaDao = new ControlePagamentoVendaDao(); $ConfiguracaoDao = new ConfiguracaoDao(); $config = $ConfiguracaoDao->getConfiguracoes($dados['id_empreendimento']); $id_controle_pagamento = $ControlePagamentoVendaDao->saveControlePagamento(); $PagamentoClienteTO->id_usuario = $config['prestashop_id_usuario_padrao']; $PagamentoClienteTO->id_cliente = $id_cliente; $PagamentoClienteTO->id_controle_pagamento = $id_controle_pagamento; $PagamentoClienteTO->obs_pagamento = 'Pagamento PrestaShop'; $PagamentoClienteTO->valor_pagamento = $dados['order']['total_products_wt']; $PagamentoClienteTO->status_pagamento = 0; $PagamentoClienteTO->id_empreendimento = $dados['id_empreendimento']; $PagamentoClienteTO->id_plano_conta = $config['prestashop_id_plano_conta_padrao']; $PagamentoClienteTO->id_conta_bancaria = $config['prestashop_id_conta_bancaria_padrao']; $PagamentoClienteTO->data_pagamento = date('Y-m-d H:i:s'); if (strtolower($dados['order']['payment']) == 'cheque') { $PagamentoClienteTO->id_forma_pagamento = 2; } else { $PagamentoClienteTO->id_forma_pagamento = 8; } $id_lancamento_entrada = $PagamentoClienteDao->savePagamentoCliente($PagamentoClienteTO); $ReferenciaIntegracaoPagTO = new ReferenciaIntegracaoTO(); $ReferenciaIntegracaoPagTO->sistema_integrado = 'PrestaShop'; $ReferenciaIntegracaoPagTO->tabela = 'tbl_pagamentos_venda'; $ReferenciaIntegracaoPagTO->id_item = $id_lancamento_entrada; $ReferenciaIntegracaoPagTO->id_item_referencia = $dados['cart']['id']; $ReferenciaIntegracaoPagTO->tipo = 'pagamento'; $ReferenciaIntegracaoPagTO->id_empreendimento = $dados['id_empreendimento']; $ReferenciaIntegracaoDao->save($ReferenciaIntegracaoPagTO); $produtos = array(); $VendaTO->id_usuario = $config['prestashop_id_usuario_padrao']; $VendaTO->id_cliente = $id_cliente; $VendaTO->venda_confirmada = 0; $VendaTO->id_empreendimento = $dados['id_empreendimento']; $VendaTO->id_status_venda = 1; $VendaTO->dta_venda = $dados['order']['date_add']; $VendaTO->vlr_saldo_anterior = NULL; $id_venda = $VendaDao->saveVenda($VendaTO); $ReferenciaIntegracaoTO = new ReferenciaIntegracaoTO(); $ReferenciaIntegracaoTO->sistema_integrado = 'PrestaShop'; $ReferenciaIntegracaoTO->tabela = 'tbl_vendas'; $ReferenciaIntegracaoTO->id_item = $id_venda; $ReferenciaIntegracaoTO->id_item_referencia = $dados['cart']['id']; $ReferenciaIntegracaoTO->tipo = 'venda'; $ReferenciaIntegracaoTO->id_empreendimento = $dados['id_empreendimento']; $ReferenciaIntegracaoDao->save($ReferenciaIntegracaoTO); foreach ($dados['order']['product_list'] as $value) { if (isset($value['id_product_attribute'])) { $refCombinacao = $ReferenciaIntegracaoDao->get(array('sistema_integrado' => 'PrestaShop', 'tabela' => 'tbl_produto_combinacao', 'id_item_referencia' => $value['id_product_attribute'], 'tipo' => 'combinacao', 'id_empreendimento' => $dados['id_empreendimento'], 'flg_excluido' => 0)); if ($refCombinacao) { $comb = $ProdutoCombinacaoDao->get(null, null, array('tpc.id' => $refCombinacao['id_item'])); if ($comb) { $id_produto = $comb[0]['id_combinacao']; } } else { $refProduto = $ReferenciaIntegracaoDao->get(array('sistema_integrado' => 'PrestaShop', 'tabela' => 'tbl_produtos', 'id_item_referencia' => $value['id_product'], 'tipo' => 'produto', 'id_empreendimento' => $dados['id_empreendimento'], 'flg_excluido' => 0)); if ($refProduto) { $id_produto = $refProduto['id_item']; } } } $ex = (double) $value['price_with_reduction_without_tax'] - (double) $value['wholesale_price']; $perc_venda_varejo = $ex * 100 / (double) $value['wholesale_price']; $perc_venda_varejo = $perc_venda_varejo / 100; $ItemVendaTO->id_venda = $id_venda; $ItemVendaTO->id_produto = $id_produto; $ItemVendaTO->valor_real_item = $value['price']; $ItemVendaTO->vlr_custo = round($value['wholesale_price'], 2); $ItemVendaTO->perc_margem_aplicada = $perc_venda_varejo; $ItemVendaTO->desconto_aplicado = 0; $ItemVendaTO->valor_desconto = 0; $ItemVendaTO->qtd = $value['quantity']; $ItemVendaTO->perc_imposto_compra = 0; $ItemVendaTO->perc_desconto_compra = 0; $ItemVendaDao->saveItemVenda($ItemVendaTO); } } catch (Exception $e) { $log = new KLogger("logs/logErrorPrestaShop.txt", KLogger::DEBUG); $log->LogError($e->getMessage() . '- file:' . $e->getFile() . ' - line:' . $e->getLine()); $log->LogDebug(json_encode($_POST)); $log->LogJunp(); Flight::halt(500, $e->getMessage()); } }
// Include our configuration (holding defines for the requires) require_once BASEPATH . 'include/config/global.inc.php'; // We include all needed files here, even though our templates could load them themself require_once INCLUDE_DIR . '/autoloader.inc.php'; // Command line switches array_shift($argv); foreach ($argv as $option) { switch ($option) { case '-f': $monitoring->setStatus($cron_name . "_disabled", "yesno", 0); break; } } // Load 3rd party logging library for running crons $log = new KLogger('logs/' . $cron_name . '.txt', KLogger::INFO); $log->LogDebug('Starting ' . $cron_name); // Load the start time for later runtime calculations for monitoring $cron_start[$cron_name] = microtime(true); // Check if our cron is activated if ($monitoring->isDisabled($cron_name)) { $log->logFatal('Cronjob is currently disabled due to errors, use -f option to force running cron.'); $monitoring->endCronjob($cron_name, 'E0018', 1, true, false); } // Mark cron as running for monitoring $log->logDebug('Marking cronjob as running for monitoring'); $monitoring->setStatus($cron_name . '_starttime', 'date', time()); // Check if we need to halt our crons due to an outstanding upgrade if ($setting->getValue('DB_VERSION') != DB_VERSION || $config['version'] != CONFIG_VERSION) { $log->logFatal('Cronjob is currently disabled due to required upgrades. Import any outstanding SQL files and check your configuration file.'); $monitoring->endCronjob($cron_name, 'E0075', 0, true, false); }