Beispiel #1
0
function app_event_test_tpl($values)
{
    global $config;
    error_log("@app_event_test_tpl ---------------------------------------------------");
    error_log(print_r($values, true));
    rea_views::setViewsPath(REA_SELF_DIRECTORY);
    //$p = rea_template::create('test.view');
    //rea_views::default_view( $p );
    $p = rea_views::default_view('reaui_test.view');
    //$p = rea_views::default_view( 'page_with_sidebar.view' );
    $p->sidebar->write("hello");
    //$page = rea_views::default_page("test.view");
    $p->title->write("Jose");
    //lets populate our view data
    $data = [];
    $data['email'] = '*****@*****.**';
    $data['payment_amount'] = '125.50';
    //$data['start_date'] = '5/14/2015'; //date can have a basic 'M/D/YYYY'
    //$data['start_date'] = date('c'); //date as ISO 8601 date
    $data['start_date'] = date('Y-m-d H:i:s');
    //date in MySQL datetime format
    $data['field01'] = [2];
    //checkbox are arrays
    $data['field02'] = [2];
    //radios are arrays
    $data['field04'] = false;
    //boolean checkbox or radios
    $data['field03'] = true;
    //boolean checkbox or radios
    $data['field05'] = false;
    //boolean checkbox or radios
    $data['field06'] = "Programmer";
    $data['fld_town02'] = 'mc';
    //lets create a datasource from our data
    $ds = rea_ui_datasource::create($data);
    //we bind our datasource to our form using a name selector and the form's name
    $ds->bindToSelector('[name=emp_record]');
    //now we add our
    //$p->js->write($ds);
    /*
    $towns = [
    	'hm' =>'Hormigueros',
    	'an' => 'Añasco'
    ];
    
    $ds = rea_ui_datasource::create($towns);
    */
}
Beispiel #2
0
function app_event_test_lookup($page, $values)
{
    global $config;
    //error_log(print_r($config, true));
    $panel = this::form('degree');
    $panel->addTitleRow('Record');
    $item = new ctrl_textbox('name', 'Jose');
    $panel->addFieldRow($item, 'Name', 'Enter a name');
    //lets build a lookup control...
    $item1 = new ctrl_lookup("prog2", '002');
    $item1->setProperty('showcode', 1);
    //if the bind value is shown on list and textbox
    //define an AJAX datasource for our list
    $url = this::eventURL('ajax_job_list');
    $ds = rea_ui_datasource::create($url, 'dynamic');
    $ds->bind('caption', 1);
    //bind the list's caption to the column/key 0 in the dataset
    $ds->bind('value', 0);
    //bind the list's value to the column/key 1 in the dataset, this is the value returned
    $item1->setDataSource($ds);
    $panel->addFieldRow($item1, "Job Type", 'This is a dynamic ds, data is loaded on request');
    $item = new ctrl_lookup("prog4", '005');
    $item->setProperty('showcode', 0);
    $a = array(array('code' => '004', 'name' => 'programmer'), array('code' => '005', 'name' => 'graphic artists'), array('code' => '006', 'name' => 'hello'));
    $ds = rea_ui_datasource::create($a);
    $ds->bind('caption', 'name');
    //bind the list's caption to the column/key 0 in the dataset
    $ds->bind('value', 'code');
    //bind the list's value to the column/key 1 in the dataset, this is the value returned
    $item->setDataSource($ds);
    $panel->addFieldRow($item, "With Array");
    $panel->addTitleRow("Binded Lookup", null, "A lookup with a datasource bounded to the value of the first.");
    //lets build a lookup control...
    $item2 = new ctrl_lookup("prog1", '002');
    $item2->setProperty('showcode', 1);
    //if the bind value is shown on list and textbox
    //define an AJAX datasource for our list
    $url = this::eventURL('ajax_job_list_static');
    $ds = rea_ui_datasource::create($url);
    $ds->bind('caption', 1);
    //bind the list's caption to the column/key 0 in the dataset
    $ds->bind('value', 0);
    //bind the list's value to the column/key 1 in the dataset, this is the value returned
    $item2->setDataSource($ds);
    $panel->addFieldRow($item2, "Job Category", 'This is a static ds, data is pulled only once');
    //This second lookup is bounded with the value of the prog1 lookup
    //lets build a lookup control...
    $item3 = new ctrl_lookup("prog3", '002');
    $item3->setProperty('showcode', 1);
    //if the bind value is shown on list and textbox
    //define an AJAX datasource for our list
    $url = this::eventURL('ajax_job_list');
    $ds = rea_ui_datasource::create($url, 'dynamic');
    $ds->bind('caption', 1);
    //bind the list's caption to the column/key 0 in the dataset
    $ds->bind('value', 0);
    //bind the list's value to the column/key 1 in the dataset, this is the value returned
    $ds->bindUpdateOnChange($item2, "category");
    $item3->setDataSource($ds);
    $panel->addFieldRow($item3, "Job Position", 'This is a dynamic ds, data is refreshed on request binded with the category');
    $item = new ctrl_button('cmd', 'Add', 'blue');
    //$item->setAction("alert(typeof arguments[1]); return false;");
    $item->setActionSubmit('test_form_save');
    $panel->addActionButton($item);
}