示例#1
0
$page->addComponent(new TitleComponent("Nueva entrada", 2));
$entrada_lote = new FormComponent();
$entrada_lote->addField("id_lote", "Lote", "combobox");
//$entrada_lote->createComboBoxJoin("id_lote", "id_lote", LoteDAO::getAll(   ) );
$entrada_lote->createComboBoxJoinDistintName("id_lote", "id_lote", "folio", LoteDAO::getAll());
$entrada_lote->setHelp("id_lote", "Lote a donde se insertara este arrivo");
$entrada_lote->addField("cantidad", "Cantidad", "text");
$este_producto = ProductoDAO::GetByPK($_GET["pid"]);
$um = UnidadMedidaDAO::getByPK($este_producto->getIdUnidad());
if (!is_null($um)) {
    $entrada_lote->setHelp("cantidad", "Cantidad en " . $um->getDescripcion());
} else {
    $entrada_lote->setHelp("cantidad", "Error!");
}
$entrada_lote->addField("productos", "", "text", "\"   [ { \\\"id_producto\\\" : " . $_GET["pid"] . ", \\\"cantidad\\\"    : 0 } ]   \"");
$entrada_lote->sendHidden("productos");
$entrada_lote->makeObligatory(array("id_lote", "cantidad"));
$entrada_lote->beforeSend("beforeSendNuevaEntrada");
$entrada_lote->addApiCall("api/almacen/lote/entrada", "POST");
$page->addComponent("<script> function beforeSendNuevaEntrada(a){ \n\t\t\t\t\tconsole.log('beforeSend(' + a + ')');\n\t\t\t\t\tvar aPdec = Ext.JSON.decode(a.productos);\n\t\t\t\t\tconsole.log(aPdec);\n\t\t\t\t\taPdec[0].cantidad = a.cantidad;\n\t\t\t\t\ta.productos = Ext.JSON.encode(aPdec);\n\t\t\t\t\treturn a;\n\t\t\t\t}</script>");
$page->addComponent($entrada_lote);
$page->nextTab("Historial");
//mostrar entradas
$entradas = LoteEntradaProductoDAO::obtenerEntradaPorProducto($_GET["pid"]);
$salidas = LoteSalidaProductoDAO::obtenerSalidaPorProducto($_GET["pid"]);
$merged = array_merge($entradas, $salidas);
function cmpByFecha($a, $b)
{
    if ($a["fecha_registro"] == $b["fecha_registro"]) {
        return 0;
    }