$fs = new PhpExt_Form_FormPanel(); $fs->setFrame(true)->setTitle("XML Form")->setLabelAlign(PhpExt_Form_FormPanel::LABEL_ALIGN_RIGHT)->setLabelWidth(85)->setWidth(340)->setWaitMsgTarget(true); // configure how to read the XML Data $reader = new PhpExt_Data_XmlReader(); $reader->setRecord("contact")->setSuccess("@success"); $reader->addField(new PhpExt_Data_FieldConfigObject("first", "name/first")); // custom mapping $reader->addField(new PhpExt_Data_FieldConfigObject("last", "name/last")); $reader->addField(new PhpExt_Data_FieldConfigObject("company", "company")); $reader->addField(new PhpExt_Data_FieldConfigObject("email", "email")); $reader->addField(new PhpExt_Data_FieldConfigObject("state", "state")); $reader->addField(new PhpExt_Data_FieldConfigObject("dob", "dob", "date", "m/d/Y")); // custom data types $fs->setReader($reader); $fs->setErrorReader(new PhpExtUx_Form_XmlErrorReader()); $fset = new PhpExt_Form_FieldSet(); $fset->setTitle("Contact Information")->setAutoHeight(true)->setDefaultType("textfield")->setDefaults(new PhpExt_Config_ConfigObject(array("width" => 190)))->addItem(PhpExt_Form_TextField::createTextField("first", "First Name"))->addItem(PhpExt_Form_TextField::createTextField("last", "Last Name"))->addItem(PhpExt_Form_TextField::createTextField("company", "Company"))->addItem(PhpExt_Form_TextField::createTextField("email", "Email", null, PhpExt_Form_FormPanel::VTYPE_EMAIL)); $combo = PhpExt_Form_ComboBox::createComboBox("state", "State")->setValueField("abbr")->setDisplayField("state")->setTypeAhead(true)->setMode(PhpExt_Form_ComboBox::MODE_LOCAL)->setTriggerAction(PhpExt_Form_ComboBox::TRIGGER_ACTION_ALL)->setEmptyText("Select a state...")->setSelectOnFocus(true); $store = new PhpExt_Data_SimpleStore(); $store->addField("abbr"); $store->addField("state"); $store->setData(PhpExt_Javascript::variable("Ext.exampledata.states")); $combo->setStore($store); $fset->addItem($combo); $fset->addItem(PhpExt_Form_DateField::createDateField("dob", "Data of Birth")->setAllowBlank(false)); $fs->addItem($fset); $fs->addButton(PhpExt_Button::createTextButton("Load", new PhpExt_Handler(PhpExt_Javascript::stm("fs.getForm().load({url:'examples/form/xml-form.xml', waitMsg:'Loading',method: 'GET'})")))); $submitBtn = PhpExt_Button::createTextButton("Submit", new PhpExt_Handler(PhpExt_Javascript::stm("fs.getForm().submit({url:'examples/form/xml-errors.xml', waitMsg:'Saving Data...'})"))); $fs->addButton($submitBtn); //****************************** onReady echo PhpExt_Ext::onReady(PhpExt_Javascript::stm(PhpExt_QuickTips::init()), PhpExt_Javascript::assign("Ext.form.Field.prototype.msgTarget", PhpExt_Javascript::valueToJavascript(PhpExt_Form_FormPanel::MSG_TARGET_SIDE)), $fs->getJavascript(false, "fs"), PhpExt_Javascript::assignNew("submit", $submitBtn->getJavascript()), $fs->render("form-ct"));
//Boton actualizar OnClick $handler_actualizar = "function(){\nthis.findParentByType('form').getForm().submit(\n\t{ \n\t\t\t url : '/seguridad/group/update_process',\n\t\t waitMsg : 'Enviando Datos',\n \t\t waitTitle :'Emporika',\n \t\tsuccess_msg : 'Grupo guardado correctamente',\n\tgrid_reload_id : '{$grid_id}' \n\t}\n\t);\t\t\t\t\n\t\t\t\t\t\t\t }"; $btn_actualizar = PhpExt_Button::createTextButton("Actualizar", new PhpExt_JavascriptStm($handler_actualizar)); //Data_Reader para leer los resultados devueltos $error_reader = new PhpExt_Data_JsonReader(); $error_reader->setRoot("errors"); $error_reader->setSuccessProperty("success"); $error_reader->addField(new PhpExt_Data_FieldConfigObject("id")); $error_reader->addField(new PhpExt_Data_FieldConfigObject("msg")); $id_grupo = array(); $id_grupo["id"] = $grupo->get("group"); //formulario que contiene todos los controles $frm_update_group = new PhpExt_Form_FormPanel(); $frm_update_group->setErrorReader($error_reader)->setBaseParams($id_grupo)->setFrame(true)->setWidth(520)->setAutoHeight(true)->setTitle("Datos del Grupo")->setMethod(PhpExt_Form_FormPanel::METHOD_POST); //marco para contenener los controles $marco = new PhpExt_Form_FieldSet(); $marco->setAutoHeight(true); //agrego todos los controles al marco $marco->addItem($txt_nombre); $marco->addItem($txt_descripcion); $marco->addItem($txt_buscar_usuario); $marco->addItem($select); $frm_update_group->addButton($btn_actualizar); $frm_update_group->addButton(PhpExt_Button::createTextButton("Cancelar")); $frm_update_group->addItem($marco); $resultado = ''; $resultado .= $to_store->getJavascript(false, "tostore"); $resultado .= $from_store->getJavascript(false, "fromstore"); $resultado .= $frm_update_group->getJavascript(false, "contenido"); //RESULTADO $obj_comunication = new OOB_ext_comunication();
$chk_anonimo = PhpExt_Form_Checkbox::createCheckbox("chk_anonimo", "Anónimo")->setMsgTarget(PhpExt_Form_FormPanel::MSG_TARGET_SIDE)->setWidth($field_width); $chk_confiados = PhpExt_Form_Checkbox::createCheckbox("chk_confiados", "Confiado")->setMsgTarget(PhpExt_Form_FormPanel::MSG_TARGET_SIDE)->setWidth($field_width); //Boton grabar OnClick $handler_grabar = " \nfunction(){\nthis.findParentByType('form').getForm().submit(\n\t{ \t \n\t\t\t\t\t\t reset : true,\n\t\t\t\t\t waitMsg : 'Enviando Datos',\n\t\t\t\t\t waitTitle : 'Emporika',\t\t\t\t \n\t\t\t grid_reload_id : '{$grid_id}',\n\t\t\t\t new_tab_dir : '/seguridad/role/update',\n\t\t\t\t new_tab_title : 'Modificar Rol',\n new_tab_pass_response_params : { id : 'id'}, \n\t\t\t\t load_tab_here : true\t \n\t}\n\t\n\t);\t\t\t\t\n\t\n}"; $btn_grabar = PhpExt_Button::createTextButton("Grabar", new PhpExt_JavascriptStm($handler_grabar)); //Data_Reader para leer los resultados devueltos $error_reader = new PhpExt_Data_JsonReader(); $error_reader->setRoot("errors"); $error_reader->setSuccessProperty("success"); $error_reader->addField(new PhpExt_Data_FieldConfigObject("id")); $error_reader->addField(new PhpExt_Data_FieldConfigObject("msg")); //formulario que contiene todos los controles $frm_nuevo_rol = new PhpExt_Form_FormPanel(); $frm_nuevo_rol->setErrorReader($error_reader)->setUrl("/seguridad/role/new_process")->setFrame(true)->setWidth(350)->setAutoHeight(true)->setTitle("Datos del Rol")->setMethod(PhpExt_Form_FormPanel::METHOD_POST); //marco para poner los controles $marco = new PhpExt_Form_FieldSet(); $marco->setDefaults(new PhpExt_Config_ConfigObject(array("width" => 210)))->setAutoHeight(true); //agrego todos los controles al marco $marco->addItem($txt_nombre); $marco->addItem($txt_descripcion); $marco->addItem($chk_anonimo); $marco->addItem($chk_confiados); $frm_nuevo_rol->addItem($marco); $frm_nuevo_rol->addButton($btn_grabar); $frm_nuevo_rol->addButton(PhpExt_Button::createTextButton("Cancelar")); //RESULTADO $obj_comunication = new OOB_ext_comunication(); $obj_comunication->set_data($frm_nuevo_rol->getJavascript(false, "contenido")); $obj_comunication->send(true); ?>
$store->setData($myData) */ $italicRenderer = PhpExt_Javascript::functionDef("italic", "return '<i>' + value + '</i>'", array("value")); $changeRenderer = PhpExt_Javascript::functionDef("change", "if(val > 0){\r\n return '<span style=\"color:green;\">' + val + '</span>';\r\n }else if(val < 0){\r\n return '<span style=\"color:red;\">' + val + '</span>';\r\n }\r\n return val;", array("val")); $pctChangeRenderer = PhpExt_Javascript::functionDef("pctChange", "if(val > 0){\r\n return '<span style=\"color:green;\">' + val + '%</span>';\r\n }else if(val < 0){\r\n return '<span style=\"color:red;\">' + val + '%</span>';\r\n }\r\n return val;", array("val")); // ColumnModel $colModel = new PhpExt_Grid_ColumnModel(); $colModel->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Company", "company", "company", 160, null, null, true, false))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Price", "price", null, 75, null, PhpExt_Javascript::variable("Ext.util.Format.usMoney"), null, true))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Change", "change", null, 75, null, PhpExt_Javascript::variable('change'), null, true))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("% Change", "pctChange", null, 75, null, PhpExt_Javascript::variable('pctChange'), null, true))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Last Updated", "lastChange", null, 75, null, PhpExt_Javascript::variable("Ext.util.Format.dateRenderer('m/d/Y')"), null, true)); // Form Panel $gridForm = new PhpExt_Form_FormPanel("company-form"); $gridForm->setFrame(true)->setLabelAlign(PhpExt_Form_FormPanel::LABEL_ALIGN_LEFT)->setTitle("Company Data")->setBodyStyle("padding: 5px;")->setWidth(750)->setLayout(new PhpExt_Layout_ColumnLayout()); // Setup Grid $leftPanel = new PhpExt_Panel(); $leftPanel->setLayout(new PhpExt_Layout_FitLayout()); $selModel = new PhpExt_Grid_RowSelectionModel(); $selModel->setSingleSelect(true)->attachListener("rowselect", new PhpExt_Listener(PhpExt_Javascript::functionDef(null, "Ext.getCmp(\"company-form\").getForm().loadRecord(rec);", array("sm", "row", "rec")))); $grid = new PhpExt_Grid_GridPanel(); $grid->setStore($store)->setColumnModel($colModel)->setSelectionModel($selModel)->setAutoExpandColumn("company")->setHeight(350)->setTitle("Company Data")->setBorder(true)->attachListener("render", new PhpExt_Listener(PhpExt_Javascript::functionDef(null, "g.getSelectionModel().selectRow(0);", array("g")), null, 10)); $leftPanel->addItem($grid); $gridForm->addItem($leftPanel, new PhpExt_Layout_ColumnLayoutData(0.6)); // Setup Fields $rightPanel = new PhpExt_Form_FieldSet(); $rightPanel->setLabelWidth(90)->setTitle("Company Details")->setDefaults(new PhpExt_Config_ConfigObject(array("width" => 140)))->setDefaultType("textfield")->setAutoHeight(true)->setBodyStyle(PhpExt_Javascript::inlineStm("Ext.isIE ? 'padding:0 0 5px 15px;' : 'padding:10px 15px;'"))->setBorder(false)->setCssStyle(new PhpExt_Config_ConfigObject(array("margin-left" => "10px", "margin-right" => PhpExt_Javascript::inlineStm('Ext.isIE6 ? (Ext.isStrict ? "-10px" : "-13px") : "0"')))); $rightPanel->addItem(PhpExt_Form_TextField::createTextField("company", "Name")); $rightPanel->addItem(PhpExt_Form_TextField::createTextField("price", "Price")); $rightPanel->addItem(PhpExt_Form_TextField::createTextField("pctChange", "% Change")); $rightPanel->addItem(PhpExt_Form_TextField::createTextField("lastChange", "Last Updated")); $gridForm->addItem($rightPanel, new PhpExt_Layout_ColumnLayoutData(0.4)); $gridForm->setRenderTo(PhpExt_Javascript::variable("Ext.get('centercolumn')")); //****************************** onReady echo PhpExt_Ext::onReady(PhpExt_Javascript::stm(PhpExt_QuickTips::init()), PhpExt_Javascript::assign("data", PhpExt_Javascript::valueToJavascript($myData)), $store->getJavascript(false, "ds"), $italicRenderer, $changeRenderer, $pctChangeRenderer, $colModel->getJavascript(false, "colModel"), $gridForm->getJavascript(false, "gridForm"));
$email = PhpExt_Form_TextField::createTextField("email", "Email", null, PhpExt_Form_FormPanel::VTYPE_EMAIL); $time = PhpExt_Form_TimeField::createTimeField("time", "Time")->setMinValue("8:00am")->setMaxValue("6:00pm"); $simple->addItem($firstName)->addItem($lastName)->addItem($company)->addItem($email)->addItem($time); $simple->addButton(PhpExt_Button::createTextButton("Save")); $simple->addButton(PhpExt_Button::createTextButton("Cancel")); //****************************** Adding Fieldset $fsf = new PhpExt_Form_FormPanel(); $fsf->setLabelWidth(75)->setUrl("save-form.php")->setFrame(true)->setTitle("Simple Form with FieldSets")->setBodyStyle("padding:5px 5px 0")->setWidth(350); //- Fielset 1 $fieldset1 = new PhpExt_Form_FieldSet(); $fieldset1->setCheckboxToggle(true)->setTitle("User Information")->setAutoHeight(true)->setDefaults(new PhpExt_Config_ConfigObject(array("width" => 210)))->setCollapsed(true); // Use the helper function to easily create fields to add them inline $fieldset1->addItem(PhpExt_Form_TextField::createTextField("first", "First Name")->setAllowBlank(false))->addItem(PhpExt_Form_TextField::createTextField("last", "Last Name"))->addItem(PhpExt_Form_TextField::createTextField("company", "Company"))->addItem(PhpExt_Form_TextField::createTextField("email", "Email")->setVType(PhpExt_Form_FormPanel::VTYPE_EMAIL)); $fsf->addItem($fieldset1); //- Fieldset 2 $fieldset2 = new PhpExt_Form_FieldSet(); $fieldset2->setTitle("Phone Number")->setCollapsible(true)->setAutoHeight(true)->setDefaults(new PhpExt_Config_ConfigObject(array("width" => 210)))->addItem(PhpExt_Form_TextField::createTextField("home", "Home")->setValue("(888) 555-1212"))->addItem(PhpExt_Form_TextField::createTextField("business", "Business"))->addItem(PhpExt_Form_TextField::createTextField("mobile", "Mobile"))->addItem(PhpExt_Form_TextField::createTextField("fax", "Fax")); $fsf->addItem($fieldset2); //- Buttons $fsf->addButton(PhpExt_Button::createTextButton("Save")); $fsf->addButton(PhpExt_Button::createTextButton("Cancel")); //****************************** A little more complex $top = new PhpExt_Form_FormPanel(); $top->setLabelAlign(PhpExt_Form_FormPanel::LABEL_ALIGN_TOP)->setFrame(true)->setTitle("Multi Column, Nested Layouts and Anchoring")->setBodyStyle("padding:5px 5px 0")->setWidth(600); $columnPanel = new PhpExt_Panel(); // using ColumnLayout $columnPanel->setLayout(new PhpExt_Layout_ColumnLayout()); $top->addItem($columnPanel); //- First column $firstColumn = new PhpExt_Panel(); // Use FormLayout to enable field labels and autoarrange fields on the panel
//e-mail $txt_email = PhpExt_Form_TextField::createTextField("txt_email", "E-mail", null, PhpExt_Form_FormPanel::VTYPE_EMAIL)->setWidth($field_width)->setMsgTarget(PhpExt_Form_FormPanel::MSG_TARGET_SIDE); //Boton actualizar OnClick $handler_grabar = "\nfunction(){\n\nthis.findParentByType('form').getForm().submit(\n\t{ \n\t\t\treset : true,\n\t\t waitMsg : 'Enviando Datos',\n\t\twaitTitle : 'Emporika',\n\t success_msg : 'Usuario creado correctamente',\n grid_reload_id : '{$grid_id}'\t\t\t\t \t \n\t}\t\n\t);\t\t\t\t\n\t\t}"; $btn_grabar = PhpExt_Button::createTextButton("Grabar", new PhpExt_JavascriptStm($handler_grabar)); //JSON_Reader para leer los resultados devueltos $error_reader = new PhpExt_Data_JsonReader(); $error_reader->setRoot("errors"); $error_reader->setSuccessProperty("success"); $error_reader->addField(new PhpExt_Data_FieldConfigObject("id")); $error_reader->addField(new PhpExt_Data_FieldConfigObject("msg")); //formulario que contiene todos los controles $frm_nuevo_usuario = new PhpExt_Form_FormPanel(); $frm_nuevo_usuario->setUrl("/seguridad/user/new_process")->setErrorReader($error_reader)->setFrame(true)->setWidth(350)->setAutoHeight(true)->setTitle("Datos del usuario")->setMethod(PhpExt_Form_FormPanel::METHOD_POST); //marco para contenener los controles $marco = new PhpExt_Form_FieldSet(); $marco->setDefaults(new PhpExt_Config_ConfigObject(array("width" => 210)))->setAutoHeight(true); //se agregan todos los controles al marco $marco->addItem($txt_usuario); $marco->addItem($txt_password); $marco->addItem($txt_repetir); $marco->addItem($txt_email); //se agrega el marco al formulario $frm_nuevo_usuario->addItem($marco); //se agregan los botones al formulario $frm_nuevo_usuario->addButton($btn_grabar); $frm_nuevo_usuario->addButton(PhpExt_Button::createTextButton("Cancelar")); //RESULTADO $obj_comunication = new OOB_ext_comunication(); $obj_comunication->set_data($frm_nuevo_usuario->getJavascript(false, "contenido")); $obj_comunication->send(true);
$select_idioma = new PhpExtUx_Itemselector(); $select_idioma->setName("idiomas")->setFieldLabel("Idioma")->setToLegend("Predeterminado")->setFromLegend("No")->settoData(array())->setfromData(PhpExt_Javascript::variable(json_encode($idiomas_list)))->setvalueField("id")->setdisplayField("name")->setmsHeight(150)->setmsWidth(120)->setdataFields(PhpExt_Javascript::variable('["id", "name"]'))->setimagePath("/scripts/ext/resources/extjs-ux/multiselect/"); //BOTON GRABAR ONCLICK $handler_save = " \nfunction(){\n\nvar form = this.findParentByType('form');\nvar selector = form.findBy(function(c){ return (c.xtype == 'itemselector') });\t\n\nif( selector[0].toStore.getCount() == 0 ){\n\tExt.MessageBox.alert( 'Emporika', 'Debe seleccionar un idioma' ); \n\treturn false;\n}\n\nvar a_params = '';\nvar field = form.getForm().findField('txt_valor');\n\nvar predeterminada = form.findBy(function(c){ return ( c.xtype == 'radiogroup' ) });\nvar opt = predeterminada[1].items.items[0];\t\n\nif( field.disabled ){\n\ta_params = { txt_valor : 1 , tipo : 'float', predeterminada : opt.getValue() }\n}else{\n\ta_params = { tipo : 'fixed', predeterminada : opt.getValue() }\n}\n\nform.getForm().submit(\n\t{ \n\t\t waitMsg : 'Enviando Datos',\n\t\t\treset : true,\n\t\t params : a_params,\n\t\twaitTitle : 'Emporika',\n\t success_msg : 'Moneda guardada correctamente',\n grid_reload_id : '{$grid_id}'\n\t \n\t}\n\t);\t\t\t\t\t\n}\n"; $save_button = PhpExt_Button::createTextButton("Grabar", new PhpExt_JavascriptStm($handler_save)); //Data_Reader para leer los resultados devueltos $error_reader = new PhpExt_Data_JsonReader(); $error_reader->setRoot("errors"); $error_reader->setSuccessProperty("success"); $error_reader->addField(new PhpExt_Data_FieldConfigObject("id")); $error_reader->addField(new PhpExt_Data_FieldConfigObject("msg")); //FORMULARIO $frm_new_currency = new PhpExt_Form_FormPanel(); $frm_new_currency->setErrorReader($error_reader)->setFrame(true)->setUrl("/currency/currency/new_process")->setWidth(400)->setAutoHeight(true)->setTitle("Datos de la moneda")->setMethod(PhpExt_Form_FormPanel::METHOD_POST); //MARCO PARA CONTENER LOS CONTROLES $marco = new PhpExt_Form_FieldSet(); $marco->setAutoHeight(true); //AGREGO TODOS LOS CONTROLES AL MARCO $marco->addItem($txt_moneda); $marco->addItem($txt_signo); $marco->addItem($opt_group_tipo_cambio); $marco->addItem($txt_valor); $marco->addItem($opt_group_predeterminada); $marco->addItem($select_idioma); //AGREGO EL MARCO AL FORMULARIO $frm_new_currency->addItem($marco); //AGREGO LOS BOTONES AL FORMULARIO $frm_new_currency->addButton($save_button); $frm_new_currency->addButton(PhpExt_Button::createTextButton("Cancelar")); //RESULTADO $obj_comunication = new OOB_ext_comunication();
$error_reader = new PhpExt_Data_JsonReader(); $error_reader->setRoot("errors"); $error_reader->setSuccessProperty("success"); $error_reader->addField(new PhpExt_Data_FieldConfigObject("id")); $error_reader->addField(new PhpExt_Data_FieldConfigObject("msg")); $modulos = PhpExt_Form_Hidden::createHidden("modulos"); $id_role = array(); $id_role["id"] = $role->get("role"); //formulario que contiene todos los controles $frm_update_role = new PhpExt_Form_FormPanel(); $frm_update_role->setErrorReader($error_reader)->setBaseParams($id_role)->setUrl("/seguridad/role/update_process")->setFrame(true)->setWidth(580)->setHeight(400)->setTitle("Datos del rol")->setMethod(PhpExt_Form_FormPanel::METHOD_POST); $form_render = "\n\tvar chk = form.findBy( function(c){ return ( c.name == 'chk_anonimo' ); } );\t\t\t\n\tvar panel_usuarios = form.findBy( function(c){ return (c.xtype == 'panel' && c.title == 'Usuarios' ) } );\t\t\t\n\tvar panel_grupos = form.findBy( function(c){ return (c.xtype == 'panel' && c.title == 'Grupos' ) } );\t\t\t\n\n\tvar groups = form.findBy( function(c){ return ( c.name == 'grupos' ) } );\t\t\t\n\tvar users = form.findBy( function(c){ return ( c.name == 'usuarios' ) } );\t\t\t\n\t\n\tchk[0].on( 'check', function(t,c){\n\t\n\t\n\n\tif( ( groups[0].toStore.getCount() != 0 ) || ( users[0].toStore.getCount() != 0 ) ){\t\n\t\tt.setValue(false);\n\t\tpanel_usuarios[0].setDisabled(false);\n\t\tpanel_grupos[0].setDisabled(false);\n\t}\n\telse\n\t{\n\t\tpanel_usuarios[0].setDisabled(c);\n\t\tpanel_grupos[0].setDisabled(c);\n\t}\t\n});\n\n"; $frm_update_role->setEnableKeyEvents(true); $frm_update_role->attachListener("render", new PhpExt_Listener(PhpExt_Javascript::functionDef(null, $form_render, array("form")))); //marco para contenener los controles $marco = new PhpExt_Form_FieldSet(); $marco->setAutoHeight(true); //agrego todos los controles al marco $marco->addItem($tab_panel); $marco->addItem($modulos); $frm_update_role->addButton($btn_actualizar); $frm_update_role->addButton(PhpExt_Button::createTextButton("Cancelar")); $frm_update_role->addItem($marco); //RESULTADOS $resultado = ''; $resultado .= $grupos_to_store->getJavascript(false, "grupos_tostore"); $resultado .= $grupos_from_store->getJavascript(false, "grupos_fromstore"); $resultado .= $usuarios_to_store->getJavascript(false, "usuarios_tostore"); $resultado .= $usuarios_from_store->getJavascript(false, "usuarios_fromstore"); $resultado .= $frm_update_role->getJavascript(false, "contenido"); //RESULTADO