My software is generating a label and pulling almost all the information I want, but when printing, it assigns a default expiration date to nearly all items. How can I correct this so that the correct expiration date is displayed for each specific item?
<?php
header('Content-Type: application/json');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$data = json_decode(file_get_contents('php://input'), true);
$code = htmlspecialchars($data['code']);
$quantity = htmlspecialchars($data['quantity']);
$totalLabels = htmlspecialchars($data['totalLabels']);
$servername = "000.000.000.00";
$port = "0000";
$username = "Testing";
$password = "exp";
$service_name = "exp";
$conn = oci_connect($username, $password, "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = $servername)(PORT = $port)))(CONNECT_DATA=(SERVICE_NAME=$service_name)))");
if (!$conn) {
$e = oci_error();
echo json_encode(['success' => false, 'message' => $e['message']]);
exit;
}
$sql = "SELECT mvs.pro_in_codigo, epr.pro_st_descricao, epr.uni_st_unidade, mvs.mvs_st_loteforne, mvs.mvs_dt_validade
FROM Testing.est_movsumarizado mvs, Testing.est_produtos epr
WHERE epr.pro_in_codigo = mvs.pro_in_codigo
AND epr.pro_in_codigo = :code
ORDER BY epr.pro_in_codigo";
$stmt = oci_parse($conn, $sql);
oci_bind_by_name($stmt, ':code', $code);
oci_execute($stmt);
if ($row = oci_fetch_assoc($stmt)) {
$expiryDateFormatted = date("d/m/Y", strtotime($row['MVS_DT_VALIDADE']));
$labelContent = "
<div class='label'>
<p class='header'><strong>PRODUTO/ITEM:</strong></p>
<p class='large-text'>{$row['PRO_ST_DESCRICAO']}</p>
<div class='content'>
<div class='left-section'>
<p class='header'><strong>CÓDIGO:</strong></p>
<p class='large-text'>{$row['PRO_IN_CODIGO']}</p>
</div>
<div class='right-section'>
<p class='header'><strong>QTD / CAIXA:</strong></p>
<p class='large-text'>{$quantity}</p>
</div>
<div class='left-section'>
<p class='header'><strong>DATA VAL:</strong></p>
<p class='large-text'>{$expiryDateFormatted}</p>
</div>
</div>
<p class='lot'><strong>Lote: </strong>{$row['MVS_ST_LOTEFORNE']}</p>
<div class='print-counter'>{pageNumber}</div>
<div class='bottom-section'></div>
</div>";
echo json_encode(['success' => true, 'labelContent' => $labelContent]);
} else {
echo json_encode(['success' => false, 'message' => 'Produto não encontrado.']);
}
oci_free_statement($stmt);
oci_close($conn);
}
?>
I need it to have the correct expiration date when I print it.
correct information
the wrong information that appears on the label
New contributor
Lucas Jesus is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.