Example #1
0
 protected function paramToString($name, $value)
 {
     $resolvedValue = PhpExt_Javascript::valueToJavascript($value);
     if (strpos($name, "-") !== false) {
         $name = "\"{$name}\"";
     }
     return "{$name}: {$resolvedValue}";
 }
Example #2
0
 public static function onReady()
 {
     $statements = func_get_args();
     $js = "Ext.onReady(function(){\n";
     foreach ($statements as $stm) {
         $js .= PhpExt_Javascript::output($stm) . "\n";
     }
     $js .= "});";
     return $js;
 }
Example #3
0
 public function output()
 {
     $stack = array();
     foreach ($this->_statements as $line) {
         $stack[] = PhpExt_Javascript::valueToJavascript($line);
     }
     $js = "function(){\n";
     $js .= implode("\n", $stack);
     $js .= "}";
     return $js;
 }
Example #4
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/SimpleStore.php';
include_once 'PhpExt/Data/FieldConfigObject.php';
include_once 'PhpExt/Form/ComboBox.php';
include_once 'PhpExt/QuickTips.php';
// simple array store
$store = new PhpExt_Data_SimpleStore();
$store->addField("abbr");
$store->addField("state");
$store->addField("nick");
$store->setData(PhpExt_Javascript::variable("Ext.exampledata.states"));
// from states.js
$combo = new PhpExt_Form_ComboBox();
$combo->setStore($store)->setDisplayField("state")->setTypeAhead(true)->setMode(PhpExt_Form_ComboBox::MODE_LOCAL)->setTriggerAction(PhpExt_Form_ComboBox::TRIGGER_ACTION_ALL)->setEmptyText("Select a state...")->setSelectOnFocus(true)->setApplyTo("local-states");
$comboWithTooltip = new PhpExt_Form_ComboBox();
$comboWithTooltip->setTemplate('<tpl for="."><div ext:qtip="{state}. {nick}" class="x-combo-list-item">{state}</div></tpl>')->setStore($store)->setDisplayField("state")->setTypeAhead(true)->setMode(PhpExt_Form_ComboBox::MODE_LOCAL)->setTriggerAction(PhpExt_Form_ComboBox::TRIGGER_ACTION_ALL)->setEmptyText("Select a state...")->setSelectOnFocus(true)->setApplyTo("local-states-with-qtip");
$converted = new PhpExt_Form_ComboBox();
$converted->setTypeAhead(true)->setTriggerAction(PhpExt_Form_ComboBox::TRIGGER_ACTION_ALL)->setTransform("state")->setWidth(135)->setForceSelection(true);
echo PhpExt_Ext::onReady(PhpExt_Javascript::stm(PhpExt_QuickTips::init()), $store->getJavascript(false, "store"), $combo->getJavascript(false, "combo"), $comboWithTooltip->getJavascript(false, "comboWithTooltip"), $converted->getJavascript(false, "converted"));
Example #5
0
 /**
  * Button config that displays Yes, No and Cancel buttons
  * @return PhpExt_JavascriptStm
  */
 public static function YESNOCANCEL()
 {
     return PhpExt_Javascript::variable("Ext.Msg.YESNOCANCEL");
 }
Example #6
0
 /**
  * @return JavascriptStm
  */
 public static function getMethodInvokeStm($instanceVarName, $methodSignature, $inline = false)
 {
     $params = array();
     foreach ($methodSignature['params'] as $key => $value) {
         $params[$key] = PhpExt_Javascript::valueToJavascript($value);
     }
     if ($methodSignature['static']) {
         $js = isset($this) && isset($this->_extClassName) && $this->_extClassName != null ? $this->_extClassName : $instanceVarName;
     } else {
         $js = $instanceVarName;
     }
     $js .= "." . $methodSignature['methodName'] . "(" . implode(",", $params) . ")";
     return $inline ? PhpExt_Javascript::inlineStm($js) : PhpExt_Javascript::stm($js);
 }
Example #7
0
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();
$colModel->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Company", "company", "company", 60, null, null, true, false))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Price", "price", null, 20, null, PhpExt_Javascript::variable("Ext.util.Format.usMoney"), true))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Change", "change", null, 20, null, PhpExt_Javascript::variable('change'), true))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Industry", "industry", null, 20, null, null, true))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Last Updated", "lastChange", null, 20, null, PhpExt_Javascript::variable("Ext.util.Format.dateRenderer('m/d/Y')"), true));
// View
$view = new PhpExt_Grid_GroupingView();
$view->setForceFit(true);
$view->setGroupTextTemplate('{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})');
// Grid
$grid = new PhpExt_Grid_GridPanel();
$grid->setStore($store)->setColumnModel($colModel)->setView($view)->setFrame(true)->setCollapsible(true)->setAnimCollapse(true)->setTitle("Grouping Example")->setIconCssClass("icon-grid")->setRenderTo("grouping-example")->setWidth(700)->setHeight(450);
// Ext.OnReady -----------------------
echo PhpExt_Ext::onReady(PhpExt_Javascript::assignNew("myData", PhpExt_Javascript::valueToJavascript($myData)), $changeRenderer, $store->getJavascript(false, "store"), $grid->getJavascript(false, "grid"));
Example #8
0
$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());
//FUNCTIONS DE USO GENERAL
$format_money = "\t\nfunction FormatMoney(v,sign){\t\t\t\t\n    v = (Math.round((v-0)*100))/100;\n    v = (v == Math.floor(v)) ? v + '.00' : ((v*10 == Math.floor(v*10)) ? v + '0' : v);\n    v = String(v);        \n        if(v.charAt(0) == '-'){\n            return '-' + sign + v.substr(1).replace('.',',');\n        }\n    return sign +  v.replace('.',',');\n}\n";
$unformat_money = "\nfunction unformatMoney(num) {\n\tvar value = num.replace(',','.');\t\t\n\treturn value.replace(/([^0-9\\.\\-])/g,'')*1;\t\n}\n";
echo PhpExt_Ext::OnReady(PhpExt_QuickTips::init(), $contenedor->getJavascript(false, "Contenedor"), $contenedor->render(PhpExt_Javascript::inlineStm("document.body")), $output_add_tab_function->output(), $output_add_tab_onclick, $output_add_tab_oncontextmenu, $unformat_money, $format_money);
Example #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/Data/StoreLoadOptions.php';
include_once 'PhpExt/Config/ConfigObject.php';
include_once 'PhpExt/XTemplate.php';
include_once 'PhpExt/Panel.php';
include_once 'PhpExt/DataView.php';
include_once 'PhpExt/Toolbar/Toolbar.php';
include_once 'PhpExt/Toolbar/PagingToolbar.php';
// User Extension
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));
Example #10
0
 /**
  * Static method to retrieve Ext.Element objects.
  * Uses simple caching to consistently return the same object. Automatically fixes if an object was recreated with the same id via AJAX or DOM.
  * To retrieve an element by Id use {@link PhpExt_Element::getById}
  * @param string $id The DOM node to retrieve
  * @return PhpExt_Element
  */
 public static function getByDOM($domNode)
 {
     if (!PhpExt_Javascript::isJavascriptStm($domNode)) {
         $domNode = PhpExt_Javascript::variable($domNode);
     }
     $e = new PhpExt_Element();
     $e->domNode = $domNode;
     $args = array($domNode);
     $methodSig = $e->createMethodSignature("get", $args, true);
     $e->createMethod = $e->getMethodInvokeStm('Ext.Element', $methodSig, true);
     return $e;
 }
Example #11
0
$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
// type so we can add records dynamically
$fields = new PhpExt_Data_FieldConfigObjectCollection();
$fields->add(new PhpExt_Data_FieldConfigObject("common", null, PhpExt_Data_FieldConfigObject::TYPE_STRING));
$fields->add(new PhpExt_Data_FieldConfigObject("botanical", null, PhpExt_Data_FieldConfigObject::TYPE_STRING));
$fields->add(new PhpExt_Data_FieldConfigObject("light"));
$fields->add(new PhpExt_Data_FieldConfigObject("price", null, PhpExt_Data_FieldConfigObject::TYPE_FLOAT));
$fields->add(new PhpExt_Data_FieldConfigObject("availDate", "availability", PhpExt_Data_FieldConfigObject::TYPE_DATE, "m/d/Y"));
$fields->add(new PhpExt_Data_FieldConfigObject("indoor", null, PhpExt_Data_FieldConfigObject::TYPE_BOOLEAN));
$plant = PhpExt_Data_Record::create($fields);
// Reader
$reader = new PhpExt_Data_XmlReader();
$reader->setRecord("plant");
$reader->setRecordType("Plant");
// Store
$store = new PhpExt_Data_Store();
$store->setUrl("examples/grid/plants.xml")->setReader($reader)->setSortInfo(new PhpExt_Data_SortInfoConfigObject("common"));
// Grid
$grid = new PhpExt_Grid_EditorGridPanel();
$grid->setClicksToEdit(1)->setStore($store)->setColumnModel($colModel)->setAutoExpandColumn("common")->setFrame(true)->setHeight(300)->setWidth(600)->setTitle("Edit Plants?")->setRenderTo("editor-grid");
$grid->getPlugins()->add($checkColumn);
$grid->getTopToolbar()->addButton("add", "Add Plant", null, new PhpExt_Handler(PhpExt_Javascript::inlineStm("var p = new Plant({\r\n            common: 'New Plant 1',\r\n            light: 'Mostly Shade',\r\n            price: 0,\r\n            availDate: (new Date()).clearTime(),\r\n            indoor: false\r\n        });\r\n        grid.stopEditing();\r\n        store.insert(0, p);\r\n        grid.startEditing(0, 0);")));
// Ext.OnReady -----------------------
echo PhpExt_Ext::onReady(PhpExt_QuickTips::init(), $formatDate, $checkColumn->getJavascript(false, "checkColumn"), $colModel->getJavascript(false, "cm"), PhpExt_Javascript::assignNew("Plant", $plant), $store->getJavascript(false, "store"), $grid->getJavascript(false, "grid"), $store->load());
Example #12
0
$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();
$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);
Example #13
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"));
Example #14
0
               ->setHeight(600);
$accordion = new PhpExt_Layout_AccordionLayout();
$accordion->setTitleCollapse(true)
		  
		  ->setActiveOnTop(true)
          ->setAnimate(true)
          ;
$accordionPanel->setLayout($accordion);
$p1 = new PhpExt_Panel();
$p1->setTitle("Navigation")
   ->setHtml("This <bt>is the navigation panel");
$p2 = new PhpExt_Panel();
$p2->setTitle("Settings")
   ->setHtml("This <br>is the settings panel");
$accordionPanel->addItem($p1);
$accordionPanel->addItem($p2); 
$accordionPanel->setRenderTo(PhpExt_Javascript::inlineStm("Ext.get('centercolumn')"));
*/
$accordionPanel = new PhpExt_Panel();
$accordionPanel->setTitle("Accordion Sample")->setWidth(500)->setHeight(300);
$accordion = new PhpExt_Layout_AccordionLayout();
$accordion->setTitleCollapse(true)->setAnimate(true);
$accordionPanel->setLayout($accordion);
$p1 = new PhpExt_Panel();
$p1->setTitle("Navigation")->setHtml("This <bt>is the navigation panel");
$p2 = new PhpExt_Panel();
$p2->setTitle("Settings")->setHtml("This <br>is the settings panel");
$accordionPanel->addItem($p1);
$accordionPanel->addItem($p2);
$accordionPanel->setRenderTo(PhpExt_Javascript::inlineStm("Ext.get('centercolumn')"));
echo PhpExt_Ext::onReady($accordionPanel->getJavascript(false, "accordionPanel"));
Example #15
0
$paging->getPlugins()->add($filter_plugin);
//GRILLA
$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);
Example #16
0
//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");
//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
Example #17
0
$tabs2->addItem($columnPanel2);
//- First column
$firstColumn2 = new PhpExt_Panel();
// Use FormLayout to enable field labels and autoarrange fields on the panel
$firstColumn2->setBorder(false)->setLayout(new PhpExt_Layout_FormLayout());
// Anchor the field to 95% of the panel by setting AnchorLayoutData (FormLayout extends AnchorLayout)
$firstColumn2->addItem(PhpExt_Form_TextField::createTextField("first", "First Name"), new PhpExt_Layout_AnchorLayoutData("95%"))->addItem(PhpExt_Form_TextField::createTextField("company", "Company"), new PhpExt_Layout_AnchorLayoutData("95%"));
// adds the panel as a 50% column using ColumnLayoutData
$columnPanel2->addItem($firstColumn2, new PhpExt_Layout_ColumnLayoutData(0.5));
//- Second column
$secondColumn2 = new PhpExt_Panel();
$secondColumn2->setBorder(false)->setLayout(new PhpExt_Layout_FormLayout())->addItem(PhpExt_Form_TextField::createTextField("last", "Last Name"), new PhpExt_Layout_AnchorLayoutData("95%"))->addItem(PhpExt_Form_TextField::createTextField("email", "Email")->setVType(PhpExt_Form_FormPanel::VTYPE_EMAIL), new PhpExt_Layout_AnchorLayoutData("95%"));
$columnPanel2->addItem($secondColumn2, new PhpExt_Layout_ColumnLayoutData(0.5));
//- Tab Panel
$tabPanel2 = new PhpExt_TabPanel();
$tabPanel2->setPlain(true)->setActiveTab(0)->setHeight(235)->setDefaults(new PhpExt_Config_ConfigObject(array("bodyStyle" => "padding:10px")));
$detailsTab2 = new PhpExt_Panel();
$detailsTab2->setTitle("Personal Details")->setLayout(new PhpExt_Layout_FormLayout())->setDefaults(new PhpExt_Config_ConfigObject(array("width" => 230)))->setDefaultType("textfield")->addItem(PhpExt_Form_TextField::createTextField("first", "First Name")->setAllowBlank(false)->setValue("Jack"))->addItem(PhpExt_Form_TextField::createTextField("company", "Company")->setValue("Slocum"))->addItem(PhpExt_Form_TextField::createTextField("last", "Last Name")->setValue("Ext JS"))->addItem(PhpExt_Form_TextField::createTextField("email", "Email")->setVType(PhpExt_Form_FormPanel::VTYPE_EMAIL));
$phonesTab2 = new PhpExt_Panel();
$phonesTab2->setTitle("Phone Numbers")->setLayout(new PhpExt_Layout_FormLayout())->setDefaults(new PhpExt_Config_ConfigObject(array("width" => 230)))->setDefaultType("textfield")->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"));
$bioTab = new PhpExt_Panel();
$bioTab->setCssClass("x-plain")->setTitle("Biography")->setLayout(new PhpExt_Layout_FitLayout())->addItem(PhpExt_Form_HtmlEditor::createHtmlEditor("bio2", "Biography", "bio2"));
$tabPanel2->addItem($detailsTab2);
$tabPanel2->addItem($phonesTab2);
$tabPanel2->addItem($bioTab);
$tabs2->addItem($tabPanel2);
$tabs2->addButton(PhpExt_Button::createTextButton("Save"));
$tabs2->addButton(PhpExt_Button::createTextButton("Cancel"));
//****************************** onReady
echo PhpExt_Ext::onReady(PhpExt_QuickTips::init(), PhpExt_Javascript::assign("bd", "Ext.get('centercolumn')"), PhpExt_Javascript::stm("bd.createChild({tag: 'h2', html: 'Form 1 - Very Simple'})"), $simple->getJavascript(false, "simple"), $simple->render(PhpExt_Javascript::variable("Ext.get('centercolumn')")), PhpExt_Javascript::stm("bd.createChild({tag: 'h2', html: 'Form 2 - Adding fieldsets'})"), $fsf->getJavascript(false, "fsf"), $fsf->render(PhpExt_Javascript::variable("Ext.get('centercolumn')")), PhpExt_Javascript::stm("bd.createChild({tag: 'h2', html: 'Form 3 - A little more complex'})"), $top->getJavascript(false, "top"), $top->render(PhpExt_Javascript::variable("Ext.get('centercolumn')")), PhpExt_Javascript::stm("bd.createChild({tag: 'h2', html: 'Form 4 - Forms can be a TabPanel...'})"), $tabs->getJavascript(false, "tabs"), $tabs->render(PhpExt_Javascript::variable("Ext.get('centercolumn')")), PhpExt_Javascript::stm("bd.createChild({tag: 'h2', html: 'Form 5 - ... and forms can contain TabPanel(s)'})"), $tabs2->getJavascript(false, "tabs2"), $tabs2->render(PhpExt_Javascript::variable("Ext.get('centercolumn')")));
Example #18
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/Panel.php';
$p = new PhpExt_Panel();
$p->setTitle("My Panel")->setCollapsible(true)->setRenderTo(PhpExt_Javascript::variable("Ext.get('centercolumn')"))->setWidth(400)->setHtml(PhpExt_Javascript::variable("Ext.example.bogusMarkup"));
echo PhpExt_Ext::OnReady($p->getJavascript(false, "p"));
Example #19
0
*/
$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"));
Example #20
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 #21
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 #22
0
 public static function valueToJavascript($value, $lazy = false)
 {
     $resolvedValue = $value;
     if (is_bool($value)) {
         $resolvedValue = $value ? "true" : "false";
     } else {
         if (is_null($value)) {
             $resolvedValue = null;
         } else {
             if (is_string($value)) {
                 $resolvedValue = "'{$value}'";
             } else {
                 if (is_array($value)) {
                     $resolvedValue = PhpExt_Javascript::jsonEncode($value);
                 } else {
                     if (PhpExt_Object::isExtObject($value)) {
                         $resolvedValue = $value->getJavascript($lazy);
                     } else {
                         if (PhpExt_ObjectCollection::isExtObjectCollection($value)) {
                             if ($value->getCount() > 0) {
                                 $resolvedValue = $value->getJavascript($lazy);
                             }
                         } else {
                             if (PhpExt_Javascript::isJavascript($value) || PhpExt_Javascript::isJavascriptStm($value)) {
                                 $resolvedValue = $value->output();
                             } else {
                                 if (is_object($value)) {
                                     $resolvedValue = PhpExt_Javascript::jsonEncode($value);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $resolvedValue;
 }
Example #23
0
 public function getJavascript()
 {
     $resolvedObjs = array();
     foreach ($this->Collection as &$obj) {
         $resolvedObjs[] = PhpExt_Javascript::valueToJavascript($obj, true);
     }
     if (count($resolvedObjs) == 1 && !$this->_forceArray) {
         return $resolvedObjs[0];
     } else {
         return "[" . implode(",", $resolvedObjs) . "]";
     }
 }
Example #24
0
$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"));
Example #25
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/SimpleStore.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/Grid/GridPanel.php';
// Sample Data
$myData = array(array('3m Co', 71.72, 0.02, 0.03, '9/1 12:00am'), array('Alcoa Inc', 29.01, 0.42, 1.47, '9/1 12:00am'), array('Altria Group Inc', 83.81, 0.28, 0.34, '9/1 12:00am'), array('American Express Company', 52.55, 0.01, 0.02, '9/1 12:00am'), array('American International Group, Inc.', 64.13, 0.31, 0.49, '9/1 12:00am'), array('AT&T Inc.', 31.61, -0.48, -1.54, '9/1 12:00am'), array('Boeing Co.', 75.43000000000001, 0.53, 0.71, '9/1 12:00am'), array('Caterpillar Inc.', 67.27, 0.92, 1.39, '9/1 12:00am'), array('Citigroup, Inc.', 49.37, 0.02, 0.04, '9/1 12:00am'), array('E.I. du Pont de Nemours and Company', 40.48, 0.51, 1.28, '9/1 12:00am'), array('Exxon Mobil Corp', 68.09999999999999, -0.43, -0.64, '9/1 12:00am'), array('General Electric Company', 34.14, -0.08, -0.23, '9/1 12:00am'), array('General Motors Corporation', 30.27, 1.09, 3.74, '9/1 12:00am'), array('Hewlett-Packard Co.', 36.53, -0.03, -0.08, '9/1 12:00am'), array('Honeywell Intl Inc', 38.77, 0.05, 0.13, '9/1 12:00am'), array('Intel Corporation', 19.88, 0.31, 1.58, '9/1 12:00am'), array('International Business Machines', 81.41, 0.44, 0.54, '9/1 12:00am'), array('Johnson & Johnson', 64.72, 0.06, 0.09, '9/1 12:00am'), array('JP Morgan & Chase & Co', 45.73, 0.07000000000000001, 0.15, '9/1 12:00am'), array('McDonald\'s Corporation', 36.76, 0.86, 2.4, '9/1 12:00am'), array('Merck & Co., Inc.', 40.96, 0.41, 1.01, '9/1 12:00am'), array('Microsoft Corporation', 25.84, 0.14, 0.54, '9/1 12:00am'), array('Pfizer Inc', 27.96, 0.4, 1.45, '9/1 12:00am'), array('The Coca-Cola Company', 45.07, 0.26, 0.58, '9/1 12:00am'), array('The Home Depot, Inc.', 34.64, 0.35, 1.02, '9/1 12:00am'), array('The Procter & Gamble Company', 61.91, 0.01, 0.02, '9/1 12:00am'), array('United Technologies Corporation', 63.26, 0.55, 0.88, '9/1 12:00am'), array('Verizon Communications', 35.57, 0.39, 1.11, '9/1 12:00am'), array('Wal-Mart Stores, Inc.', 45.45, 0.73, 1.63, '9/1 12:00am'));
$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"));
// Store
$store = new PhpExt_Data_SimpleStore();
$store->addField(new PhpExt_Data_FieldConfigObject("company"));
$store->addField(new PhpExt_Data_FieldConfigObject("price", null, "float"));
$store->addField(new PhpExt_Data_FieldConfigObject("change", null, "float"));
$store->addField(new PhpExt_Data_FieldConfigObject("pctChange", null, "float"));
$store->addField(new PhpExt_Data_FieldConfigObject("lastChange", null, "date", "n/j h:ia"));
// 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, 85, null, PhpExt_Javascript::variable("Ext.util.Format.dateRenderer('m/d/Y')"), null, true));
// Grid
$grid = new PhpExt_Grid_GridPanel();
$grid->setStore($store)->setColumnModel($colModel)->setStripeRows(true)->setAutoExpandColumn("company")->setHeight(350)->setWidth(600)->setTitle("Array Grid");
// Ext.OnReady -----------------------
echo PhpExt_Ext::onReady(PhpExt_Javascript::assignNew("myData", PhpExt_Javascript::valueToJavascript($myData)), $changeRenderer, $pctChangeRenderer, $store->getJavascript(false, "store"), $store->loadData(PhpExt_Javascript::variable("myData")), $grid->getJavascript(false, "grid"), $grid->render("grid-example"));
Example #26
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/Handler.php';
include_once 'PhpExt/Template.php';
include_once 'PhpExt/XTemplate.php';
include_once 'PhpExt/Panel.php';
include_once 'PhpExt/Toolbar/Toolbar.php';
$data = array('name' => 'Jack Slocum', 'company' => 'Ext JS, LLC', 'address' => '4 Red Bulls Drive', 'city' => 'Cleveland', 'state' => 'Ohio', 'zip' => '44102', 'kids' => array(array('name' => 'Sara Grace', 'age' => 3), array('name' => 'Zachary', 'age' => 2), array('name' => 'John James', 'age' => 0)));
/* Example 1: Basic Template */
$t = new PhpExt_Template("<p>Name: {name}</p>", "<p>Company: {company}</p>", '<p>Location: {city}, {state}</p>');
$p = new PhpExt_Panel();
$p->setTitle('Basic Template')->setWidth('300')->setHtml('<p><i>Apply the template to see results here</i></p>');
$tb = $p->getTopToolbar();
$tb->addButton("apply", "Apply Template", null, new PhpExt_Handler(PhpExt_Javascript::stm($t->getJavascript(false, "tpl")), $t->overwrite(PhpExt_Javascript::variable("p.body"), PhpExt_Javascript::variable("data"))));
$p->setRenderTo(PhpExt_Javascript::inlineStm("Ext.get('centercolumn')"));
/** Example 2: XTemplate */
$t2 = new PhpExt_XTemplate('<p>Name: {name}</p>', '<p>Company: {company}</p>', '<p>Location: {city}, {state}</p>', '<p>Kids: ', '<tpl for="kids" if="name==\\\'Jack Slocum\\\'">', '<tpl if="age &gt; 1"><p>{#}. {parent.name}\\\'s kid - {name}</p></tpl>', '</tpl></p>');
//$t2->VarName = "tpl2";
$p2 = new PhpExt_Panel();
$p2->setTitle('XTemplate')->setWidth('300')->setHtml('<p><i>Apply the template to see results here</i></p>');
$tb2 = $p2->getTopToolbar();
$tb2->addButton("apply", "Apply Template", null, new PhpExt_Handler(PhpExt_Javascript::stm($t2->getJavascript(false, "tpl2")), $t2->overwrite(PhpExt_Javascript::variable("p2.body"), PhpExt_Javascript::variable("data"))));
$p2->setRenderTo(PhpExt_Javascript::variable("Ext.get('centercolumn')"));
echo PhpExt_Ext::onReady(PhpExt_Javascript::stm("var data = " . PhpExt_Javascript::jsonEncode($data) . ";"), $p->getJavascript(false, "p"), $p2->getJavascript(false, "p2"));
Example #27
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);
Example #28
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&oacute;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();
Example #29
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");