Esempio n. 1
0
 /**
  * Helper function to create a DateField.  Useful for quick adding it to a ComponentCollection
  *
  * @param string $name The field's HTML name attribute.
  * @param string $label The label text to display next to this field (defaults to '')
  * @param string $id The unique id of this component (defaults to an auto-assigned id).
  * @return PhpExt_Form_DateField
  */
 public static function createDateField($name, $label = null, $id = null)
 {
     $c = new PhpExt_Form_DateField();
     $c->setName($name);
     if ($label !== null) {
         $c->setFieldLabel($label);
     }
     if ($id !== null) {
         $c->setId($id);
     }
     return $c;
 }
Esempio n. 2
0
$col_model->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Id", "id", null, 35));
$col_model->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Moneda", "currency"));
$col_model->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Ultimo Valor", "value"));
$col_model->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Fecha", "date", null, 110));
$col_model->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Nuevo Valor", "new")->setEditor($txt_nuevo_valor));
$paging = new PhpExt_Toolbar_PagingToolbar();
$paging->setStore($store)->setDisplayInfo(true)->setEmptyMessage("No tiene monedas flotantes para definir el tipo de cambio");
//GRILLA
$grid = new PhpExt_Grid_EditorGridPanel();
$grid->setStore($store)->setColumnModel($col_model)->setSelectionModel(new PhpExt_Grid_RowSelectionModel())->setLoadMask(true)->setenableColLock(false);
$grid->setBottomToolbar($paging);
$grid->getPlugins()->add(new PhpExtUx_App_FitToParent());
$grid_render = "\n\n\nvar save = function(){\n\tvar fecha = grid.getTopToolbar().items.find( function(c){ return (c.xtype == 'datefield') } );\t\n\tvar store = grid.getStore();\n\tvar store_changes = store.getModifiedRecords();\n\t\n\tvar items = Array();\n\t\n\tfor( var i = 0, len = store_changes.length; i < len; i++ )\n\t{\t\t\n\t\tvar item = { \n\t\t\t\t\t id : store_changes[i].get('id'),\n\t\t\t\t  value : store_changes[i].get('new')\t\t\t\t\t\n\t\t           }\n\t\titems.push(item);\n\t}\n\t\n\tvar json = { \n\t\t\t\t fecha : fecha.value,\n\t\t\t\t items : items \n\t\t\t   }\n\t\n\tstore.load( { params:{ NewsValuesData : Ext.encode(json) } } );\n\tstore.commitChanges();\n\t\n\t\n}\n\t\nvar button1 = grid.getTopToolbar().items.find( function(c){ return ( c.text == 'Guardar cambios') } );\nbutton1.on( 'click', save );\n\n";
$grid->setEnableKeyEvents(true);
$grid->attachListener("render", new PhpExt_Listener(PhpExt_Javascript::functionDef(null, $grid_render, array("grid"))));
//CONTROL PARA LA FECHA
$txt_fecha = new PhpExt_Form_DateField();
$txt_fecha->setInvalidText("Fecha Invalida(dd/mm/yyyy)")->setValue(date('Y-m-d'))->setFormat(str_replace("%", "", $ari->get("locale")->get('shortdateformat', 'datetime')));
$tb = $grid->getTopToolbar();
$tb->addTextItem("text", "Fecha:");
$tb->addItem("txt_fecha", $txt_fecha);
$tb->addButton("update", "Guardar cambios", "images/save.gif");
$resultado = '';
$resultado .= $store->getJavascript(false, "store_user_list");
$resultado .= $col_model->getJavascript(false, "cm");
$resultado .= $grid->getJavascript(false, "contenido");
$resultado .= "store_user_list.load();";
//RESULTADO
$obj_comunication = new OOB_ext_comunication();
$obj_comunication->set_data($resultado);
$obj_comunication->send(true);
Esempio n. 3
0
$fs = new PhpExt_Form_FormPanel();
$fs->setFrame(true)->setTitle("XML Form")->setLabelAlign(PhpExt_Form_FormPanel::LABEL_ALIGN_RIGHT)->setLabelWidth(85)->setWidth(340)->setWaitMsgTarget(true);
// configure how to read the XML Data
$reader = new PhpExt_Data_XmlReader();
$reader->setRecord("contact")->setSuccess("@success");
$reader->addField(new PhpExt_Data_FieldConfigObject("first", "name/first"));
// custom mapping
$reader->addField(new PhpExt_Data_FieldConfigObject("last", "name/last"));
$reader->addField(new PhpExt_Data_FieldConfigObject("company", "company"));
$reader->addField(new PhpExt_Data_FieldConfigObject("email", "email"));
$reader->addField(new PhpExt_Data_FieldConfigObject("state", "state"));
$reader->addField(new PhpExt_Data_FieldConfigObject("dob", "dob", "date", "m/d/Y"));
// custom data types
$fs->setReader($reader);
$fs->setErrorReader(new PhpExtUx_Form_XmlErrorReader());
$fset = new PhpExt_Form_FieldSet();
$fset->setTitle("Contact Information")->setAutoHeight(true)->setDefaultType("textfield")->setDefaults(new PhpExt_Config_ConfigObject(array("width" => 190)))->addItem(PhpExt_Form_TextField::createTextField("first", "First Name"))->addItem(PhpExt_Form_TextField::createTextField("last", "Last Name"))->addItem(PhpExt_Form_TextField::createTextField("company", "Company"))->addItem(PhpExt_Form_TextField::createTextField("email", "Email", null, PhpExt_Form_FormPanel::VTYPE_EMAIL));
$combo = PhpExt_Form_ComboBox::createComboBox("state", "State")->setValueField("abbr")->setDisplayField("state")->setTypeAhead(true)->setMode(PhpExt_Form_ComboBox::MODE_LOCAL)->setTriggerAction(PhpExt_Form_ComboBox::TRIGGER_ACTION_ALL)->setEmptyText("Select a state...")->setSelectOnFocus(true);
$store = new PhpExt_Data_SimpleStore();
$store->addField("abbr");
$store->addField("state");
$store->setData(PhpExt_Javascript::variable("Ext.exampledata.states"));
$combo->setStore($store);
$fset->addItem($combo);
$fset->addItem(PhpExt_Form_DateField::createDateField("dob", "Data of Birth")->setAllowBlank(false));
$fs->addItem($fset);
$fs->addButton(PhpExt_Button::createTextButton("Load", new PhpExt_Handler(PhpExt_Javascript::stm("fs.getForm().load({url:'examples/form/xml-form.xml', waitMsg:'Loading',method: 'GET'})"))));
$submitBtn = PhpExt_Button::createTextButton("Submit", new PhpExt_Handler(PhpExt_Javascript::stm("fs.getForm().submit({url:'examples/form/xml-errors.xml', waitMsg:'Saving Data...'})")));
$fs->addButton($submitBtn);
//****************************** onReady
echo PhpExt_Ext::onReady(PhpExt_Javascript::stm(PhpExt_QuickTips::init()), PhpExt_Javascript::assign("Ext.form.Field.prototype.msgTarget", PhpExt_Javascript::valueToJavascript(PhpExt_Form_FormPanel::MSG_TARGET_SIDE)), $fs->getJavascript(false, "fs"), PhpExt_Javascript::assignNew("submit", $submitBtn->getJavascript()), $fs->render("form-ct"));
Esempio n. 4
0
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
// 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");