{"id":59,"date":"2026-02-19T05:22:55","date_gmt":"2026-02-19T09:22:55","guid":{"rendered":"https:\/\/armatuweb.work\/?page_id=59"},"modified":"2026-02-19T05:23:34","modified_gmt":"2026-02-19T09:23:34","slug":"compras-tienda","status":"publish","type":"page","link":"https:\/\/armatuweb.work\/index.php\/compras-tienda\/","title":{"rendered":"Compras Tienda"},"content":{"rendered":"    <div style=\"max-width:500px; margin:auto; font-family:sans-serif; background:#fff; border-radius:15px; box-shadow:0 10px 25px rgba(0,0,0,0.1); border:1px solid #ddd;\">\r\n        <div style=\"background:#2271b1; color:white; padding:20px; text-align:center; border-radius:15px 15px 0 0;\">\r\n            <h2 style=\"margin:0;\">\ud83d\uded2 Compras Mercado<\/h2>\r\n        <\/div>\r\n\r\n        <form id=\"pablito-form-compra\" style=\"padding:20px;\">\r\n            <label style=\"font-weight:bold; color:#444;\">\u00bfQu\u00e9 est\u00e1s comprando?<\/label>\r\n            <select name=\"producto_id\" id=\"selector_producto\" required style=\"width:100%; padding:12px; margin:10px 0 20px; border-radius:8px; border:1px solid #ccc; font-size:16px;\">\r\n                <option value=\"\">-- Seleccionar Producto --<\/option>\r\n                <option value=\"nuevo\" style=\"font-weight:bold; color:#2e7d32;\">\u2795 REGISTRAR PRODUCTO NUEVO<\/option>\r\n                                    <option value=\"54\">Gaseosa 2L<\/option>\r\n                                    <option value=\"55\">Leche Entera<\/option>\r\n                            <\/select>\r\n\r\n            <div id=\"campos_nuevo_producto\" style=\"display:none; background:#f0f7ff; padding:15px; border-radius:10px; margin-bottom:20px; border:1px solid #b3d7ff;\">\r\n                <h4 style=\"margin-top:0; color:#0056b3;\">\u2728 Datos del Nuevo Producto<\/h4>\r\n                \r\n                <label>Nombre del Producto:<\/label>\r\n                <input type=\"text\" name=\"nuevo_nombre\" placeholder=\"Ej: Aceite Fino 1L\" style=\"width:100%; padding:10px; margin-bottom:15px; border:1px solid #ccc; border-radius:5px;\">\r\n\r\n                <label>Categor\u00eda (Solo Tienda):<\/label>\r\n                <select name=\"nueva_categoria\" style=\"width:100%; padding:10px; margin-bottom:15px; border:1px solid #ccc; border-radius:5px;\">\r\n                    <option value='Insumos'>Insumos<\/option><option value='Mercader\u00eda'>Mercader\u00eda<\/option><option value='Utilidades'>Utilidades<\/option>                <\/select>\r\n\r\n                <div style=\"display:grid; grid-template-columns:1fr 1fr; gap:10px;\">\r\n                    <div>\r\n                        <label>Uds x Pack:<\/label>\r\n                        <input type=\"number\" name=\"unidades_pack\" placeholder=\"Ej: 12\" style=\"width:100%; padding:10px; border:1px solid #ccc; border-radius:5px;\">\r\n                    <\/div>\r\n                    <div>\r\n                        <label>Venta Unidad:<\/label>\r\n                        <input type=\"number\" step=\"0.01\" name=\"precio_venta_unidad\" placeholder=\"Bs.\" style=\"width:100%; padding:10px; border:1px solid #ccc; border-radius:5px;\">\r\n                    <\/div>\r\n                <\/div>\r\n            <\/div>\r\n\r\n            <div style=\"display:grid; grid-template-columns:1fr 1fr; gap:10px;\">\r\n                <div>\r\n                    <label style=\"font-weight:bold;\">Cant. Packs:<\/label>\r\n                    <input type=\"number\" name=\"cantidad_packs\" required style=\"width:100%; padding:12px; margin-top:5px; border-radius:8px; border:1px solid #ccc;\">\r\n                <\/div>\r\n                <div>\r\n                    <label style=\"font-weight:bold;\">Costo Pack:<\/label>\r\n                    <input type=\"number\" step=\"0.01\" name=\"costo_pack\" required style=\"width:100%; padding:12px; margin-top:5px; border-radius:8px; border:1px solid #ccc;\">\r\n                <\/div>\r\n            <\/div>\r\n\r\n            <label style=\"font-weight:bold; display:block; margin-top:15px;\">Fecha de Vencimiento:<\/label>\r\n            <input type=\"date\" name=\"fecha_vencimiento\" required style=\"width:100%; padding:12px; margin-top:5px; border-radius:8px; border:1px solid #ccc;\">\r\n\r\n            <button type=\"submit\" style=\"width:100%; background:#2e7d32; color:white; border:none; padding:18px; border-radius:10px; font-size:18px; font-weight:bold; margin-top:20px; cursor:pointer;\">\r\n                \ud83d\udcbe Registrar Compra\r\n            <\/button>\r\n            <div id=\"res-mensaje\" style=\"margin-top:15px; text-align:center; font-weight:bold;\"><\/div>\r\n        <\/form>\r\n    <\/div>\r\n\r\n    <script>\r\n    jQuery(document).ready(function($) {\r\n        $('#selector_producto').on('change', function() {\r\n            if($(this).val() === 'nuevo') $('#campos_nuevo_producto').show();\r\n            else $('#campos_nuevo_producto').hide();\r\n        });\r\n\r\n        $('#pablito-form-compra').on('submit', function(e) {\r\n            e.preventDefault();\r\n            var $btn = $(this).find('button');\r\n            $btn.prop('disabled', true).text('\u231b Guardando...');\r\n\r\n            $.post(pablito_ajax_obj.ajax_url, {\r\n                action: 'pablito_registrar_compra_stock',\r\n                formData: $(this).serialize()\r\n            }, function(res) {\r\n                if(res.success) {\r\n                    $('#res-mensaje').html(res.data.mensaje).css('color', 'green');\r\n                    if($('#selector_producto').val() === 'nuevo') {\r\n                        setTimeout(function(){ location.reload(); }, 2000);\r\n                    } else {\r\n                        $('#pablito-form-compra')[0].reset();\r\n                        $btn.prop('disabled', false).text('\ud83d\udcbe Registrar Compra');\r\n                    }\r\n                } else {\r\n                    $('#res-mensaje').html('\u274c ' + res.data.mensaje).css('color', 'red');\r\n                    $btn.prop('disabled', false).text('\ud83d\udcbe Registrar Compra');\r\n                }\r\n            });\r\n        });\r\n    });\r\n    <\/script>\r\n    \n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"footnotes":""},"class_list":["post-59","page","type-page","status-publish","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/armatuweb.work\/index.php\/wp-json\/wp\/v2\/pages\/59","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/armatuweb.work\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/armatuweb.work\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/armatuweb.work\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/armatuweb.work\/index.php\/wp-json\/wp\/v2\/comments?post=59"}],"version-history":[{"count":2,"href":"https:\/\/armatuweb.work\/index.php\/wp-json\/wp\/v2\/pages\/59\/revisions"}],"predecessor-version":[{"id":61,"href":"https:\/\/armatuweb.work\/index.php\/wp-json\/wp\/v2\/pages\/59\/revisions\/61"}],"wp:attachment":[{"href":"https:\/\/armatuweb.work\/index.php\/wp-json\/wp\/v2\/media?parent=59"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}