Exemplo n.º 1
0
$cbo_modulo = PhpExt_Form_ComboBox::createComboBox("cbo_modulo")->setStore($store_modulos)->setDisplayField("detalle")->setValueField("id")->setLazyRender(true)->setEditable(false)->setForceSelection(true)->setSingleSelect(true)->setMode(PhpExt_Form_ComboBox::MODE_LOCAL)->setTriggerAction(PhpExt_Form_ComboBox::TRIGGER_ACTION_ALL);
$format_contacto = "\n\t function( v, params, record , rowIndex, colIndex, store ){\t\t\t\n\t\treturn record.data['contacto'];\n\t }\n";
$format_modulo = "\n\t function( v, params, record , rowIndex, colIndex, store ){\t\t\t\n\t\treturn record.data['modulenicename'];\n\t }\n";
$col_model = new PhpExt_Grid_ColumnModel();
$col_model->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Id", "id", null, 30));
$col_model->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Nombre", "nombre", null, 280)->setEditor($txt_nombre));
$col_model->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Descripción", "descripcion", null, 280)->setEditor($txt_descripcion));
$col_model->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Modulo", "modulo", null, 80, PhpExt_Ext::HALIGN_RIGHT, new PhpExt_JavascriptStm($format_modulo))->setEditor($cbo_modulo));
$grid = new PhpExt_Grid_EditorGridPanel();
$grid->setStore($store)->setColumnModel($col_model)->setSelectionModel(new PhpExt_Grid_RowSelectionModel())->setLoadMask(true)->setenableColLock(false);
$grid->getPlugins()->add($filter_plugin);
$grid->getPlugins()->add(new PhpExtUx_App_FitToParent());
$grid->setBottomToolbar($paging);
$grid_render = "\n\nvar store = grid.getStore();\n\ngrid.on('validateedit', function(e){\n    if(e.field == 'modulo'){\n\t\tvar combo = grid.getColumnModel().getCellEditor(e.column, e.row).field;\t\t\t\t \t\t \n        e.record.data['modulenicename'] = combo.getRawValue();\n    }\t\n});\n\n\nvar nuevo = function(){\n\nvar cmodel = Ext.data.Record.create([\n\t\t\t\t   {name: 'id'},\n\t\t\t\t   {name: 'nombre', type: 'string'},\n\t\t\t\t   {name: 'sucursal', type: 'string'},\n\t\t\t\t   {name: 'contacto', type: 'string'},\n\t\t\t\t   {name: 'sucursal::nombre'},\n\t\t\t\t   {name: 'contacto::apellido'}\n\t\t\t  ]);\n\nvar cm = new cmodel({\n\t\t\t\t\tid : '',\n\t\t\t    nombre : '',\t\t\t \n\t\t\t  sucursal : '',\n\t\t\t  contacto : '',\n\t'sucursal::nombre' : '',\n  'contacto::apellido' : ''\n\t\t\t\t\t});\n\t\t\t\t\n\tgrid.stopEditing();\n\tstore.insert(0, cm);\n\tgrid.startEditing(0, 1);\n\n}\n\nvar eliminar = function(){\n\n\t\tvar noborrar = 0;\n\t\tvar m = grid.getSelections();\n        if( m.length > 0 )\n        {\n\t\t\tvar msg = 'Esta seguro que desea ' + ((m.length > 1)?'los':'el') + ' deposito' + ((m.length > 1)?'s':'') + '?';\n\t\t\n        \tExt.MessageBox.confirm('Emporika', msg , function( btn ){\n\t\t\t\t\tif( btn == 'yes' )\n\t\t\t\t\t{\t\n\t\t\t\t\t\tvar m = grid.getSelections();\n\t\t\t\t\t\tvar items = Array();\n\t\t\t\t\t\tfor( var i = 0, len = m.length; i < len; i++ ){  \t\t\t\t\t\t\t\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 );\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tvar pag = grid.getStore().lastOptions.params['start'];\t\t\t\t\t\t\n\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\t   DeleteData : Ext.encode(items) }\n\t\t\t\t\t\t\t\t\t});\t\t\n\t\t\t\t\t}\t\t\t\n\t\t\t});\t\n        }\n        else\n        {\n        \tExt.MessageBox.alert('Emporika', 'Por favor seleccione un deposito');\n        }\n}\n\nvar save = function(){\n\n\tvar hab = true;\n\tvar store_changes = store.getModifiedRecords();\n\tvar items = Array();\t\n\t\n\tfor( var i = 0, len = store_changes.length; i < len; i++ ){\n\t\n\t\t\t\t\n\t\tif( store_changes[i].get('nombre') == '' ){\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\tgrid.startEditing(i, 1);\n\t\t\thab = false;\n\t\t}\n\t\t\n\t\tif( store_changes[i].get('contacto') == '' && hab ){\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\tgrid.startEditing(i, 2);\n\t\t\thab = false;\n\t\t}\n\t\t\n\t\tif( store_changes[i].get('sucursal') == '' && hab ){\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\tgrid.startEditing(i, 3);\n\t\t\thab = false;\n\t\t}\n\t\t\n\t\t\t\n\t\tvar item = { \n\t\t\t\t\t id : store_changes[i].get('id'),\n\t\t\t     nombre : store_changes[i].get('nombre'),\n\t\t\t   contacto : store_changes[i].get('contacto::apellido'),\n\t\t\t   sucursal : store_changes[i].get('sucursal::nombre')\n\t\t\t\t   }\t\n\t\titems.push(item);\t\t   \n\t}\t\n\t\n\tif(hab){\n\t\tvar pag = grid.getStore().lastOptions.params['start'];\n\t\tstore.load( { params:{ \n\t\t\t\t\t\t\tstart : pag, \n\t\t\t\t\t\t\tlimit : {$page_size} , \n\t\t\t\t   NewsValuesData : Ext.encode(items) }\n\t\t\t\t   } );\n\t\tstore.commitChanges();\n\t}\n\t\n}\n\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 == 'Borrar') } );\nbutton2.on( 'click', eliminar );\n\nvar button3 = grid.getTopToolbar().items.find( function(c){ return ( c.text == 'Guardar cambios') } );\nbutton3.on( 'click', save );\n\n";
$grid->setEnableKeyEvents(true);
$grid->attachListener("render", new PhpExt_Listener(PhpExt_Javascript::functionDef(null, $grid_render, array("grid"))));
$tb = $grid->getTopToolbar();
$tb->addButton("new", "Nuevo", "images/add.png");
$tb->addSeparator("sep1");
$tb->addButton("delete", "Borrar", "images/no_.gif");
$tb->addSeparator("sep2");
$tb->addButton("update", "Guardar cambios", "images/save.gif");
$resultado = '';
$resultado .= $store->getJavascript(false, "store_sucursales_list");
$resultado .= " store_sucursales_list.load( { params : { start : 0, limit : {$page_size} } } );";
$resultado .= $filter_plugin->getJavascript(false, "filters");
$resultado .= $col_model->getJavascript(false, "cm");
$resultado .= "cm.defaultSortable = true;";
$resultado .= $grid->getJavascript(false, "contenido");
//RESULTADO
$obj_comunication = new OOB_ext_comunication();
Exemplo n.º 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>";
 }
Exemplo n.º 3
0
set_include_path(get_include_path() . PATH_SEPARATOR . realpath('../../library'));
include_once 'PhpExt/Javascript.php';
PhpExt_Javascript::sendContentType();
include_once 'PhpExt/Ext.php';
include_once 'PhpExt/Data/GroupingStore.php';
include_once 'PhpExt/Data/ArrayReader.php';
include_once 'PhpExt/Data/FieldConfigObject.php';
include_once 'PhpExt/Data/SortInfoConfigObject.php';
include_once 'PhpExt/Grid/ColumnModel.php';
include_once 'PhpExt/Grid/ColumnConfigObject.php';
include_once 'PhpExt/Grid/GridPanel.php';
include_once 'PhpExt/Grid/GroupingView.php';
// Sample Data
$myData = array(array('3m Co', 71.72, 0.02, 0.03, '4/2 12:00am', 'Manufacturing'), array('Alcoa Inc', 29.01, 0.42, 1.47, '4/1 12:00am', 'Manufacturing'), array('Altria Group Inc', 83.81, 0.28, 0.34, '4/3 12:00am', 'Manufacturing'), array('American Express Company', 52.55, 0.01, 0.02, '4/8 12:00am', 'Finance'), array('American International Group, Inc.', 64.13, 0.31, 0.49, '4/1 12:00am', 'Services'), array('AT&T Inc.', 31.61, -0.48, -1.54, '4/8 12:00am', 'Services'), array('Boeing Co.', 75.43000000000001, 0.53, 0.71, '4/8 12:00am', 'Manufacturing'), array('Caterpillar Inc.', 67.27, 0.92, 1.39, '4/1 12:00am', 'Services'), array('Citigroup, Inc.', 49.37, 0.02, 0.04, '4/4 12:00am', 'Finance'), array('E.I. du Pont de Nemours and Company', 40.48, 0.51, 1.28, '4/1 12:00am', 'Manufacturing'), array('Exxon Mobil Corp', 68.09999999999999, -0.43, -0.64, '4/3 12:00am', 'Manufacturing'), array('General Electric Company', 34.14, -0.08, -0.23, '4/3 12:00am', 'Manufacturing'), array('General Motors Corporation', 30.27, 1.09, 3.74, '4/3 12:00am', 'Automotive'), array('Hewlett-Packard Co.', 36.53, -0.03, -0.08, '4/3 12:00am', 'Computer'), array('Honeywell Intl Inc', 38.77, 0.05, 0.13, '4/3 12:00am', 'Manufacturing'), array('Intel Corporation', 19.88, 0.31, 1.58, '4/2 12:00am', 'Computer'), array('International Business Machines', 81.41, 0.44, 0.54, '4/1 12:00am', 'Computer'), array('Johnson & Johnson', 64.72, 0.06, 0.09, '4/2 12:00am', 'Medical'), array('JP Morgan & Chase & Co', 45.73, 0.07000000000000001, 0.15, '4/2 12:00am', 'Finance'), array('McDonald\'s Corporation', 36.76, 0.86, 2.4, '4/2 12:00am', 'Food'), array('Merck & Co., Inc.', 40.96, 0.41, 1.01, '4/2 12:00am', 'Medical'), array('Microsoft Corporation', 25.84, 0.14, 0.54, '4/2 12:00am', 'Computer'), array('Pfizer Inc', 27.96, 0.4, 1.45, '4/8 12:00am', 'Services', 'Medical'), array('The Coca-Cola Company', 45.07, 0.26, 0.58, '4/1 12:00am', 'Food'), array('The Home Depot, Inc.', 34.64, 0.35, 1.02, '4/8 12:00am', 'Retail'), array('The Procter & Gamble Company', 61.91, 0.01, 0.02, '4/1 12:00am', 'Manufacturing'), array('United Technologies Corporation', 63.26, 0.55, 0.88, '4/1 12:00am', 'Computer'), array('Verizon Communications', 35.57, 0.39, 1.11, '4/3 12:00am', 'Services'), array('Wal-Mart Stores, Inc.', 45.45, 0.73, 1.63, '4/3 12:00am', 'Retail'), array('Walt Disney Company (The) (Holding Company)', 29.89, 0.24, 0.8100000000000001, '4/1 12:00am', 'Services'));
$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"));
$reader = new PhpExt_Data_ArrayReader();
$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_GroupingStore();
$store->setSortInfo(new PhpExt_Data_SortInfoConfigObject("company"));
$store->setGroupField("industry");
$store->setReader($reader);
$store->setData($myData);
// ColumnModel
$colModel = new PhpExt_Grid_ColumnModel();
Exemplo n.º 4
0
include_once 'PhpExt/Handler.php';
include_once 'PhpExt/MessageBox.php';
include_once 'PhpExt/MessageBoxOptions.php';
include_once 'PhpExt/ProgressBarWaitConfig.php';
$mb1Element = PhpExt_Element::getById('mb1');
$mb1Handler = PhpExt_Javascript::functionDef(null, PhpExt_MessageBox::confirm("Confirm", "Are you sure you want to do that", PhpExt_Javascript::variable('showResult')), array("e"));
$mb2Element = PhpExt_Element::getById('mb2');
$mb2Handler = PhpExt_Javascript::functionDef(null, PhpExt_MessageBox::prompt("Name", "Please enter your name:", PhpExt_Javascript::variable('showResultText')), array("e"));
$mb3Element = PhpExt_Element::getById('mb3');
$mb3Options = PhpExt_MessageBoxOptions::createMsgOptions()->setTitle('Address')->setMsg('Please enter your address:')->setWidth(300)->setButtons(PhpExt_MessageBox::OKCANCEL())->setMultiline(true)->setFn(PhpExt_Javascript::variable('showResultText'))->setAnimEl('mb3');
$mb3Handler = PhpExt_Javascript::functionDef(null, PhpExt_MessageBox::show($mb3Options));
$mb4Element = PhpExt_Element::getById('mb4');
$mb4Options = PhpExt_MessageBoxOptions::createMsgOptions()->setTitle('Save Changes?')->setMsg('You are closing a tab that has unsaved changes. <br />Would you like to save your changes?')->setButtons(PhpExt_MessageBox::YESNOCANCEL())->setFn(PhpExt_Javascript::variable('showResult'))->setAnimEl('mb4')->setIcon(PhpExt_MessageBox::QUESTION());
$mb4Handler = PhpExt_Javascript::functionDef(null, PhpExt_MessageBox::show($mb4Options));
$mb6Element = PhpExt_Element::getById('mb6');
$mb6Options = PhpExt_MessageBoxOptions::createMsgOptions()->setTitle('Please wait')->setMsg('Loading items...')->setProgressText('Initializing...')->setWidth(300)->setProgress(true)->setClosable(false)->setAnimEl('mb6');
$mb6Hide = PhpExt_MessageBox::hide()->output();
$mb6Progress = PhpExt_MessageBox::updateProgress(PhpExt_Javascript::variable("i"), PhpExt_Javascript::inlineStm("Math.round(100*i)+'% completed'"))->output();
$mb6Handler = PhpExt_Javascript::functionDef(null, PhpExt_MessageBox::show($mb6Options)->output() . "\r\n\t\t// this hideous block creates the bogus progress\r\n       var f = function(v){\r\n            return function(){\r\n                if(v == 12){\r\n                    " . $mb6Hide . ";\r\n                    Ext.example.msg('Done', 'Your fake items were loaded!');\r\n                }else{\r\n                    var i = v/11;\r\n\t\t\t\t\t" . $mb6Progress . ";                    \r\n                }\r\n           };\r\n       };\r\n       for(var i = 1; i < 13; i++){\r\n           setTimeout(f(i), i*500);\r\n       }");
$mb7Element = PhpExt_Element::getById('mb7');
$mb7Options = PhpExt_MessageBoxOptions::createMsgOptions()->setMsg('Saving your data, please wait...')->setProgressText('Saving...')->setWait(true)->setWaitConfig(PhpExt_ProgressBarWaitConfig::createWaitConfig()->setInterval(200))->setIcon('ext-mb-download')->setAnimEl('mb7');
$mb7Handler = PhpExt_Javascript::functionDef(null, PhpExt_MessageBox::show($mb7Options)->output() . "\r\n\t\tsetTimeout(function(){\r\n            //This simulates a long-running operation like a database save or XHR call.\r\n            //In real code, this would be in a callback function.\r\n            " . PhpExt_MessageBox::hide()->output() . ";\r\n            Ext.example.msg('Done', 'Your fake data was saved!');\r\n        }, 8000);");
$mb8Element = PhpExt_Element::getById('mb8');
$mb8Handler = PhpExt_Javascript::functionDef(null, PhpExt_MessageBox::alert("Status", "Changes saved successfully.", PhpExt_Javascript::variable('showResult')));
$comboValues = PhpExt_Javascript::stm("\r\n\t//Add these values dynamically so they aren't hard-coded in the html\r\n    Ext.fly('info').dom.value = Ext.MessageBox.INFO;\r\n    Ext.fly('question').dom.value = Ext.MessageBox.QUESTION;\r\n    Ext.fly('warning').dom.value = Ext.MessageBox.WARNING;\r\n    Ext.fly('error').dom.value = Ext.MessageBox.ERROR;\r\n");
$mb9Element = PhpExt_Element::getById('mb9');
$mb9Options = PhpExt_MessageBoxOptions::createMsgOptions()->setTitle('Icon Support')->setMsg('Here is a message with an icon!')->setButtons(PhpExt_MessageBox::OK())->setFn(PhpExt_Javascript::variable('showResult'))->setAnimEl('mb9')->setIcon(PhpExt_Javascript::variable("Ext.get('icons').dom.value"));
$mb9Handler = PhpExt_Javascript::functionDef(null, PhpExt_MessageBox::show($mb9Options));
$showResult = PhpExt_Javascript::stm("function showResult(btn){\r\n        Ext.example.msg('Button Click', 'You clicked the {0} button', btn);\r\n    };");
$showResultText = PhpExt_Javascript::stm("function showResultText(btn, text){\r\n        Ext.example.msg('Button Click', 'You clicked the {0} button and entered the text \"{1}\".', btn, text);\r\n    };");
echo PhpExt_Ext::OnReady($mb1Element->on("click", $mb1Handler), $mb2Element->on("click", $mb2Handler), $mb3Element->on("click", $mb3Handler), $mb4Element->on("click", $mb4Handler), $mb6Element->on("click", $mb6Handler), $mb7Element->on("click", $mb7Handler), $mb8Element->on("click", $mb8Handler), $comboValues, $mb9Element->on("click", $mb9Handler), $showResult, $showResultText);
Exemplo n.º 5
0
$add_tab_function = "\n\n//oob_download\nExt.DomHelper.append(document.body, {\n                    tag: 'form',\n                    id:'download_form',\n                    frameBorder: 0,\n                    width: 0,\n                    height: 0,\n                    css: 'display:none;visibility:hidden;height:0px;'\n\t\t\t\t\t}); \n\nfunction oob_download( url, params ){\n\nvar form = document.getElementById('download_form');\n\nvar inputs = form.getElementsByTagName('input');\n\nfor (i = 0; i < inputs.length; i++){\n   form.removeChild(inputs[i]); \n}\n\nif( Ext.isArray(params) ){\n\tExt.each( params, function( item, index ){\n\t\tel = document.createElement('input');\n\t\tel = form.appendChild(el);\n\t\tel.name = item.name;\n\t\tel.type = 'hidden';\n\t\tel.value = item.value;\t\n\t});\n}\n\nform.method = 'post';\nform.action = url;\nform.submit();\n\n}\nExt.apply( Ext,{ oob_download : oob_download } );\n//fin oob_download\t\t\t\t\t\n\nvar msgconfig = {\n\t\t   title :'Error',\n\t\tprogress : false,\n\t\t    wait : false,\n\t\t     msg : 'Se produjo un error al cargar la pagina.',\n\t\t buttons : Ext.Msg.OK,\t\t \n\t\t    icon : Ext.MessageBox.ERROR ,\n\t\t\t  fn : function(c,t,o){\n\t\t\t\tExt.MessageBox.getDialog().setTitle(''); \n\t\t\t\tExt.MessageBox.getDialog().hide();\n\t\t\t  }\t\n\t\t}\n\n\n\nExt.Ajax.on('requestexception',function(request,response,f,g,h){\n\t\n\t\t\n\tswitch( response.status ){\n\tcase 401:\n\n\tvar loginDialog = new Ext.ux.form.LoginDialog({\n\t\t\t\tmodal : true,\n\t\t\t\ttitle : 'Nutus Econom&iacute;a',\n\t\t\t  message : 'Por su seguridad debe logearse nuevamente,<br /> ya que no ha utilizado el sistema por más de 30 minutos',\n\t\tusernameLabel : 'Usuario',\n\t\tpasswordLabel : 'Contrase&ntilde;a',\n\t\t cancelButton : 'Cerrar',\n\t\t  loginButton : 'Enviar',\n\t\t  failMessage : 'Usuario o contrase&ntilde;a no v&aacute;lida.',\n\t\t\t\t  url : '/seguridad/login_ajax'\t\t\t\n\t\t\t});\n\n\t\n\tloginDialog.show();\n\n\tloginDialog.on('success',function(){\n\trequest.request(f);\n\t});\n\n\tbreak;\n\tcase 400:\n\t\t\n\t\tvar msgconfig = {\n\t\t   title :'Error 400',\t\t\t\t    \n\t\t     msg : response.getResponseHeader['message'],\n\t\t buttons : Ext.Msg.OK,\t\t \n\t\t    icon : Ext.MessageBox.ERROR ,\n\t\t\t  fn : function(c,t,o){\n\t\t\t\tExt.MessageBox.getDialog().setTitle(''); \n\t\t\t\tExt.MessageBox.getDialog().hide();\n\t\t\t  }\t\n\t\t}\n\t\n\t\tExt.MessageBox.hide();\t \n\t\tvar win = Ext.MessageBox.getDialog();\t\t\n\t\t\n\t\twin.on('beforehide',function(){\n\t\t\t\n\t\t\tif( this.title == 'Error 400'){\n\t\t\t\t\treturn false;\n\t\t\t}\t\t\n\t\t});\n\t\t\n\t\tExt.Msg.show(msgconfig);\n\t\tExt.getCmp('status_bar').clearStatus({useDefaults:true});\n\t\t\n\tbreak;\n\tcase 404:\n\t\tvar msgconfig = {\n\t\t   title :'Error 404',\t\t\t\t    \n\t\t     msg : response.getResponseHeader['message'],\n\t\t buttons : Ext.Msg.OK,\t\t \n\t\t    icon : Ext.MessageBox.ERROR ,\n\t\t\t  fn : function(c,t,o){\n\t\t\t\tExt.MessageBox.getDialog().setTitle(''); \n\t\t\t\tExt.MessageBox.getDialog().hide();\n\t\t\t  }\t\n\t\t}\n\t\tExt.Msg.show(msgconfig);\n\t\tExt.getCmp('status_bar').clearStatus({useDefaults:true});\t\n\tbreak;\n\tcase 500:\t\t\n        Ext.MessageBox.hide();\t \n\t\tvar win = Ext.MessageBox.getDialog();\t\t\n\t\t\n\t\twin.on('beforehide',function(){\n\t\t\t\n\t\t\tif( this.title == 'Error'){\n\t\t\t\t\treturn false;\n\t\t\t}\t\t\n\t\t});\n\t\t\n\t\tExt.Msg.show(msgconfig);\n\t\tExt.getCmp('status_bar').clearStatus({useDefaults:true});\n\t\t \n\tbreak;\n\tcase 9001:\n\t\tExt.MessageBox.alert('" . $ari->title . "',response.getResponseHeader['message']); \n\t\tExt.getCmp('status_bar').clearStatus({useDefaults:true});\n\tbreak;\t\n\t}\n});\n\n\n\nExt.Ajax.on('requestcomplete', function(request,response,f,g,h){\ntry\n  { \n  \n    //Ext.MessageBox.updateProgress(1);\n    //Ext.MessageBox.hide();\t\n\t//alert(response.getResponseHeader['Content-Type']);\n\t\n\n\t \n\t\t\n  }\ncatch(err)\n  {\n  //alert(err.description);\n  }\n  \n\n\n}, this);\n\n\n\nExt.Ajax.request({url: '/admin/getcache',\n\t\t  method: 'POST',\n  \t\t success: function(responseObject){\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t   json = Ext.decode(responseObject.responseText);\t\t\t\t\t\t\t   \n\t\t\t\t\t\t\t   Ext.each( json, function(i){\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\taddTab(i.title,i.url,true,i.params,true,i.id);\n\t\t\t\t\t\t\t   });\t\t\t\t\t\t   \n\t\t\t\t\t   }\t\t\t\t   \n\t\t\t\t});\n\t\t\t\t\n\t\t\t\t\n\n \n//funcion para agregar las tabs \nfunction addTab( Title, Url, Add, Params, cache, tab_id ){\n\nvar panel_tabs = Ext.getCmp('TabPanel'); //obtengo el tabpanel que contiene todas las tabs\nvar cnx = new Ext.data.Connection(); //creo un nuevo objeto conexion\nvar tab_id; //defino la variable tab_id, tiene el id de la tab que se va agregar\n\t\t\t\n\t//pongo la barra de estado(cargando...)\n\tExt.getCmp('status_bar').showBusy();\n\t\t\t\n\t//obtengo un id unico para el contenedor de los contenidos que voy a cargar\n\tvar id = Ext.id();\n\n\t//function para agregar definitivamente la tab\n\tvar add = function( tab_id ){\n\t\n\t\n\t\t\t//si quiero agregar una tab nueva\n\t\t\t\t\t\t\t\t\t\n\n\t\tExt.Ajax.request( { url : Url,\n\t\t\t\t\t\tmethod : 'POST',\t\t\t\t\t\t\n\t\t\t\t\t\tparams : Params,\n\t\t\t\t\t   success : function( responseObject ){\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\tvar respuesta = responseObject.responseText;\t\n\n\t\t\t\t\t\t\t\t\tif(Add){\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t   var tab = new Ext.Panel({\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tid : tab_id,\n\t\t\t\t\t\t\t\t\t\t\t\t\t title : Title,\n\t\t\t\t\t\t\t\t\t\t\t\t\tlayout : 'fit',\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  closable : true,\n\t\t\t\t\t\t\t\t\t\t\tdeferredRender : false,\n\t\t\t\t\t\t\t\t\t\t\t\t\t  html : '<div style=\"height:100%;width:100%;\" id=\"' + id + '\"></div>',\n\t\t\t\t\t\t\t\t\t\t\t\tautoScroll : true\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   });\n\t\t\t\t\t\t\t\t\t\t   \n\t\t\t\t\t\t\t\t\t\t   panel_tabs.add(tab);\n\t\t\t\t\t\t\t\t\t\t   tab.show();\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}\n\t\t\t\t\t\t\t\t\telse //si quiero agregar en la tab que esta activa\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tvar active_tab = panel_tabs.getActiveTab();\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tvar cnx = new Ext.data.Connection();\n\t\t\t\t\t\t\t\t\t\tExt.Ajax.request({ url : '/admin/closetab',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmethod : 'POST',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tparams : 'tab_id=' + active_tab.id \t\t\t\t\t   \n\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\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tactive_tab.setTitle(Title);\n\t\t\t\t\t\t\t\t\t\tactive_tab.body.dom.innerHTML = '<div style=\"height:100%;width:100%;\" id=\"' + id + '\"></div>';\n\t\t\t\t\t\t\t\t\t}\n\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//una vez insertado el contenedor con el id unico , se procede a insertar los\n\t\t\t\t\t\t\t\t\t//datos en el mismo\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t//si el contenido a cargar es un html\n\t\t\t\t\t\t\t\t\tif( responseObject.getResponseHeader['Content-Type'] == 'text/html' ){\t\t\n\t\t\t\t\t\t\t\t\t\tExt.get(id).dom.innerHTML = respuesta;\t\t\t  \n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\telse //si el contenido es un json(extjs)\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t//ejecuto la respuesta y hago un render de la variable contenido\n\t\t\t\t\t\t\t\t\t\t//sobre el contenedor\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\teval(respuesta);\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tcontenido.render(Ext.get(id));\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t//llamo el evento para que aplique los filtros\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\tcontenido.fireEvent( 'applyfilters', tab_id );\t\t\t\t\t\t\t\t\n\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\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tExt.getCmp('status_bar').clearStatus({useDefaults:true});\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\treturn true;\t\t\t\n\t\t\t\t\t}});\n\n\n\t\t\t}//end function addtab\n\n\t\t\n\t\t//si !cache , quiere decir que la tab no esta en cache, por lo tanto llamo a newtab\n\t\t//para que la cachee y me devuelve el tab_id\n\t\tif(!cache){\n\t\t\t  Ext.Ajax.request({url: '/admin/newtab',\n\t\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\t\tparams: 'url=' + Url + '&title=' + Title + '&params=' + Params ,\n\t\t\t\t\t   success: function(responseObject){\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t   json = Ext.decode(responseObject.responseText);\t\t\t\t\t\t\t  \t\t\t\t\t\t\t   \n\t\t\t\t\t\t\t   //este tab_id luego es usado por la funcion tab_id\n\t\t\t\t\t\t\t   tab_id = json.id;\t\t\t\t\t\t\t   \n\t\t\t\t\t\t\t   add(json.id); \t\t\t\t\t\t\t   \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   }\n\t\t\t\t});\t\t\n\t\t}\n\t\telse\n\t\t{\n\t\t\t\t\tadd(tab_id); \t\t\t\t\t\t\t   \n\t\t}\t\t\n\t\n\t\t\n\t}\n\t\n\t\t\t\t\n\t\n\tExt.apply( Ext,{ addTab : addTab } );\n\t\n\t\n\tvar map = new Ext.KeyMap(document, [\n\t\t\t\t{\n\t\t\t\t\tkey: \"t\",\n\t\t\t\t\tctrl:true,\n\t\t\t\t\tshift:true,\n\t\t\t\t\tfn: function(){\n\t\t\t\t\t\tvar panel_tabs = Ext.getCmp('TabPanel'); //obtengo el tabpanel que contiene todas las tabs\n\t\t\t\t\t\tvar active_tab = panel_tabs.getActiveTab();\n\t\t\t\t\t\t if(active_tab){\n\t\t\t\t\t\t\tpanel_tabs.remove(active_tab);\n\t\t\t\t\t\t }//end if\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t]);\n\t\t\n\n\t//esto dejarlo siempre al ultimo por que hace el fadeout del precargador( osea lo oculta )\n\tvar hideMask = function () {\n        Ext.get('loading').remove();\n        Ext.fly('loading-mask').fadeOut({\n            remove:true\n        });\n    }\n\n    hideMask.defer(250);\t\t\t\n\t\n\t\n\t";
$add_tab_invoke = PhpExt_Javascript::callfunction("addTab", array("n.id[0]", "n.id[1]", "true", "''", "false"))->output() . "return false;";
$add_tab_invoke_html = PhpExt_Javascript::callfunction("addTab", array("n.id[0]", "n.id[1]", "false", "''", "false"))->output() . "return false;";
$get_tree_panel = PhpExt_Element::getCmp('treePanel');
$if_leaf = PhpExt_Javascript::functionNoDef("if", $add_tab_invoke, array("n.leaf"));
$if_leaf_html = PhpExt_Javascript::functionNoDef("if", $add_tab_invoke_html, array("n.leaf"));
$add_tab_onclick = PhpExt_Javascript::functionDef(null, $if_leaf, array("n"));
$add_tab_oncontextmenu = PhpExt_Javascript::functionDef(null, $if_leaf_html, array("n"));
$output_add_tab_onclick = $get_tree_panel->on("click", $add_tab_onclick);
$output_add_tab_oncontextmenu = $get_tree_panel->on("contextmenu", $add_tab_oncontextmenu);
$output_add_tab_function = new PhpExt_JavascriptStm($add_tab_function);
//-----------------------------------------------------------BARRA DE ESTADO--------------------------------------------------------------------------------------------
$function_win_open = PhpExt_Javascript::callfunction("window.open", array("'http://www.nutus.com.ar'"));
$handler_abrir_pagina = PhpExt_Javascript::functionDef("", $function_win_open, array("e"));
$function_win_open2 = PhpExt_Javascript::callfunction("window.open", array("'http://soporte.nutus.info'"));
$handler_abrir_pagina2 = PhpExt_Javascript::functionDef("", $function_win_open2, array("e"));
$barra_estado = new PhpExt_Toolbar_StatusBar();
$barra_estado->setId("status_bar");
$barra_estado->setDefaultText("Terminado");
$barra_estado->addButton("ayuda", "Ayuda on-line", null, $handler_abrir_pagina2);
$barra_estado->addButton("Pagina", "&#169; Nutus 2009", null, $handler_abrir_pagina);
$status_bar = new PhpExt_Panel();
$status_bar->setBottomToolbar($barra_estado);
//USO UN VIEWPORT YA QUE SE ADAPTA AL ANCHO DE LA PAGINA
//creo uno nuevo y le agrego todos los items setando el area
$contenedor = new PhpExt_Viewport();
$contenedor->setLayout(new PhpExt_Layout_BorderLayout());
$contenedor->addItem($menu_top, PhpExt_Layout_BorderLayoutData::createNorthRegion());
$contenedor->addItem($menu_acordion, PhpExt_Layout_BorderLayoutData::createWestRegion());
$contenedor->addItem($principal, PhpExt_Layout_BorderLayoutData::createCenterRegion());
$contenedor->addItem($status_bar, PhpExt_Layout_BorderLayoutData::createSouthRegion());
Exemplo n.º 6
0
 $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"));
Exemplo n.º 7
0
include_once 'PhpExt/Handler.php';
include_once 'PhpExt/QuickTips.php';
include_once 'PhpExt/Data/Record.php';
include_once 'PhpExt/Data/Store.php';
include_once 'PhpExt/Data/XmlReader.php';
include_once 'PhpExt/Data/FieldConfigObject.php';
include_once 'PhpExt/Data/SortInfoConfigObject.php';
include_once 'PhpExt/Grid/ColumnModel.php';
include_once 'PhpExt/Grid/ColumnConfigObject.php';
include_once 'PhpExt/Grid/EditorGridPanel.php';
include_once 'PhpExt/Form/TextField.php';
include_once 'PhpExt/Form/NumberField.php';
include_once 'PhpExt/Form/DateField.php';
include_once 'PhpExt/Form/ComboBox.php';
include_once 'PhpExtUx/Grid/CheckColumn.php';
$formatDate = PhpExt_Javascript::functionDef("formatDate", "return value ? value.dateFormat('M d, Y') : '';", array("value"));
// custom column plugin example
$checkColumn = new PhpExtUx_Grid_CheckColumn("Indoor?");
$checkColumn->setDataIndex("indoor");
$checkColumn->setWidth(55);
// the column model has information about grid columns
//dataIndex maps the column to the specific data field in
// the data store (created below)
// ColumnModel
$txtCommon = PhpExt_Form_TextField::createTextField('txtCommon')->setAllowBlank(false);
$cmbLight = PhpExt_Form_ComboBox::createComboBox("cmbLight")->setTypeAhead(true)->setTriggerAction(PhpExt_Form_ComboBox::TRIGGER_ACTION_ALL)->setTransform("light")->setLazyRender(true)->setListCssClass('x-combo-list-small');
$txtPrice = PhpExt_Form_NumberField::createNumberField("txtPrice")->setAllowBlank(false)->setAllowNegative(false)->setMaxValue(100000);
$dtAvailable = PhpExt_Form_DateField::createDateField("dtAvaliable")->setFormat("m/d/y")->setMinValue("01/01/06")->setDisabledDays(array(0, 6))->setDisabledDaysText("Plants are not available on the weekends");
$colModel = new PhpExt_Grid_ColumnModel();
$colModel->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Common Name", "common", "common", 220)->setEditor($txtCommon))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Light", "light", null, 130)->setEditor($cmbLight))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Price", "price", "price", 70, PhpExt_Ext::HALIGN_RIGHT, "usMoney")->setEditor($txtPrice))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Avaliable", "availDate", "availDate", 95, null, PhpExt_Javascript::variable('formatDate'))->setEditor($dtAvailable))->addColumn($checkColumn);
// this could be inline, but we want to define the Plant record
Exemplo n.º 8
0
$opt_group_tipo_cambio->attachListener("render", new PhpExt_Listener(PhpExt_Javascript::functionDef(null, $group_render, array("group"))));
$opt_tipo_fijo->setEnableKeyEvents(true);
//VALOR DE LA MONEDA
$txt_valor = PhpExt_Form_NumberField::createNumberField("txt_valor", "Valor")->setMsgTarget(PhpExt_Form_FormPanel::MSG_TARGET_SIDE)->setDecimalSeparator($separador_decimal)->setValue(1)->setDisabled(true)->setWidth($field_width);
//MONEDA PREDETERMINADA
$opt_predeterminada_si = new PhpExt_Form_Radio();
$opt_predeterminada_si->setBoxLabel("Si")->setValue("yes")->setName("opt-predeterminada");
$opt_predeterminada_no = new PhpExt_Form_Radio();
$opt_predeterminada_no->setBoxLabel("No")->setValue("no")->setName("opt-predeterminada");
$opt_predeterminada_no->setChecked(true);
$opt_group_predeterminada = new PhpExt_Form_RadioGroup();
$opt_group_predeterminada->setfieldLabel("Predeterminada");
$opt_group_predeterminada->addItem($opt_predeterminada_si);
$opt_group_predeterminada->addItem($opt_predeterminada_no);
$group_render = "\n\nvar formulario = this.findParentByType('form');\n\t\nvar group = formulario.findBy( function(c){ return ( c.xtype == 'radiogroup' );} );\n\nopt = this.items.items[0];\t\n\nopt.on( 'check' , function(t,n,o){\t\n\tvar field = formulario.getForm().findField('txt_valor');\n\tif( t.getValue() )\n\t{\n\t\tgroup[0].items.items[0].setValue(true);\n\t\tgroup[0].items.items[1].setValue(false);\n\t\tfield.setValue('1');\n\t\tfield.disable();\t\t\n\t}\n\telse\n\t{\n\t\tif( group[0].items.items[0].getValue() ){\n\t\t\tfield.enable();\n\t\t\tfield.focus(true);\t\t\n\t\t}else{\n\t\t\tfield.setValue('1');\n\t\t\tfield.disable();\t\t\n\t\t}\n\t}\n},this);\n";
$opt_group_predeterminada->attachListener("render", new PhpExt_Listener(PhpExt_Javascript::functionDef(null, $group_render, array("group"))));
$opt_predeterminada_si->setEnableKeyEvents(true);
//MONEDA PREDETERMINADA EN IDIOMA
$idiomas_list = array();
if ($idiomas = $ari->get('agent')->getLanguages()) {
    foreach ($idiomas as $i) {
        $idiomas_list[] = array($i, $i);
    }
}
$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();
Exemplo n.º 9
0
<?php

set_include_path(get_include_path() . PATH_SEPARATOR . realpath('../../library'));
include_once 'PhpExt/Javascript.php';
PhpExt_Javascript::sendContentType();
include_once 'PhpExt/Ext.php';
include_once 'PhpExt/Data/Store.php';
include_once 'PhpExt/Data/ScriptTagProxy.php';
include_once 'PhpExt/Data/JsonReader.php';
include_once 'PhpExt/Data/FieldConfigObject.php';
include_once 'PhpExt/Config/ConfigObject.php';
include_once 'PhpExt/XTemplate.php';
include_once 'PhpExt/Form/ComboBox.php';
include_once 'PhpExt/Listener.php';
$ds = new PhpExt_Data_Store();
$ds->setProxy(new PhpExt_Data_ScriptTagProxy('http://extjs.com/forum/topics-remote.php'));
$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->setReader($reader);
$ds->setBaseParams(array("limit" => 20, "forumId" => 21));
$resultTpl = new PhpExt_XTemplate('<tpl for="."><div class="search-item">', '<h3><span>{lastPost:date("M j, Y")}<br />by {author}</span>{title}</h3>', '{excerpt}', '</div></tpl>');
$search = new PhpExt_Form_ComboBox(null, "searchbox");
$search->setStore($ds)->setDisplayField("title")->setTypeAhead(false)->setLoadingText("Searching...")->setWidth(570)->setPageSize(10)->setHideTrigger(true)->setTemplate($resultTpl)->setApplyTo("fsearch")->setItemCssSelector("div.search-item")->attachListener("onSelect", new PhpExt_Listener(PhpExt_Javascript::functionDef(null, "window.location =\r\n                String.format('http://extjs.com/forum/showthread.php?t={0}&p={1}', record.data.topicId, record.id)", array("record"))));
//------------ Ext.OnReady
echo PhpExt_Ext::onReady($ds->getJavascript(false, "ds"), $resultTpl->getJavascript(false, "resultTpl"), $search->getJavascript(false, "search"));
Exemplo n.º 10
0
$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"));
$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");