include_once "../DataTransferObjects/RequestItemDTO.php"; include_once "../DataAccessObjects/InventoryItemDAO.php"; include_once "../DataTransferObjects/InventoryItemDTO.php"; include_once "../DataAccessObjects/ReadingDAO.php"; include_once "../DataTransferObjects/ReadingDTO.php"; $supplyRequestId = $_GET['supplyRequestId']; $cutoffDate = $_GET['cutoffDate']; // Abre a conexao com o banco de dados $dataConnector = new DataConnector('both'); $dataConnector->OpenConnection(); if ($dataConnector->mysqlConnection == null || $dataConnector->sqlserverConnection == null) { echo 'Não foi possível se connectar ao bando de dados!'; exit; } // Cria os objetos de mapeamento objeto relacional $supplyRequestDAO = new SupplyRequestDAO($dataConnector->mysqlConnection); $supplyRequestDAO->showErrors = 1; $requestItemDAO = new RequestItemDAO($dataConnector->mysqlConnection); $requestItemDAO->showErrors = 1; $inventoryItemDAO = new InventoryItemDAO($dataConnector->sqlserverConnection); $inventoryItemDAO->showErrors = 1; $readingDAO = new ReadingDAO($dataConnector->mysqlConnection); $readingDAO->showErrors = 1; // Busca os dados da solicitação de consumível $equipmentCode = 0; $itemEnumeration = ''; $supplyRequest = $supplyRequestDAO->RetrieveRecord($supplyRequestId); if ($supplyRequest != null) { $equipmentCode = $supplyRequest->codigoCartaoEquipamento; $reqItemArray = $requestItemDAO->RetrieveRecordArray("pedidoConsumivel_id=" . $supplyRequest->id); foreach ($reqItemArray as $reqItem) {
$indirectCostDAO = new IndirectCostDAO($dataConnector->mysqlConnection); $indirectCostDAO->showErrors = 1; $indirectCostIdArray = $indirectCostDAO->GetIds("chamadoServico_id IN (" . $callEnumeration . ") GROUP BY custoIndireto_id"); $idEnumeration = ""; foreach ($indirectCostIdArray as $indirectCostId) { if (!empty($idEnumeration)) { $idEnumeration .= ", "; } $idEnumeration = $idEnumeration . $indirectCostId; } if (empty($idEnumeration)) { $idEnumeration = "0"; } $indirectCostArray = $indirectCostDAO->RetrieveRecordArray("id IN (" . $idEnumeration . ")"); // localiza todos os gastos com consumíveis no período $supplyRequestDAO = new SupplyRequestDAO($dataConnector->mysqlConnection); $supplyRequestDAO->showErrors = 1; $requestItemDAO = new RequestItemDAO($dataConnector->mysqlConnection); $requestItemDAO->showErrors = 1; $pediodFilter = "data >= '" . $startDate . " 00:00' AND data <= '" . $endDate . " 23:59' "; $supplyRequestArray = $supplyRequestDAO->RetrieveRecordArray("codigoCartaoEquipamento IN (" . $equipmentEnumeration . ") AND " . $pediodFilter); if (sizeof($expenseArray) < 1 && sizeof($indirectCostArray) < 1 && sizeof($supplyRequestArray) < 1) { echo "<tr>"; echo " <td colspan='4' align='center'>Nenhum registro encontrado!</td>"; echo "</tr>"; exit; } $somaTotais = 0; $productionInputDAO = new ProductionInputDAO($dataConnector->mysqlConnection); $productionInputDAO->showErrors = 1; $inputTypeArray = $productionInputDAO->RetrieveInputTypes();
$subContract = $_REQUEST["subContract"]; } // Abre a conexao com o banco de dados $dataConnector = new DataConnector('both'); $dataConnector->OpenConnection(); if ($dataConnector->mysqlConnection == null || $dataConnector->sqlserverConnection == null) { echo 'Não foi possível se connectar ao bando de dados!'; exit; } $nivelAutorizacao = GetAuthorizationLevel($dataConnector->mysqlConnection, $functionalities["solicitacaoConsumiveis"]); if ($nivelAutorizacao <= 1) { DisplayNotAuthorizedWarning(); exit; } // Cria o objeto de mapeamento objeto-relacional $supplyRequestDAO = new SupplyRequestDAO($dataConnector->mysqlConnection); $supplyRequestDAO->showErrors = 1; $id = 0; $supplyRequest = new SupplyRequestDTO(); if (isset($_REQUEST["id"]) && $_REQUEST["id"] != 0) { $id = $_REQUEST["id"]; $supplyRequest = $supplyRequestDAO->RetrieveRecord($id); $equipmentCode = $supplyRequest->codigoCartaoEquipamento; // sobrescreve o parâmetro recebido na url caso a solicitação esteja sendo alterada/editada } $equipmentInfo = EquipmentDAO::GetSerialNumber($dataConnector->sqlserverConnection, $equipmentCode); $defaultEmailAddress = ConfigDAO::GetConfigurationParam($dataConnector->mysqlConnection, "emailPadrao"); ?> <h1>Solicitação de Consumível <?php echo $equipmentInfo;
</div> </div> <div class="portlet" id="pendingSupplies" > <div class="portlet-header">Solicitações de consumível pendentes</div> <div class="portlet-content"> <table border="0" cellpadding="0" cellspacing="0" class="sorTable"> <thead> <tr> <th style="width:25%;" > Data</th> <th style="width:65%;" > Descrição</th> <th style="width:10%;" > Equip.</th> </tr> </thead> <tbody> <?php $supplyRequestDAO = new SupplyRequestDAO($dataConnector->mysqlConnection); $supplyRequestDAO->showErrors = 1; $requestItemDAO = new RequestItemDAO($dataConnector->mysqlConnection); $requestItemDAO->showErrors = 1; // Busca as solicitações de consumível pendentes $supplyRequestArray = $supplyRequestDAO->RetrieveRecordArray("status = 2"); // 2 = 'em espera' if (sizeof($supplyRequestArray) == 0) { echo '<tr><td colspan="3" align="center" >Nenhum registro encontrado!</td></tr>'; } foreach ($supplyRequestArray as $supplyRequest) { $equipmentCode = $supplyRequest->codigoCartaoEquipamento; $requestItemArray = $requestItemDAO->RetrieveRecordArray("pedidoConsumivel_id=" . $supplyRequest->id); $description = ""; foreach ($requestItemArray as $requestItem) { if (!empty($description)) {
include_once "../../DataAccessObjects/ReadingDAO.php"; include_once "../../DataTransferObjects/ReadingDTO.php"; if (!isset($_REQUEST["acao"])) { echo "Erro no processamento da requisição."; exit; } $acao = $_REQUEST["acao"]; // Abre a conexao com o banco de dados $dataConnector = new DataConnector('mySql'); $dataConnector->OpenConnection(); if ($dataConnector->mysqlConnection == null) { echo 'Não foi possível se connectar ao bando de dados!'; exit; } // Cria o objeto de mapeamento objeto-relacional $supplyRequestDAO = new SupplyRequestDAO($dataConnector->mysqlConnection); $supplyRequestDAO->showErrors = 1; if ($acao == "store") { $id = 0; $supplyRequest = new SupplyRequestDTO(); if (isset($_REQUEST["id"]) && $_REQUEST["id"] != 0) { $id = $_REQUEST["id"]; $supplyRequest = $supplyRequestDAO->RetrieveRecord($id); } $supplyRequest->codigoCartaoEquipamento = $_REQUEST["equipmentCode"]; $supplyRequest->data = $_REQUEST["data"]; $supplyRequest->hora = $_REQUEST["hora"]; $supplyRequest->status = $_REQUEST["status"]; $supplyRequest->observacao = $_REQUEST["observacao"]; $recordId = $supplyRequestDAO->StoreRecord($supplyRequest); if ($recordId == null) {
$indirectCostDAO = new IndirectCostDAO($dataConnector->mysqlConnection); $indirectCostDAO->showErrors = 1; $indirectCostIdArray = $indirectCostDAO->GetIds("chamadoServico_id IN (" . $callEnumeration . ") GROUP BY custoIndireto_id"); $idEnumeration = ""; foreach ($indirectCostIdArray as $indirectCostId) { if (!empty($idEnumeration)) { $idEnumeration .= ", "; } $idEnumeration = $idEnumeration . $indirectCostId; } if (empty($idEnumeration)) { $idEnumeration = "0"; } $indirectCostArray = $indirectCostDAO->RetrieveRecordArray("id IN (" . $idEnumeration . ")"); // localiza todos os gastos com consumíveis no período $supplyRequestDAO = new SupplyRequestDAO($dataConnector->mysqlConnection); $supplyRequestDAO->showErrors = 1; $requestItemDAO = new RequestItemDAO($dataConnector->mysqlConnection); $requestItemDAO->showErrors = 1; $pediodFilter = "data >= '" . $startDate . " 00:00' AND data <= '" . $endDate . " 23:59' "; $supplyRequestArray = $supplyRequestDAO->RetrieveRecordArray("codigoCartaoEquipamento = " . $equipmentCode . " AND " . $pediodFilter); $details = ""; if (sizeof($expenseArray) < 1 && sizeof($indirectCostArray) < 1 && sizeof($supplyRequestArray) < 1) { $details .= "<tr>"; $details .= " <td colspan='4' align='center'>Nenhum registro encontrado!</td>"; $details .= "</tr>"; } $somaTotais = 0; $productionInputDAO = new ProductionInputDAO($dataConnector->mysqlConnection); $productionInputDAO->showErrors = 1; $inputTypeArray = $productionInputDAO->RetrieveInputTypes();
$subContract = $_REQUEST["subContract"]; } // Abre a conexao com o banco de dados $dataConnector = new DataConnector('both'); $dataConnector->OpenConnection(); if ($dataConnector->mysqlConnection == null || $dataConnector->sqlserverConnection == null) { echo 'Não foi possível se connectar ao bando de dados!'; exit; } $nivelAutorizacao = GetAuthorizationLevel($dataConnector->mysqlConnection, $functionalities["solicitacaoConsumiveis"]); if ($nivelAutorizacao <= 1) { DisplayNotAuthorizedWarning(); exit; } // Cria os objetos de mapeamento objeto-relacional $supplyRequestDAO = new SupplyRequestDAO($dataConnector->mysqlConnection); $supplyRequestDAO->showErrors = 1; $requestItemDAO = new RequestItemDAO($dataConnector->mysqlConnection); $requestItemDAO->showErrors = 1; // Traz a lista de consumíveis solicitados $maxRecordCount = ConfigDAO::GetConfigurationParam($dataConnector->mysqlConnection, "limiteListaConsumiveis"); $recCount = $supplyRequestDAO->GetRecordCount(); $boundary = ""; if ($recCount > $maxRecordCount && empty($equipmentCode)) { $boundary = "LIMIT " . ($recCount - $maxRecordCount) . ", " . $recCount; } $filter = "id > 0 ORDER BY id"; if ($equipmentCode != 0) { $filter = "codigoCartaoEquipamento = " . $equipmentCode; } $supplyRequestArray = $supplyRequestDAO->RetrieveRecordArray($filter . ' ' . $boundary);