Exemplo n.º 1
0
include_once "PhpExtUx/App/SearchField.php";
// Configure Reader and Store
$reader = new PhpExt_Data_JsonReader();
$reader->setRoot("topics")->setTotalProperty("totalCount")->setId("post_id");
$reader->addField(new PhpExt_Data_FieldConfigObject("postId", "post_id"));
$reader->addField(new PhpExt_Data_FieldConfigObject("title", "topic_title"));
$reader->addField(new PhpExt_Data_FieldConfigObject("topicId", "topic_id"));
$reader->addField(new PhpExt_Data_FieldConfigObject("author", "author"));
$reader->addField(new PhpExt_Data_FieldConfigObject("lastPost", "post_time", "date", "timestamp"));
$reader->addField(new PhpExt_Data_FieldConfigObject("excerpt", "post_text"));
$ds = new PhpExt_Data_Store();
$ds->setProxy(new PhpExt_Data_ScriptTagProxy('http://extjs.com/forum/topics-remote.php'))->setReader($reader)->setBaseParams(array("limit" => 20, "forumId" => 21));
// ->setBaseParams(new PhpExt_Config_ConfigObject(array("limit"=>20,"forumId"=>21));
// Configure Custom SearchField
$resultTpl = new PhpExt_XTemplate('<tpl for=".">', '<div class="search-item">', '<h3><span>{lastPost:date("M j, Y")}<br />by {author}</span>', '<a href="http://extjs.com/forum/showthread.php?t={topicId}&p={postId}" target="_blank">{title}</a></h3>', '<p>{excerpt}</p>', '</div></tpl>');
$panel = new PhpExt_Panel();
$panel->setApplyTo("search-panel")->setTitle("Forum Search")->setHeight(300)->setAutoScroll(true);
$dv = new PhpExt_DataView("div.search-item");
$dv->setStore($ds)->setTemplate($resultTpl);
$panel->addItem($dv);
$searchField = new PhpExtUx_App_SearchField();
$searchField->setStore($ds)->setWidth(320);
$tb = $panel->getTopToolbar();
$tb->addTextItem(1, "Search: ");
$tb->addSpacer(2);
$tb->addItem(3, $searchField);
$paging = new PhpExt_Toolbar_PagingToolbar();
$paging->setStore($ds)->setPageSize(20)->setDisplayInfo("Topics {0} - {1} of {2}")->setEmptyMessage("No topics to display");
$panel->setBottomToolbar($paging);
//------------ Ext.OnReady
echo PhpExt_Ext::onReady($ds->getJavascript(false, "ds"), $resultTpl->getJavascript(false, "resultTpl"), $panel->getJavascript(false, "panel"), $ds->load(new PhpExt_Data_StoreLoadOptions(array("start" => 0, "limit" => 0, "forumId" => 21, "query" => "\"PHP-Ext 0.\""))));
Exemplo n.º 2
0
$grid = new PhpExt_Grid_GridPanel();
$grid->setStore($store)->setSelectionModel($check_select)->setColumnModel($col_model)->setLoadMask(true)->setenableColLock(false);
$grid->getPlugins()->add($filter_plugin);
$grid->getPlugins()->add(new PhpExtUx_App_FitToParent());
$grid_render = "\n\nvar combo = grid.getTopToolbar().items.find( function(c){ return ( c.xtype == 'combo') } );\nvar store = grid.getStore();\n\n\tvar nuevo = function(){\n\t\tvar id = 'gid=' + grid.id ;\n\t\taddTab( 'Nuevo Usuario', '/seguridad/user/new', true, id );\n\t}\n\nvar edit = function(){\n\t\n\t\t\tvar id;\n\t\t\tvar m = grid.getSelections();\n\n\t\t\tif( m.length >= 1 ){\t\n\t\t\t\tfor( var i = 0, len = m.length; i < len; i++ ){\t\t\t\t\t\n\t\t\t\t\t\tvar id = 'id=' + m[i].get('id') + '&gid=' + grid.id ;\n\t\t\t\t\t\taddTab('Modificar Usuario','/seguridad/user/update',true,id);\t\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tExt.MessageBox.alert('Emporika', 'Por favor seleccione un item');\n\t\t\t}\t\t\t\n}\n\n\tvar save = function(){\n\t\n\tif( combo.getValue() == '' ){\n\t\tExt.Msg.alert('Nutus Econom&iacute;a', 'Debe seleccionar un estado' );\t\n\t}\n\telse\n\t{\n\t\n\t\tvar m = grid.getSelections();\n        if(m.length > 0)\n        {\n        \tExt.MessageBox.confirm( 'Emporika', 'Esta seguro que desea cambiar el estado?' , function(btn){\n\t\t\t\t\n\t\t\t\tif( btn == 'yes' ){\t\n\t\t\t\t\tvar m = grid.getSelections();\n\t\t\t\t\t\n\t\t\t\t\tvar items = Array();\n\t\t\t\t\tfor(var i = 0, len = m.length; i < len; i++){  \n\t\t\t\t\t\tvar item = { id : m[i].get('id') };\n\t\t\t\t\t\titems.push(item);\n\t\t\t\t\t}\n\t\t\t\t\tvar json = { \n\t\t\t\t\t\t\t\t status : combo.getRawValue() ,\n\t\t\t\t\t\t\t\t  items : items\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t   }\t\t\t\t\t\n\t\t\t\t\t\t   \n\t\t\t\t\tvar pag = grid.getStore().lastOptions.params['start'];\n\t\t\t\t\tgrid.getStore().load( { params : { start : pag, limit: {$page_size} , UpdateStateData: Ext.encode(json) } } );\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}, this );\t\n        }\n        else\n        {\n        \tExt.MessageBox.alert('Emporika', 'Por favor seleccione un item');\n        }\n\n\t}\n\t\n\t}\n\n\nvar eliminar = function(){\n\t\n\tvar m = grid.getSelections();\n        if(m.length > 0)\n        {\n\t\t\tvar msg = 'Esta seguro que desea eliminar ' + ((m.length>1)?'los':'el') + ' usuario' + ((m.length>1)?'s':'') + '?';\n        \tExt.MessageBox.confirm('Emporika', msg , \n\t\t\tfunction(btn){\n\t\t\t\t\tif( btn == 'yes' ){\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tvar items = Array();\n\t\t\t\t\t\t\tfor(var i = 0, len = m.length; i < len; i++){  \n\t\t\t\t\t\t\t\tvar item = { id: m[i].get('id') };\n\t\t\t\t\t\t\t\titems.push( item );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tvar pag = grid.getStore().lastOptions.params['start'];\t\n\t\t\t\t\t\t\tstore.load( { params:{ \n\t\t\t\t\t\t\t\t\t\t\t\tstart: pag,\n\t\t\t\t\t\t\t\t\t\t\t\tlimit: {$page_size} , \n\t\t\t\t\t\t\t\t\t\tDeleteUserData: Ext.encode(items) \n\t\t\t\t\t\t\t\t\t\t\t\t}\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t  });\t\t\n\t\t\t\t\t}\t\t\n\t\t\t}, this );\t\n        }\n        else\n        {\n        \tExt.MessageBox.alert('Emporika', 'Por favor seleccione un item');\n        }\n}\t\n\t\nvar button1 = grid.getTopToolbar().items.find( function(c){ return ( c.text == 'Nuevo') } );\nbutton1.on( 'click', nuevo );\n\nvar button2 = grid.getTopToolbar().items.find( function(c){ return ( c.text == 'Modificar') } );\nbutton2.on( 'click', edit );\n\nvar button3 = grid.getTopToolbar().items.find( function(c){ return ( c.text == 'Guardar cambios') } );\nbutton3.on( 'click', save );\n\nvar button4 = grid.getTopToolbar().items.find( function(c){ return ( c.text == 'Eliminar') } );\nbutton4.on( 'click', eliminar );\n\ngrid.on( 'celldblclick', edit );\n\n";
$grid->setEnableKeyEvents(true);
$grid->attachListener("render", new PhpExt_Listener(PhpExt_Javascript::functionDef(null, $grid_render, array("grid"))));
//SETEO LA BARRA DE PAGINACION
$grid->setBottomToolbar($paging);
//Data_Store para llenar el combo con los datos
$store_estados = new PhpExt_Data_SimpleStore();
$store_estados->addField("id");
$store_estados->addField("descripcion");
$store_estados->setData(PhpExt_Javascript::variable(json_encode($estados)));
$cbo_estados = PhpExt_Form_ComboBox::createComboBox(null, "Estado")->setWidth(80)->setStore($store_estados)->setDisplayField("descripcion")->setValueField("id")->setEditable(false)->setForceSelection(true)->setSingleSelect(true)->setEmptyText("seleccionar")->setMode(PhpExt_Form_ComboBox::MODE_LOCAL)->setTriggerAction(PhpExt_Form_ComboBox::TRIGGER_ACTION_ALL);
$txt_busqueda = new PhpExtUx_App_SearchField();
$txt_busqueda->setStore($store);
$tb = $grid->getTopToolbar();
$tb->addButton("new", "Nuevo", "images/add.png");
$tb->addSeparator("sep1");
$tb->addButton("modificar", "Modificar", "images/edit.gif");
$tb->addSeparator("sep2");
$tb->addButton("delete", "Eliminar", "images/no_.gif");
$tb->addSeparator("sep3");
$tb->addTextItem("text2", "Buscar:");
$tb->addItem("txt_busqueda", $txt_busqueda);
$tb->addFill("fill");
$tb->addTextItem("text", "Modificar estado:");
$tb->addItem("estados", $cbo_estados);
$tb->addButton("guardar", "Guardar cambios", "images/save.gif");
//resultados
Exemplo n.º 3
0
$page_size = PAGE_SIZE;
//controles
//nombre del grupo
$txt_nombre = PhpExt_Form_TextField::createTextField("txt_nombre", "Nombre")->setWidth($field_width)->setMsgTarget(PhpExt_Form_FormPanel::MSG_TARGET_SIDE)->setValue($grupo->get("name"));
//descripcion del grupo
$txt_descripcion = PhpExt_Form_TextArea::createTextArea("txt_descripcion", "Descripci&oacute;n")->setMsgTarget(PhpExt_Form_FormPanel::MSG_TARGET_SIDE)->setWidth($field_width)->setValue($grupo->get("description"));
$from_store = new PhpExt_Data_JsonStore();
$from_store->setUrl("/seguridad/group/get_nomembers")->setRoot("topics")->setBaseParams(array("id" => $grupo->get("group")))->setTotalProperty("totalCount");
$from_store->addField(new PhpExt_Data_FieldConfigObject("id", "id"));
$from_store->addField(new PhpExt_Data_FieldConfigObject("uname", "uname"));
$to_store = new PhpExt_Data_JsonStore();
$to_store->setUrl("/seguridad/group/get_members")->setRoot("topics")->setAutoLoad("true")->setBaseParams(array("id" => $grupo->get("group")))->setTotalProperty("totalCount");
$to_store->addField(new PhpExt_Data_FieldConfigObject("id", "id"));
$to_store->addField(new PhpExt_Data_FieldConfigObject("uname", "uname"));
//TXT DE BUSQUEDA DE USUARIOS
$txt_buscar_usuario = new PhpExtUx_App_SearchField();
$txt_buscar_usuario->setFieldLabel("Buscar")->setStore($from_store);
//control para seleccionar los usuarios
$select = new PhpExtUx_Itemselector();
$select->setName("usuarios")->setFieldLabel("Usuarios")->setToLegend("Miembros")->setFromLegend("No Miembros")->setvalueField("id")->setdisplayField("uname")->setmsHeight(160)->setmsWidth($field_width)->setToStore($to_store)->setFromStore($from_store)->setdataFields(PhpExt_Javascript::variable('["id", "uname"]'))->setimagePath("/scripts/ext/resources/extjs-ux/multiselect/");
//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");
Exemplo n.º 4
0
$usuarios_to_store->addField(new PhpExt_Data_FieldConfigObject("id", "id"));
$usuarios_to_store->addField(new PhpExt_Data_FieldConfigObject("uname", "uname"));
$tab_general = new PhpExt_Panel();
$tab_general->setTitle("General")->setLayout(new PhpExt_Layout_FormLayout());
$tab_general->addItem($txt_nombre);
$tab_general->addItem($txt_descripcion);
$tab_general->addItem($chk_anonimo);
$tab_general->addItem($chk_confiados);
$tab_panel->addItem($tab_general);
$tab_usuarios = new PhpExt_Panel();
$tab_usuarios->setTitle("Usuarios")->setLayout(new PhpExt_Layout_FormLayout());
if ($role->get("anonymous") == ANONIMO) {
    $tab_usuarios->setDisabled(true);
}
//TXT DE BUSQUEDA DE USUARIOS
$txt_buscar_usuario = new PhpExtUx_App_SearchField();
$txt_buscar_usuario->setFieldLabel("Buscar")->setStore($usuarios_from_store);
//control para seleccionar los usuarios
$select_usuarios = new PhpExtUx_Itemselector();
$select_usuarios->setName("usuarios")->setFieldLabel("Usuarios")->setToLegend("Miembros")->setFromLegend("No Miembros")->setvalueField("id")->setdisplayField("uname")->setmsHeight(230)->setmsWidth($field_width)->setToStore($usuarios_to_store)->setFromStore($usuarios_from_store)->setdataFields(PhpExt_Javascript::variable('["id", "uname"]'))->setimagePath("/scripts/ext/resources/extjs-ux/multiselect/");
$tab_usuarios->addItem($txt_buscar_usuario);
$tab_usuarios->addItem($select_usuarios);
$tab_panel->addItem($tab_usuarios);
$tab_grupos = new PhpExt_Panel();
$tab_grupos->setTitle("Grupos")->setLayout(new PhpExt_Layout_FormLayout());
if ($role->get("anonymous") == ANONIMO) {
    $tab_grupos->setDisabled(true);
}
$grupos_from_store = new PhpExt_Data_JsonStore();
$grupos_from_store->setUrl("/seguridad/role/get_groups_nomembers")->setRoot("topics")->setAutoLoad("true")->setBaseParams(array("id" => $role->get("role")))->setTotalProperty("totalCount");
$grupos_from_store->addField(new PhpExt_Data_FieldConfigObject("id", "id"));