Exemple #1
0
 /**
  * Class Constructor
  * @param $type    Type of the message (info, error)
  * @param $message Message to be shown
  * @param $action  Action to process
  */
 public function __construct($type, $message, TAction $action = NULL)
 {
     $this->id = uniqid();
     if (!is_null($action)) {
         $this->action = '__adianti_load_page(\'' . $action->serialize() . '\');';
     }
     if (TPage::isMobile()) {
         $img = new TElement('img');
         $img->src = "lib/adianti/images/{$type}.png";
         $table = new TTable();
         $table->width = '250px';
         $table->bgcolor = '#E5E5E5';
         $table->style = "border-collapse:collapse";
         $row = $table->addRow();
         $row->addCell($img);
         $row->addCell($message);
         $table->show();
     } else {
         TPage::include_css('lib/adianti/include/tmessage/tmessage.css');
         // creates a pannel to show the dialog
         $painel = new TElement('div');
         $painel->{'class'} = 'tmessage';
         $painel->id = 'tmessage_' . $this->id;
         // creates a table for layout
         $table = new TTable();
         // creates a row for the icon and the message
         $row = $table->addRow();
         $row->addCell(new TImage("lib/adianti/images/{$type}.png"));
         $scroll = new TScroll();
         $scroll->setSize(350, 70);
         $scroll->add($message);
         $scroll->setTransparency(true);
         $cell = $row->addCell($scroll);
         // add the table to the pannel
         $painel->add($table);
         // show the pannel
         $painel->show();
         $script = new TElement('script');
         $script->{'type'} = 'text/javascript';
         $script->add(' $(function() {
             $( "#' . $painel->id . '" ).dialog({
                 height: 180,
                 width: 440,
                 stack: false,
                 zIndex: 3000,
                 modal: true,
                 buttons: {
                     OK: function() {
                         $( this ).dialog( "close" ); ' . $this->action . '
                     }
                 }
                 }).css("visibility", "visible");
                 
             	$( "#' . $painel->id . ' a" ).click(function () {
             	    window.open($(this).attr(\'href\'));
                 }); 
             });');
         $script->show();
     }
 }
Exemple #2
0
 /**
  * Class Constructor
  * @param  $message    A string containint the question
  * @param  $action_yes Action taken for YES response
  * @param  $action_no  Action taken for NO  response
  */
 public function __construct($message, TAction $action_yes = NULL, TAction $action_no = NULL)
 {
     $this->id = uniqid();
     if (TPage::isMobile()) {
         $img = new TElement('img');
         $img->src = "lib/adianti/images/question.png";
         $yes = new TElement('a');
         $yes->href = $action_yes->serialize();
         $yes->generator = 'adianti';
         $yes->add(TAdiantiCoreTranslator::translate('Yes'));
         $no = new TElement('a');
         $no->href = $action_no->serialize();
         $no->generator = 'adianti';
         $no->add(TAdiantiCoreTranslator::translate('No'));
         $table = new TTable();
         $table->width = '250px';
         $table->bgcolor = '#E5E5E5';
         $table->style = "border-collapse:collapse";
         $row = $table->addRow();
         $row->addCell($img);
         $table2 = new TTable();
         $row->addCell($table2);
         $row = $table2->addRow();
         $c = $row->addCell($message);
         $c->colspan = 2;
         $row = $table2->addRow();
         $row->addCell($yes);
         $row->addCell($no);
         $table->show();
     } else {
         TPage::include_css('lib/adianti/include/tmessage/tmessage.css');
         // creates a layer to show the dialog
         $painel = new TElement('div');
         $painel->{'class'} = "tmessage";
         $painel->id = 'tquestion_' . $this->id;
         $url_yes = '';
         $url_no = '';
         if ($action_yes) {
             // convert the actions into URL's
             $url_yes = TAdiantiCoreTranslator::translate('Yes') . ': function () { $( this ).dialog( "close" ); __adianti_load_page(\'' . $action_yes->serialize() . '\');},';
         }
         if ($action_no) {
             $url_no = TAdiantiCoreTranslator::translate('No') . ': function () { $( this ).dialog( "close" ); __adianti_load_page(\'' . $action_no->serialize() . '\');},';
         } else {
             $url_no = TAdiantiCoreTranslator::translate('No') . ': function () { $( this ).dialog( "close" );},';
         }
         // creates a table for layout
         $table = new TTable();
         // creates a row for the icon and the message
         $row = $table->addRow();
         $row->addCell(new TImage("lib/adianti/images/question.png"));
         $scroll = new TScroll();
         $scroll->setSize(350, 70);
         $scroll->add($message);
         $scroll->setTransparency(true);
         $cell = $row->addCell($scroll);
         // add the table to the pannel
         $painel->add($table);
         // show the pannel
         $painel->show();
         $script = new TElement('script');
         $script->add(' $(function() {
             $( "#' . $painel->id . '" ).dialog({
                 height: 180,
                 width: 440,
                 modal: true,
                 stack: false,
                 zIndex: 3000,
                 buttons: {
                 ' . $url_yes . $url_no . TAdiantiCoreTranslator::translate('Cancel') . ': function() {
                         $( this ).dialog( "close" );
                     }
                 }
                 }).css("visibility", "visible");
             });');
         $script->show();
     }
 }
 /**
  * Class constructor
  * Creates the page and the registration form
  */
 function __construct()
 {
     parent::__construct();
     // creates the notebook
     $this->notebook = new TNotebook();
     $this->notebook->setSize(600, 350);
     $scroll = new TScroll();
     $scroll->setSize(600, 350);
     $scroll->setTransparency(TRUE);
     // creates the table container
     $table = new TTable();
     $frame_programs = new TFrame(400, 250);
     $frame_programs->setLegend(_t('Programs'));
     // creates the form
     $this->form = new TForm('form_System_group');
     $this->notebook->appendPage(_t('Groups'), $scroll);
     $scroll->add($table);
     // add the notebook inside the form
     $this->form->add($this->notebook);
     // create the form fields
     $id = new TEntry('id');
     $name = new TEntry('name');
     $multifield = new TMultiField('programs');
     $program_id = new TDBSeekButton('program_id', 'permission', 'form_System_group', 'SystemProgram', 'name', 'programs_id', 'programs_name');
     $program_name = new TEntry('program_name');
     $frame_programs->add($multifield);
     $multifield->setHeight(140);
     $multifield->setClass('SystemProgram');
     $multifield->addField('id', _t('Program') . ' ID', $program_id, 100, true);
     $multifield->addField('name', _t('Name'), $program_name, 250);
     $multifield->setOrientation('horizontal');
     // define the sizes
     $program_id->setSize(70);
     $id->setSize(100);
     $name->setSize(200);
     // validations
     $name->addValidation('name', new TRequiredValidator());
     // outras propriedades
     $id->setEditable(false);
     $program_name->setEditable(false);
     // add a row for the field id
     $table->addRowSet(new TLabel('ID:'), $id);
     $table->addRowSet(new TLabel(_t('Name') . ': '), $name);
     // add a row for the field name
     $row = $table->addRow();
     $cell = $row->addCell($frame_programs);
     $cell->colspan = 2;
     // create an action button (save)
     $save_button = new TButton('save');
     $save_button->setAction(new TAction(array($this, 'onSave')), _t('Save'));
     $save_button->setImage('ico_save.png');
     // create an new button (edit with no parameters)
     $new_button = new TButton('new');
     $new_button->setAction(new TAction(array($this, 'onEdit')), _t('New'));
     $new_button->setImage('ico_new.png');
     $list_button = new TButton('list');
     $list_button->setAction(new TAction(array('SystemGroupList', 'onReload')), _t('Back to the listing'));
     $list_button->setImage('ico_datagrid.png');
     // define the form fields
     $this->form->setFields(array($id, $name, $multifield, $save_button, $new_button, $list_button));
     $buttons = new THBox();
     $buttons->add($save_button);
     $buttons->add($new_button);
     $buttons->add($list_button);
     $container = new TTable();
     $container->addRow()->addCell(new TXMLBreadCrumb('menu.xml', 'SystemGroupList'));
     $container->addRow()->addCell($this->form);
     $container->addRow()->addCell($buttons);
     // add the form to the page
     parent::add($container);
 }