Created
September 18, 2017 23:39
-
-
Save rodrigobravo/8390354e5149100cc2de88fda42d2991 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| include_once 'Pedido.php'; | |
| include_once 'querys.php'; | |
| try{ | |
| $db = new PDO('sqlite:/home/rodrigo/delivery2/files/database.db'); | |
| $dbdest = new PDO('sqlite:/home/rodrigo/delivery2/files/delivery.db'); | |
| if(!$db){ | |
| echo $db->lastErrorMsg() ; | |
| }else{ | |
| $sql = $db->prepare($sqlPedidos); | |
| $sqlinsert = $dbdest->prepare($sqlInsertRequests); | |
| $sql->execute(); | |
| while ($row = $sql->fetchObject()){ | |
| $linhas[] = $row; | |
| $today=date('d-m-Y'); | |
| $listaPedidos = array(); | |
| foreach ($linhas as $entrada) { | |
| $reqdate = $entrada->date_req; | |
| if ($today === $reqdate){ | |
| $clock = datetime::createFromFormat( 'U', (substr($entrada->clock_req,0,-9))); | |
| $novoPedido = new Pedido($entrada->id, $entrada->doc_prefix, $entrada->doc_number, $entrada->acumulador, $entrada->date_req, $clock->format("H:i"), $entrada->client_id, $entrada->cliente, $entrada->funcionario, $entrada->local, $entrada->obs, $entrada->total); | |
| $client_id = $entrada->client_id; | |
| $funcionario = $entrada->funcionario; | |
| $acumulador = $entrada->acumulador; | |
| $obs = $entrada->obs; | |
| $total = $entrada->total; | |
| $date_req = $entrada->date_req; | |
| $id = $entrada->id; | |
| $doc_number = $entrada->doc_number; | |
| $clock_req = substr($entrada->clock_req,0,-9); | |
| $sqlinsert->bindParam(':client_id', $client_id); | |
| $sqlinsert->bindParam(':employee_name', $funcionario); | |
| $sqlinsert->bindParam(':accumulator', $acumulador); | |
| $sqlinsert->bindParam(':obs', $obs); | |
| $sqlinsert->bindParam(':totalPrice', $total); | |
| $sqlinsert->bindParam(':date', $date_req); | |
| $sqlinsert->bindParam(':id_orig', $id); | |
| $sqlinsert->bindParam(':doc_number', $doc_number); | |
| $sqlinsert->bindParam(':clock_req', $clock_req); | |
| $sqlinsert->execute(); | |
| $listaPedidos[] = $novoPedido; | |
| } | |
| } | |
| if (empty($listaPedidos)){ | |
| }else{ | |
| echo json_encode($listaPedidos); | |
| } | |
| } | |
| } | |
| } | |
| catch(PDOException $e){ | |
| print 'Exception : '.$e->getMessage(); | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment