//$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; } return $a["fecha_registro"] < $b["fecha_registro"] ? 1 : -1; } usort($merged, "cmpByFecha");
} $f->setEditable(false); $f->setStyle("big"); $page->addComponent($f); /** * * **/ $page->nextTab("Editar"); $f = new FormComponent(); for ($i = 0; $i < sizeof($values); $i++) { $f->addField($values[$i]["campo"], $values[$i]["caption"], $values[$i]["tipo"], utf8_decode($values[$i]["val"])); } $f->setEditable(true); $f->setStyle("big"); $f->addApiCall("api/documento/editar", "POST"); $f->beforeSend("attachExtraParams"); $html = " <script>\n\t\t\tfunction attachExtraParams( a ) {\n\t\t\t\ta.id_documento = " . $documento->getIdDocumento() . ";\n\t\t\t\ta.extra_params = Ext.JSON.encode({ "; for ($i = 0; $i < sizeof($values); $i++) { $html .= $values[$i]["campo"] . " : Ext.get(\"" . $f->getGuiComponentId() . $values[$i]["campo"] . "\" ).getValue() , "; } $html .= "});\n\t\t\t\treturn a;\n\t\t\t}\n\t\t</script>"; $page->addComponent($html); $page->addComponent($f); /** * * **/ $page->nextTab("Compartir"); /** *
// Validar parametro de base $DocumentoBase = DocumentoBaseDAO::getByPK($_GET["base"]); if (is_null($DocumentoBase)) { $page->render(); exit; } else { if ($DocumentoBase->GetActivo() == false) { $page->render(); exit; } } $page->addComponent(new TitleComponent("Nuevo " . $DocumentoBase->getNombre(), 1)); //Buscar sus parametros extra $ExtraParamsStructs = ExtraParamsEstructuraDAO::search(new ExtraParamsEstructura(array("tabla" => "documento_base-" . $DocumentoBase->getIdDocumentoBase()))); $f = new FormComponent(); $f->addApiCall("api/documento/nuevo"); for ($i = 0; $i < sizeof($ExtraParamsStructs); $i++) { // function addField($id, $caption, $type, $value = "", $name = null) { if ($ExtraParamsStructs[$i]->tipo == "enum") { $enum_string = explode(",", $ExtraParamsStructs[$i]->enum); $enum_array = array(); for ($k = 0; $k < count($enum_string); $k++) { array_push($enum_array, array("caption" => $enum_string[$k], "id" => $enum_string[$k], "selected" => 0)); } $f->addField($ExtraParamsStructs[$i]->campo, $ExtraParamsStructs[$i]->caption, $ExtraParamsStructs[$i]->tipo, $enum_array); } else { $f->addField($ExtraParamsStructs[$i]->campo, $ExtraParamsStructs[$i]->caption, $ExtraParamsStructs[$i]->tipo); } } $f->beforeSend("attachExtraParams"); $f->setStyle("big");
$epform->setHelp($ep["campo"], $ep["descripcion"]); } } $epform->beforeSend("editar_extra_p"); $page->addComponent(' <script> var cliente = ' . $_GET["cid"] . '; function editar_extra_p(obj){ return { id_cliente : cliente, extra_params : Ext.JSON.encode(obj) } } </script> '); $epform->addApiCall("api/cliente/editar/", "POST"); $page->addComponent($epform); $page->nextTab("Direccion"); if (is_null($este_cliente->getIdDireccion())) { //no existe direccion Logger::log("El uid=" . $_GET["cid"] . " no tiene direccion. Insertando."); DireccionController::NuevaDireccionParaUsuario($_GET["cid"]); //recargar el objeto de cliente $este_cliente = UsuarioDAO::getByPK($_GET["cid"]); } $esta_dir = DireccionDAO::getByPK($este_cliente->getIdDireccion()); if (is_null($esta_dir)) { //esta definida pero el registro no existe por alguna razon Logger::error("user " . $_GET["cid"] . " se supone que tiene id direccion = " . $este_cliente->getIdDireccion() . " , pero esta en null ..."); DAO::transBegin(); $este_cliente->setIdDireccion(NULL);
$html .= "</script>"; // Configuracion de productos en VC $form = new FormComponent(); $form->addField('mostrar', 'Mostrar productos', 'bool', 'mostrar'); $campos = array_keys(get_class_vars('Producto')); foreach ($campos as $key => $campo) { if ($campo == "visible_en_vc") { unset($campos[$key]); } else { $caption = ucwords(str_replace("_", " ", $campo)); $campos[$key] = array("id" => $campo, "caption" => $caption); } } $form->addField('propiedades', 'Propiedades *', 'listbox', $campos, 'propiedades'); $form->beforeSend('attachPropiedades'); $form->addApiCall('api/pos/configuracion/vistas/clientes'); $html .= <<<EOD <script type='text/javascript' charset='utf-8'> function attachPropiedades(o) { o.propiedades = getParams(); console.log(o.propiedades); return o; } function getParams() { var options = Ext.DomQuery.jsSelect('select[name=propiedades] > option'); var params = new Array(); for (var i = 0; i < options.length; i++) { if (options[i].selected) { params.push(options[i].value); }