예제 #1
0
 /**
  * Class Constructor
  * @param $name Name of the widget
  */
 public function __construct($name)
 {
     parent::__construct($name);
     $this->widget = new GtkHBox();
     parent::add($this->widget);
     $this->mask = 'yyyy-mm-dd';
     // creates the entry field
     $this->entry = new TEntry($name);
     $this->entry->setSize(200);
     $this->setMask($this->mask);
     $this->widget->add($this->entry);
     // creates a button with a calendar image
     $button = new GtkButton();
     $button->set_relief(GTK::RELIEF_NONE);
     $imagem = GtkImage::new_from_file('lib/adianti/images/tdate-gtk.png');
     $button->set_image($imagem);
     $this->actionButton = $button;
     // define the button's callback
     $button->connect_simple('clicked', array($this, 'onCalendar'));
     $this->widget->add($button);
     // creates the calendar window
     $this->popWindow = new GtkWindow(Gtk::WINDOW_POPUP);
     // creates the calendar
     $this->calendar = new GtkCalendar();
     // define the action when the user selects a date
     $this->calendar->connect_simple('day-selected-double-click', array($this, 'onSelectDate'));
     $this->month = new TCombo('tdate-month');
     $this->month->addItems(array(TAdiantiCoreTranslator::translate('January'), TAdiantiCoreTranslator::translate('February'), TAdiantiCoreTranslator::translate('March'), TAdiantiCoreTranslator::translate('April'), TAdiantiCoreTranslator::translate('May'), TAdiantiCoreTranslator::translate('June'), TAdiantiCoreTranslator::translate('July'), TAdiantiCoreTranslator::translate('August'), TAdiantiCoreTranslator::translate('September'), TAdiantiCoreTranslator::translate('October'), TAdiantiCoreTranslator::translate('November'), TAdiantiCoreTranslator::translate('December')));
     $this->month->setCallback(array($this, 'onChangeMonth'));
     $this->month->setSize(70);
     for ($n = date('Y') - 10; $n <= date('Y') + 10; $n++) {
         $years[$n] = $n;
     }
     $this->year = new TCombo('tdate-year');
     $this->year->addItems($years);
     $this->year->setCallback(array($this, 'onChangeMonth'));
     $this->year->setSize(70);
     $hbox = new GtkHBox();
     $hbox->pack_start($this->month);
     $hbox->pack_start($this->year);
     $bt_today = new GtkButton(TAdiantiCoreTranslator::translate('Today'));
     $bt_close = new GtkButton(TAdiantiCoreTranslator::translate('Close'));
     $bt_today->connect_simple('clicked', array($this, 'selectToday'));
     $inst = $this->popWindow;
     $bt_close->connect_simple('clicked', array($inst, 'hide'));
     $hbox2 = new GtkHBox();
     $hbox2->pack_start($bt_today);
     $hbox2->pack_start($bt_close);
     $vbox = new GtkVBox();
     $vbox->pack_start($hbox, FALSE, FALSE);
     $vbox->pack_start($this->calendar);
     $vbox->pack_start($hbox2, FALSE, FALSE);
     // shows the window
     $this->popWindow->add($vbox);
 }
예제 #2
0
 function preenche_lista()
 {
     $db = new Database($this->Owner, true);
     if (!$db->link) {
         return;
     }
     // Secoes
     $sql = 'SELECT * FROM Tb_Secoes';
     if (!$db->multi_query($sql)) {
         return;
     }
     while ($line = $db->line()) {
         $CodSecao = $line['Cod_S_Secao'];
         $Imagem = $line['Imagem'];
         $Nome = $line['Nome'];
         $this->lista->pack_start($ptr = $this->secoes[$CodSecao] = new GtkExpander(''), false);
         $ptr->add(new GtkVBox());
         $ptr->set_label_widget($hbox = new GtkHBox());
         $hbox->pack_start(GtkImage::new_from_file(XMONEY_IMAGES . DIRECTORY_SEPARATOR . $Imagem), false);
         $hbox->pack_start($label = new GtkLabel());
         $label->set_markup('<b>' . $Nome . '</b>');
         $ptr->show_all();
     }
     // Menus
     $sql = 'SELECT * FROM Tb_Menus';
     if (!$db->multi_query($sql)) {
         return;
     }
     while ($line = $db->line()) {
         $CodMenu = $line['Cod_S_Menu'];
         $CodSecao = $line['Cod_S_Secao'];
         $Imagem = $line['Imagem'];
         $Nome = $line['Nome'];
         $Permissao = $line['Permissao'];
         $Classe = $line['Classe'];
         $this->secoes[$CodSecao]->child->pack_start($button = new GtkButton());
         $button->set_relief(Gtk::RELIEF_NONE);
         $button->add($hbox = new GtkHBox());
         $hbox->pack_start(GtkImage::new_from_file(XMONEY_IMAGES . DIRECTORY_SEPARATOR . $Imagem), false);
         $hbox->pack_start(new GtkLabel(' ' . $Nome . ' '));
         $button->show_all();
         $button->connect('clicked', array($this, 'button_clicked'), array($Permissao, $Classe));
     }
     // Ajuda
     $this->lista->pack_start($ptr = new GtkExpander(''), false);
     $ptr->set_label_widget($hbox = new GtkHBox());
     $hbox->pack_start(GtkImage::new_from_file(XMONEY_IMAGES . DIRECTORY_SEPARATOR . 'ajuda.png'), false);
     $hbox->pack_start($label = new GtkLabel());
     $label->set_markup('<b>Ajuda</b>');
     $ptr->show_all();
     // Sobre
     $ptr->add($button = new GtkButton());
     $button->set_relief(Gtk::RELIEF_NONE);
     $button->add($hbox = new GtkHBox());
     $hbox->pack_start(GtkImage::new_from_file(XMONEY_IMAGES . DIRECTORY_SEPARATOR . 'sobre.png'), false);
     $hbox->pack_start(new GtkLabel('Sobre'));
     $ptr->show_all();
     $button->connect('clicked', array($this, 'sobre_clicked'));
     return true;
 }
예제 #3
0
 /**
  * Define the menu based on user profile
  */
 public function configureMenu()
 {
     if ($this->scroll->get_child()) {
         $this->scroll->remove($this->scroll->get_child());
     }
     TTransaction::open('library');
     $member = User::newFromLogin(TSession::getValue('login'));
     if ($member->role->mnemonic == 'LIBRARIAN') {
         $buttons = array();
         $buttons[] = array('<b>' . _t('Cataloging') . '</b>');
         $buttons[] = array(_t('Books'), 'BookList');
         $buttons[] = array(_t('Collections'), 'CollectionFormList');
         $buttons[] = array(_t('Classifications'), 'ClassificationFormList');
         $buttons[] = array(_t('Subjects'), 'SubjectList');
         $buttons[] = array(_t('Authors'), 'AuthorList');
         $buttons[] = array(_t('Publishers'), 'PublisherList');
         $buttons[] = array(_t('Status'), 'StatusFormList');
         $buttons[] = array('<b>' . _t('Members') . '</b>');
         $buttons[] = array(_t('Members'), 'MemberList');
         $buttons[] = array(_t('Categories'), 'CategoryFormList');
         $buttons[] = array(_t('Cities'), 'CityList');
         $buttons[] = array('<b>' . _t('Circulation') . '</b>');
         $buttons[] = array(_t('Check in'), 'CheckInForm');
         $buttons[] = array(_t('Check out'), 'CheckOutForm');
         $buttons[] = array('<b>' . _t('Reports') . '</b>');
         $buttons[] = array(_t('Loans'), 'LoanReport');
         $buttons[] = array(_t('Member'), 'MemberReport');
         $buttons[] = array(_t('Books'), 'BookReport');
         $buttons[] = array('Logout', array('LoginForm', 'onLogout'));
     } else {
         if ($member->role->mnemonic == 'OPERATOR') {
             $buttons = array();
             $buttons[] = array('<b>' . _t('Members') . '</b>');
             $buttons[] = array(_t('Members'), 'MemberList');
             $buttons[] = array(_t('Categories'), 'CategoryFormList');
             $buttons[] = array(_t('Cities'), 'CityList');
             $buttons[] = array('<b>' . _t('Circulation') . '</b>');
             $buttons[] = array(_t('Check in'), 'CheckInForm');
             $buttons[] = array(_t('Check out'), 'CheckOutForm');
             $buttons[] = array('<b>' . _t('Reports') . '</b>');
             $buttons[] = array(_t('Loans'), 'LoanReport');
             $buttons[] = array(_t('Member'), 'MemberReport');
             $buttons[] = array(_t('Books'), 'BookReport');
             $buttons[] = array('Logout', array('LoginForm', 'onLogout'));
         } else {
             if ($member->role->mnemonic == 'ADMINISTRATOR') {
                 $buttons = array();
                 $buttons[] = array('<b>' . 'Admin' . '</b>');
                 $buttons[] = array(_t('Users'), 'UserList');
                 $buttons[] = array(_t('Roles'), 'RoleList');
                 $buttons[] = array('Logout', array('LoginForm', 'onLogout'));
             }
         }
     }
     TTransaction::close();
     $vbox_buttons = new GtkVBox(FALSE, 0);
     $this->scroll->add_with_viewport($vbox_buttons);
     $this->scroll->get_child()->modify_bg(Gtk::STATE_NORMAL, GdkColor::parse('#EFEFEF'));
     foreach ($buttons as $button_info) {
         if (!isset($button_info[1])) {
             $button = new GtkEventBox();
             $button->add($label = new GtkLabel($button_info[0]));
             $button->set_size_request(-1, 20);
             $label->set_use_markup(TRUE);
             $button->modify_bg(Gtk::STATE_NORMAL, GdkColor::parse('#C0C0C0'));
         } else {
             $button = new GtkButton($button_info[0]);
             $button->get_child()->set_alignment(0, 0);
             $button->set_property('can-focus', FALSE);
             $button->set_relief(Gtk::RELIEF_NONE);
             $button->modify_bg(Gtk::STATE_PRELIGHT, GdkColor::parse('#CFCFCF'));
             $button->modify_bg(Gtk::STATE_ACTIVE, GdkColor::parse('#CFCFCF'));
             $button->set_size_request(-1, 24);
             $button->connect_simple('clicked', array($this, 'run'), $button_info[1]);
         }
         $vbox_buttons->pack_start($button, FALSE, FALSE, 0);
     }
     $this->scroll->show_all();
 }