Nueva partida cambios - edición
This commit is contained in:
@@ -440,56 +440,70 @@ function editar() {
|
||||
if (!($_SESSION['usuario_id'] ?? false)) {
|
||||
header('Location: /IMPORTADORES/login'); exit;
|
||||
}
|
||||
$id_solicitud = $_GET['id']??null;
|
||||
if(!$id_solicitud||!is_numeric($id_solicitud)) die("❌ ID inválido.");
|
||||
$id_importador=$_SESSION['usuario_id'];
|
||||
$conn=getConnection();
|
||||
|
||||
$stmt=sqlsrv_query($conn,
|
||||
"SELECT * FROM dbo.solicitud_importacion_factura WHERE id_solicitud=? AND id_importador=?",
|
||||
[(int)$id_solicitud,$id_importador]
|
||||
);
|
||||
if($stmt===false) die(print_r(sqlsrv_errors(),true));
|
||||
$factura=sqlsrv_fetch_array($stmt,SQLSRV_FETCH_ASSOC);
|
||||
if(!$factura) die("❌ No autorizado.");
|
||||
if($factura['fecha_factura'] instanceof DateTime)
|
||||
$factura['fecha_factura']=$factura['fecha_factura']->format('Y-m-d');
|
||||
$id_solicitud = $_GET['id']??null;
|
||||
if(!$id_solicitud || !is_numeric($id_solicitud)) {
|
||||
die("❌ ID inválido.");
|
||||
}
|
||||
$id_importador = $_SESSION['usuario_id'];
|
||||
$conn = getConnection();
|
||||
|
||||
$stmt = sqlsrv_query($conn,"SELECT * FROM dbo.solicitud_importacion_factura WHERE id_solicitud=? AND id_importador=?",[(int)$id_solicitud,$id_importador]);
|
||||
if($stmt === false) {
|
||||
die(print_r(sqlsrv_errors(),true));
|
||||
}
|
||||
$factura = sqlsrv_fetch_array($stmt,SQLSRV_FETCH_ASSOC);
|
||||
if(!$factura) {
|
||||
die("❌ No autorizado.");
|
||||
}
|
||||
if($factura['fecha_factura'] instanceof DateTime) {
|
||||
$factura['fecha_factura'] = $factura['fecha_factura']->format('Y-m-d');
|
||||
}
|
||||
|
||||
// Solo necesitamos la clave del proveedor actual para JavaScript
|
||||
$proveedor_clave_actual = $factura['proveedor_clave'] ?? '';
|
||||
|
||||
// Carga selects (igual que crear)
|
||||
// Transportistas
|
||||
$transportistas=[]; $stmtT=sqlsrv_query($conn,"SELECT id_transportista,nombre FROM dbo.transportistas WHERE id_usuario=? AND activo=1 ORDER BY nombre",[$id_importador]);
|
||||
while($r=sqlsrv_fetch_array($stmtT,SQLSRV_FETCH_ASSOC)) $transportistas[]=$r;
|
||||
$transportistas = []; $stmtT = sqlsrv_query($conn,"SELECT id_transportista, nombre FROM dbo.transportistas WHERE id_usuario=? AND activo=1 ORDER BY nombre",[$id_importador]);
|
||||
while($r = sqlsrv_fetch_array($stmtT,SQLSRV_FETCH_ASSOC)) {
|
||||
$transportistas[] = $r;
|
||||
}
|
||||
// Choferes
|
||||
$choferes=[]; $stmtC=sqlsrv_query($conn,"SELECT c.id_chofer,c.nombre+' '+c.apellido AS nombre FROM dbo.choferes c JOIN dbo.transportistas t ON c.transportista_id=t.id_transportista WHERE t.id_usuario=? AND c.status=1 ORDER BY c.nombre",[$id_importador]);
|
||||
while($r=sqlsrv_fetch_array($stmtC,SQLSRV_FETCH_ASSOC)) $choferes[]=$r;
|
||||
$choferes = []; $stmtC = sqlsrv_query($conn,"SELECT c.id_chofer, c.nombre+' '+c.apellido AS nombre FROM dbo.choferes c JOIN dbo.transportistas t ON c.transportista_id=t.id_transportista
|
||||
WHERE t.id_usuario=? AND c.status=1 ORDER BY c.nombre",[$id_importador]);
|
||||
while($r=sqlsrv_fetch_array($stmtC,SQLSRV_FETCH_ASSOC)) {
|
||||
$choferes[] = $r;
|
||||
}
|
||||
// Paises
|
||||
$paises=[]; $stmtP=sqlsrv_query($conn,"SELECT id_pais,nombre FROM dbo.paises ORDER BY nombre");
|
||||
while($r=sqlsrv_fetch_array($stmtP,SQLSRV_FETCH_ASSOC)) $paises[]=$r;
|
||||
$paises = []; $stmtP = sqlsrv_query($conn,"SELECT id_pais, nombre FROM dbo.paises ORDER BY nombre");
|
||||
while($r=sqlsrv_fetch_array($stmtP,SQLSRV_FETCH_ASSOC)) {
|
||||
$paises[] = $r;
|
||||
}
|
||||
// Aduanas
|
||||
$aduanas=[]; $stmtA=sqlsrv_query($conn,"SELECT aduana_seccion,nombre FROM dbo.aduanas ORDER BY aduana_seccion");
|
||||
while($r=sqlsrv_fetch_array($stmtA,SQLSRV_FETCH_ASSOC)) $aduanas[]=$r;
|
||||
$aduanas = []; $stmtA = sqlsrv_query($conn,"SELECT DISTINCT RIGHT(REPLICATE('0', 3) + CAST(aduana_seccion AS VARCHAR), 3) AS aduana_seccion, nombre FROM dbo.aduanas ORDER BY aduana_seccion");
|
||||
while($r = sqlsrv_fetch_array($stmtA,SQLSRV_FETCH_ASSOC)) {
|
||||
$aduanas[] = $r;
|
||||
}
|
||||
// Incoterms
|
||||
$incoterms=[]; $stmtI=sqlsrv_query($conn,"SELECT INCOTERM,DESCESPANOL FROM dbo.gIncoterms ORDER BY INCOTERM");
|
||||
while($r=sqlsrv_fetch_array($stmtI,SQLSRV_FETCH_ASSOC)) $incoterms[]=$r;
|
||||
$incoterms = []; $stmtI = sqlsrv_query($conn,"SELECT INCOTERM,DESCESPANOL FROM dbo.gIncoterms ORDER BY INCOTERM");
|
||||
while($r = sqlsrv_fetch_array($stmtI,SQLSRV_FETCH_ASSOC)) {
|
||||
$incoterms[] = $r;
|
||||
}
|
||||
// Unidades de Medida
|
||||
$unidades_medida = []; $stmtU = sqlsrv_query($conn, "SELECT id, descripcion FROM dbo.unidades_medida_apendice7 ORDER BY id");
|
||||
while ($r = sqlsrv_fetch_array($stmtU, SQLSRV_FETCH_ASSOC)) {
|
||||
$unidades_medida[] = $r;
|
||||
}
|
||||
|
||||
// Partidas existentes
|
||||
$partidas=[];
|
||||
$partidas = [];
|
||||
$stmtPar = sqlsrv_query($conn,
|
||||
"SELECT
|
||||
id_partida,
|
||||
descripcion,
|
||||
cantidad_comercial,
|
||||
cantidad_tarifa,
|
||||
valor_factura,
|
||||
peso_bruto,
|
||||
unidad_comercial_id,
|
||||
tasa_preferencial
|
||||
FROM dbo.solicitud_importacion_partidas
|
||||
WHERE id_solicitud=?
|
||||
ORDER BY id_partida",
|
||||
[(int)$id_solicitud]
|
||||
);
|
||||
while($r=sqlsrv_fetch_array($stmtPar,SQLSRV_FETCH_ASSOC)) $partidas[]=$r;
|
||||
"SELECT id_partida, descripcion, cantidad_comercial, cantidad_tarifa, valor_factura, peso_bruto, unidad_comercial_id, tasa_preferencial
|
||||
FROM dbo.solicitud_importacion_partidas WHERE id_solicitud=? ORDER BY id_partida", [(int)$id_solicitud]);
|
||||
while($r=sqlsrv_fetch_array($stmtPar,SQLSRV_FETCH_ASSOC)) {
|
||||
$partidas[]=$r;
|
||||
}
|
||||
|
||||
include __DIR__ . '/../../views/solicitud_importacion/editar.php';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user