Exemple #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);
    */
}
Exemple #2
0
 static function create($x)
 {
     global $rea_ui_datasources;
     ///N:Construct a data source from a rest web service
     ///N:Pass an absolute URL to a rest service. EX: rea_ui_datasource::create( "http://example.com/ajax.php?list=towns")
     ///N:Pass a relative URL to a rest service. EX:  rea_ui_datasource::create( "./rest/ajax.php?list=towns")
     ///N:Pass the name of an event that returns rest data. EX: rea_ui_datasource::create( "app_event_towns")
     ///N:By default a data source from a web service is "static". Which means is populated only once. If you want to make sure data is fetched always set
     ///N:the second optional argument to "dynamic", as in rea_ui_datasource::create( "./rest/ajax.php?list=towns", 'dynamic')
     ///N:Construct a datasource from an array.  EX:  rea_ui_datasource::create( $anArray )
     $ar = func_get_args();
     if (count($ar) < 1) {
         return null;
     }
     if (is_string($ar[0])) {
         $s = $ar[0];
         $p = strtolower(substr($s, 0, 4));
         $v1 = count($ar) > 1 ? $ar[1] : 'static';
         if ($p == 'https' || $p == 'http' || substr($p, 0, 1) == '/' || substr($p, 0, 2) == './' || strpos($s, '?') !== false) {
             return rea_ui_datasource::ajax($s, $v1);
         } elseif ($p == 'ajax') {
             $n = parse_url($s);
             if (strlen($n['path']) > 0) {
             }
             return rea_ui_datasource::ajax($s, $v1);
         } elseif (substr($s, 0, 10) == 'app_event_') {
             $s = substr($s, 10);
             $s = REA_SELF_URL . '?ajax=' . $s;
             return rea_ui_datasource::ajax($s, $v1);
         }
     } elseif (is_array($ar[0])) {
         $ds = new rea_ui_datasource();
         $ds->def['source'] = 'json';
         foreach ($ar[0] as $k => $v) {
             $ds->def['items'][] = [$k => $v];
         }
         $rea_ui_datasources[] = $ds;
         return $ds;
     }
 }
Exemple #3
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);
}