Created
September 15, 2017 19:58
-
-
Save rodrigobravo/4256d8a1b3b769c75345bcdbfc38edf7 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'; | |
| try{ | |
| $db = new PDO('sqlite:/home/rodrigo/delivery2/files/database.db'); | |
| if(!$db) { | |
| echo $db->lastErrorMsg() ; | |
| } else { | |
| $sqlPedidos = " | |
| select | |
| DOCHEADER.ID, | |
| DOCHEADER.DOC_PREFIX, | |
| DOCHEADER.DOC_NUMBER, | |
| DOCHEADER.ACCUMULATOR as acumulador, | |
| DOCHEADER.CLOCK_DATE data_FP, | |
| DOCHEADER.ENTITY_ID as client_id, | |
| ENTITY.DESCRIPTION as cliente, | |
| EMPLOYEE.INTERNAL_NAME as funcionario, | |
| LOCAL.DESCRIPTION as local, | |
| DOCHEADER.OBS as obs | |
| from DOCHEADER | |
| JOIN ENTITY on ENTITY.ID = DOCHEADER.ENTITY_ID | |
| JOIN LOCAL on LOCAL.ID = DOCHEADER.LOCAL_ID | |
| JOIN EMPLOYEE on EMPLOYEE.ENTITY_ID = DOCHEADER.employee_id | |
| Where DOCHEADER.DELETED=0 and local = 'Delivery' | |
| ORDER by data_FP | |
| "; | |
| $sql = $db->prepare($sqlPedidos); | |
| $sql->execute(); | |
| while ($row = $sql->fetchObject()){ | |
| $linhas[] = $row; | |
| } | |
| $today = date("d/m/y"); | |
| foreach ($linhas as $entrada) { | |
| if ((date("d/m/y",substr($entrada->data_FP,0,-9))>= $today) | |
| { | |
| $novoPedido = new Pedido($entrada->id, $entrada->doc_prefix, $entrada->doc_number, $entrada->acumulador, date("d/m H:i",substr($entrada->data_FP,0,-9)), $entrada->client_id, $entrada->cliente, $entrada->funcionario, $entrada->local, $entrada->obs); | |
| $listaPedidos[] = $novoPedido; | |
| } | |
| } | |
| 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