Example #1
0
$store = new PhpExt_Data_JsonStore();
$store->setUrl("/seguridad/permission/get_permissions")->setRoot("topics")->setTotalProperty("totalCount");
//DEFINICION DE LOS CAMPOS DEL STORE
$store->addField(new PhpExt_Data_FieldConfigObject("id"));
$store->addField(new PhpExt_Data_FieldConfigObject("nombre"));
$store->addField(new PhpExt_Data_FieldConfigObject("descripcion"));
$store->addField(new PhpExt_Data_FieldConfigObject("modulo"));
$store->addField(new PhpExt_Data_FieldConfigObject("contacto"));
$store->addField(new PhpExt_Data_FieldConfigObject("sucursal::nombre"));
$store->addField(new PhpExt_Data_FieldConfigObject("sucursal"));
$filter_plugin = new PhpExtUx_Grid_GridFilters();
$filter_plugin->addFilter(PhpExt_Grid_FilterConfigObject::createFilter("numeric", "id"));
$filter_plugin->addFilter(PhpExt_Grid_FilterConfigObject::createFilter("string", "nombre"));
$filter_plugin->addFilter(PhpExt_Grid_FilterConfigObject::createFilter("string", "contacto::apellido"));
$filter_plugin->addFilter(PhpExt_Grid_FilterConfigObject::createFilter("string", "sucursal::nombre"));
$paging = new PhpExt_Toolbar_PagingToolbar();
$paging->setStore($store)->setPageSize($page_size)->setDisplayInfo(true)->setEmptyMessage("No se encontraron permisos");
$paging->getPlugins()->add($filter_plugin);
$txt_nombre = new PhpExt_Form_TextField();
$txt_descripcion = new PhpExt_Form_TextField();
$modulos = array();
if ($listado_modulos = OOB_module::listModules()) {
    foreach ($listado_modulos as $modulo) {
        $modulos[] = array($modulo->name(), $modulo->nicename());
    }
    //end each
}
//end if
$store_modulos = new PhpExt_Data_SimpleStore();
$store_modulos->addField("id");
$store_modulos->addField("detalle");
Example #2
0
 public static function Render($dataModel, $object, $PageSize = 5, $Titulo = '')
 {
     include_once 'PhpExt/Ext.php';
     include_once 'PhpExt/Data/SimpleStore.php';
     include_once 'PhpExt/Data/ArrayReader.php';
     include_once 'PhpExt/Data/JsonReader.php';
     include_once 'PhpExt/Data/ScriptTagProxy.php';
     include_once 'PhpExt/Data/FieldConfigObject.php';
     include_once 'PhpExt/Data/StoreLoadOptions.php';
     include_once 'PhpExt/Data/HttpProxy.php';
     include_once 'PhpExt/Data/JsonStore.php';
     include_once 'PhpExt/Button.php';
     include_once 'PhpExt/Toolbar/PagingToolbar.php';
     include_once 'PhpExt/Grid/ColumnModel.php';
     include_once 'PhpExt/Grid/ColumnConfigObject.php';
     include_once 'PhpExt/Grid/GridPanel.php';
     include_once 'PhpExt/Window.php';
     include_once 'PhpExt/Form/FormPanel.php';
     include_once 'PhpExt/Ext.php';
     include_once 'PhpExt/Data/Store.php';
     include_once 'PhpExt/Data/ArrayReader.php';
     include_once 'PhpExt/Data/FieldConfigObject.php';
     include_once 'PhpExt/Grid/ColumnModel.php';
     include_once 'PhpExt/Grid/ColumnConfigObject.php';
     include_once 'PhpExt/Panel.php';
     include_once 'PhpExt/Grid/GridPanel.php';
     include_once 'PhpExt/Grid/RowSelectionModel.php';
     include_once 'PhpExt/Listener.php';
     include_once 'PhpExt/Config/ConfigObject.php';
     include_once 'PhpExt/Form/FormPanel.php';
     include_once 'PhpExt/Form/FieldSet.php';
     include_once 'PhpExt/Form/TextField.php';
     include_once 'PhpExt/QuickTips.php';
     include_once 'PhpExt/Layout/ColumnLayout.php';
     include_once 'PhpExt/Layout/ColumnLayoutData.php';
     include_once 'PhpExt/Layout/FitLayout.php';
     $reader = new PhpExt_Data_JsonReader();
     $reader->setRoot("topics")->setTotalProperty("totalCount")->setId("ID");
     foreach ($object->properties as $k => $v) {
         $reader->addField(new PhpExt_Data_FieldConfigObject($k));
     }
     $store = new PhpExt_Data_Store();
     $store->setUrl('action_main.php')->setReader($reader)->setBaseParams(array("limit" => $PageSize));
     $colModel = new PhpExt_Grid_ColumnModel();
     foreach ($object->properties as $k => $v) {
         if (strpos($k, "S_") !== 0) {
             $colModel->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn($object->properties_desc[$k], $k, $k, null, null, null, true, true));
         }
     }
     readfile(dirname(__FILE__) . "/local/Tmpl/PhpExt.tmpl");
     $selModel = new PhpExt_Grid_RowSelectionModel();
     $selModel->setSingleSelect(true)->attachListener("rowselect", new PhpExt_Listener(PhpExt_Javascript::functionDef(null, "Ext.getCmp(\"idGrid\").getForm().loadRecord(rec);", array("sm", "row", "rec"))));
     // Grid
     $grid = new PhpExt_Grid_GridPanel("idGrid");
     $grid->setStore($store)->setColumnModel($colModel)->setStripeRows(true)->setWidth(500)->setHeight(350)->setTitle("Elementos");
     $grid->setSelectionModel($selModel);
     $paging = new PhpExt_Toolbar_PagingToolbar();
     $paging->setStore($store)->setPageSize($PageSize)->setDisplayInfo("Topics {0} - {1} of {2}")->setEmptyMessage("No topics to display");
     $grid->setBottomToolbar($paging);
     $window = new PhpExt_Window();
     $window->setTitle($Titulo)->setWidth(600)->setHeight(450)->setMinWidth(300)->setMinHeight(200)->setPlain(true)->setBodyStyle("padding:5px")->setButtonAlign(PhpExt_Ext::HALIGN_CENTER);
     $window->addButton(PhpExt_Button::createTextButton("Editar"));
     $window->addButton(PhpExt_Button::createTextButton("Borrar"));
     $window->addItem($grid);
     // Ext.OnReady -----------------------
     echo PhpExt_Ext::onReady(null, null, $store->getJavascript(false, "store"), $store->load(new PhpExt_Data_StoreLoadOptions(array("start" => 0, "limit" => $PageSize))), $grid->getJavascript(false, "grid"), $window->getJavascript(false, "window"), $window->show());
     echo "</script>";
 }
Example #3
0
include_once 'PhpExt/Data/HttpProxy.php';
include_once 'PhpExt/Data/JsonStore.php';
include_once 'PhpExt/Toolbar/PagingToolbar.php';
include_once 'PhpExt/Grid/ColumnModel.php';
include_once 'PhpExt/Grid/ColumnConfigObject.php';
include_once 'PhpExt/Grid/GridPanel.php';
$PageSize = 10;
$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"));
$reader = new PhpExt_Data_JsonReader();
$reader->setRoot("topics")->setTotalProperty("totalCount")->setId("id");
$reader->addField(new PhpExt_Data_FieldConfigObject("company"));
$reader->addField(new PhpExt_Data_FieldConfigObject("price", null, "float"));
$reader->addField(new PhpExt_Data_FieldConfigObject("change", null, "float"));
$reader->addField(new PhpExt_Data_FieldConfigObject("pctChange", null, "float"));
$reader->addField(new PhpExt_Data_FieldConfigObject("lastChange", null, "date", "n/j h:ia"));
$reader->addField(new PhpExt_Data_FieldConfigObject("industry"));
// Store
$store = new PhpExt_Data_Store();
$store->setUrl($baseUrl . '/grid/json_exampledata.php')->setReader($reader)->setBaseParams(array("limit" => $PageSize));
// 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"), true, 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, 85, null, PhpExt_Javascript::variable("Ext.util.Format.dateRenderer('m/d/Y')"), null, true))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Industry", "industry", null, 85, null, null, true, true));
// Grid
$grid = new PhpExt_Grid_GridPanel();
$grid->setStore($store)->setColumnModel($colModel)->setStripeRows(true)->setAutoExpandColumn("company")->setHeight(350)->setWidth(600)->setTitle("Json Grid");
$paging = new PhpExt_Toolbar_PagingToolbar();
$paging->setStore($store)->setPageSize($PageSize)->setDisplayInfo("Topics {0} - {1} of {2}")->setEmptyMessage("No topics to display");
$grid->setBottomToolbar($paging);
// Ext.OnReady -----------------------
echo PhpExt_Ext::onReady($changeRenderer, $pctChangeRenderer, $store->getJavascript(false, "store"), $store->load(new PhpExt_Data_StoreLoadOptions(array("start" => 0, "limit" => $PageSize))), $grid->getJavascript(false, "grid"), $grid->render("grid-example"));
Example #4
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.\""))));
Example #5
0
//AGREGO LOS CAMPOS AL STORE
$store->addField(new PhpExt_Data_FieldConfigObject("id"));
$store->addField(new PhpExt_Data_FieldConfigObject("currency"));
$store->addField(new PhpExt_Data_FieldConfigObject("value"));
$store->addField(new PhpExt_Data_FieldConfigObject("date"));
$store->addField(new PhpExt_Data_FieldConfigObject("new"));
$txt_nuevo_valor = new PhpExt_Form_NumberField();
$txt_nuevo_valor->setDecimalSeparator($separador_decimal)->setMsgTarget(PhpExt_Form_FormPanel::MSG_TARGET_SIDE);
//AGREGO LAS COLUMNAS A LA GRILLA
$col_model = new PhpExt_Grid_ColumnModel();
$col_model->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Id", "id", null, 35));
$col_model->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Moneda", "currency"));
$col_model->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Ultimo Valor", "value"));
$col_model->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Fecha", "date", null, 110));
$col_model->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Nuevo Valor", "new")->setEditor($txt_nuevo_valor));
$paging = new PhpExt_Toolbar_PagingToolbar();
$paging->setStore($store)->setDisplayInfo(true)->setEmptyMessage("No tiene monedas flotantes para definir el tipo de cambio");
//GRILLA
$grid = new PhpExt_Grid_EditorGridPanel();
$grid->setStore($store)->setColumnModel($col_model)->setSelectionModel(new PhpExt_Grid_RowSelectionModel())->setLoadMask(true)->setenableColLock(false);
$grid->setBottomToolbar($paging);
$grid->getPlugins()->add(new PhpExtUx_App_FitToParent());
$grid_render = "\n\n\nvar save = function(){\n\tvar fecha = grid.getTopToolbar().items.find( function(c){ return (c.xtype == 'datefield') } );\t\n\tvar store = grid.getStore();\n\tvar store_changes = store.getModifiedRecords();\n\t\n\tvar items = Array();\n\t\n\tfor( var i = 0, len = store_changes.length; i < len; i++ )\n\t{\t\t\n\t\tvar item = { \n\t\t\t\t\t id : store_changes[i].get('id'),\n\t\t\t\t  value : store_changes[i].get('new')\t\t\t\t\t\n\t\t           }\n\t\titems.push(item);\n\t}\n\t\n\tvar json = { \n\t\t\t\t fecha : fecha.value,\n\t\t\t\t items : items \n\t\t\t   }\n\t\n\tstore.load( { params:{ NewsValuesData : Ext.encode(json) } } );\n\tstore.commitChanges();\n\t\n\t\n}\n\t\nvar button1 = grid.getTopToolbar().items.find( function(c){ return ( c.text == 'Guardar cambios') } );\nbutton1.on( 'click', save );\n\n";
$grid->setEnableKeyEvents(true);
$grid->attachListener("render", new PhpExt_Listener(PhpExt_Javascript::functionDef(null, $grid_render, array("grid"))));
//CONTROL PARA LA FECHA
$txt_fecha = new PhpExt_Form_DateField();
$txt_fecha->setInvalidText("Fecha Invalida(dd/mm/yyyy)")->setValue(date('Y-m-d'))->setFormat(str_replace("%", "", $ari->get("locale")->get('shortdateformat', 'datetime')));
$tb = $grid->getTopToolbar();
$tb->addTextItem("text", "Fecha:");
$tb->addItem("txt_fecha", $txt_fecha);