Beispiel #1
0
 /**
  * Class constructor
  * Creates the page
  */
 function __construct()
 {
     parent::__construct();
     $html1 = new THtmlRenderer('app/resources/welcome.html');
     // replace the main section variables
     $html1->enableSection('main', array());
     /*
     $panel1 = new TPanelGroup('Welcome!');
     $panel1->add($html1);
     */
     // add the template to the page
     parent::add($html1);
 }
 /**
  * Show customer data and sales
  */
 public function onCheckSales()
 {
     try {
         $data = $this->form->getData();
         // get form data
         $this->form->setData($data);
         // keep the form filled
         // load the html template
         $html = new THtmlRenderer('app/resources/customer_status.html');
         // load CSS styles
         parent::include_css('app/resources/styles.css');
         TTransaction::open('samples');
         $customer = new Customer();
         // load customer identified in the form
         $object = $customer->load($data->customer_id);
         if ($object) {
             // create one array with the customer data
             $array_object = $object->toArray();
             $array_object['city_name'] = $object->city_name;
             $array_object['category_name'] = $object->category_name;
             // replace variables from the main section with the object data
             $html->enableSection('main', $array_object);
             $replaces = array();
             $sales = $object->getSales();
             if ($sales) {
                 $total = 0;
                 // iterate the customer sales
                 foreach ($sales as $sale) {
                     // foreach sale item
                     foreach ($sale->getSaleItems() as $item) {
                         // define the multidimensional array with the sale items
                         $replaces[] = array('date' => $sale->date, 'product_id' => $item->product_id, 'product_description' => $item->product->description, 'sale_price' => number_format($item->sale_price, 2), 'amount' => $item->amount, 'discount' => $item->discount, 'total' => number_format($item->total, 2));
                         $total += $item->total;
                     }
                 }
                 $totals['total'] = number_format($total, 2);
                 // replace sale items and totals
                 $html->enableSection('sale-details', $replaces, TRUE);
                 $html->enableSection('sale-totals', $totals);
             }
         } else {
             throw new Exception('Customer not found');
         }
         TTransaction::close();
         parent::add($html);
     } catch (Exception $e) {
         new TMessage('error', $e->getMessage());
     }
 }
 /**
  * Class constructor
  * Creates the page
  */
 function __construct()
 {
     parent::__construct();
     TPage::include_css('app/resources/styles.css');
     $html1 = new THtmlRenderer('app/resources/welcome.html');
     $html2 = new THtmlRenderer('app/resources/bemvindo.html');
     // replace the main section variables
     $html1->enableSection('main', array());
     $html2->enableSection('main', array());
     $panel1 = new TPanelGroup('Welcome!');
     $panel1->add($html1);
     $panel2 = new TPanelGroup('Bem-vindo!');
     $panel2->add($html2);
     // add the template to the page
     parent::add(TVBox::pack($panel1, $panel2));
 }
 /**
  * Class constructor
  * Creates the page
  */
 function __construct()
 {
     parent::__construct();
     // load the styles
     TPage::include_css('app/resources/formdecorator.css');
     // create the HTML Renderer
     $html = new THtmlRenderer('app/resources/formdecorator.html');
     // create the form using TQuickForm class
     $this->form = new TQuickForm();
     // create the form fields
     $id = new TEntry('id');
     $description = new TEntry('description');
     $date = new TDate('date');
     $time = new TEntry('time');
     $number = new TEntry('number');
     $text = new TText('text');
     $description->setTip('Type the description here...');
     $date->setMask('dd/mm/yyyy');
     // define date mask
     $time->setMask('99:99');
     $number->setNumericMask(2, ',', '.');
     // define numeric input
     // add the fields inside the form
     $this->form->addQuickField('Id', $id, 40);
     $this->form->addQuickField('Description', $description, 200);
     $this->form->addQuickField('Date (dd/mm/yyyy)', $date, 80);
     $this->form->addQuickField('Time (99:99)', $time, 60);
     $this->form->addQuickField('Numeric Input (9.999,99)', $number, 100);
     $this->form->addQuickField('Text', $text, 120);
     $text->setSize(200, 100);
     // define the form action
     $this->form->addQuickAction('Save', new TAction(array($this, 'onSave')), 'ico_save.png');
     // replace the main section variables
     $replace = array('form' => $this->form);
     $html->enableSection('main', $replace);
     // wrap the page content using vertical box
     $vbox = new TVBox();
     $vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
     $vbox->add($html);
     parent::add($vbox);
 }
 public function __construct()
 {
     // parent classs constructor
     parent::__construct();
     $xml = simplexml_load_file('menu.xml');
     foreach ($xml as $xmlElement) {
         $atts = $xmlElement->attributes();
         $index = (string) $atts['label'];
         if ($xmlElement->menu) {
             foreach ($xmlElement->menu->menuitem as $subXmlElement) {
                 $subindex = (string) $subXmlElement['label'];
                 $subatts = $subXmlElement->attributes();
                 $items = array();
                 if ($subXmlElement->menu) {
                     foreach ($subXmlElement->menu->menuitem as $option) {
                         $optatts = $option->attributes();
                         $label = (string) $option['label'];
                         $action = (string) $option->action;
                         $icon = (string) $option->icon;
                         $items[] = array('label' => $label, 'action' => $action, 'icon' => $icon);
                     }
                 }
                 $section = new THtmlRenderer('app/resources/menupart.html');
                 $section->enableSection('main', array('subindex' => (string) $subindex));
                 $section->enableSection('items', $items, TRUE);
                 $replaces[$index][] = array('options' => $section);
             }
         }
     }
     $this->html = new THtmlRenderer('app/resources/home.html');
     $this->html->enableSection('main');
     $this->html->enableSection('persistence', $replaces['Persistence'], TRUE);
     $this->html->enableSection('presentation', $replaces['Presentation'], TRUE);
     $this->html->enableSection('organization', $replaces['Organization'], TRUE);
     parent::add($this->html);
 }
 public function __construct()
 {
     parent::__construct();
     $html = new THtmlRenderer('app/resources/profile.html');
     $replaces = array();
     try {
         TTransaction::open('permission');
         $user = SystemUser::newFromLogin(TSession::getValue('login'));
         $replaces = $user->toArray();
         $replaces['frontpage'] = $user->frontpage_name;
         $replaces['groupnames'] = $user->getSystemUserGroupNames();
         TTransaction::close();
     } catch (Exception $e) {
         new TMessage('error', $e->getMessage());
     }
     $html->enableSection('main', $replaces);
     $html->enableTranslation();
     $bc = new TBreadCrumb();
     $bc->addHome();
     $bc->addItem('Perfil');
     $container = TVBox::pack($bc, $html);
     $container->style = 'width:60%';
     parent::add($container);
 }
 public function __construct()
 {
     parent::__construct();
     // load the html template
     $html = new THtmlRenderer('app/resources/testeformview.html');
     // load CSS styles
     parent::include_css('app/resources/formview.css');
     TTransaction::open('samples');
     $customer = new Customer();
     $replace = array();
     $html->enableSection('main', $replace);
     $replaces = array();
     $total = 0;
     for ($n = 0; $n <= 3; $n++) {
         // define the multidimensional array with the sale items
         $replaces[] = array('id' => 1, 'descricao' => 'sdf', 'preco' => 123, 'qtde' => 10, 'desconto' => 10, 'total' => 1230);
         $total += 123;
     }
     $totals['total'] = number_format($total, 2);
     // replace sale items and totals
     $html->enableSection('details', $replaces, TRUE);
     $html->enableSection('totals', $totals);
     parent::add($html);
 }
 /**
  * Constructor method
  */
 public function __construct()
 {
     parent::__construct();
     // create the HTML Renderer
     $this->html = new THtmlRenderer('app/resources/agenda.html');
     // define replacements for the main section
     $replaces = array();
     try {
         // load the products
         TTransaction::open('samples');
         $events = Event::getWeekEvents();
         $first_date = Event::getFirstWeekDay();
         $replace_detail = array();
         if ($events) {
             // iterate products
             foreach ($events as $event) {
                 $ordered_events[$event->event_date][(int) $event->start_hour] = $event;
             }
             for ($day = 0; $day < 7; $day++) {
                 $dt = new DateTime($first_date);
                 $dt->add(new DateInterval('P' . $day . 'D'));
                 $filter_date = $dt->format('Y-m-d');
                 $replaces['day' . ($day + 1)] = '';
                 if (isset($ordered_events[$filter_date])) {
                     for ($hour = 0; $hour < 24; $hour++) {
                         if (isset($ordered_events[$filter_date][$hour])) {
                             $event = $ordered_events[$filter_date][$hour];
                             $replace_event = $event->toArray();
                             $replace_event['height'] = $event->duration * 24;
                             $replace_event['hour'] = $hour;
                             $event_html = new THtmlRenderer('app/resources/event.html');
                             $event_html->enableSection('main', $replace_event);
                             $replaces['day' . ($day + 1)] .= $event_html->getContents();
                             // array of replacements
                             $hour += $event->duration - 1;
                         } else {
                             $event_html = new THtmlRenderer('app/resources/event_empty.html');
                             $event_html->enableSection('main', array('popmenu' => 'fa-plus-square-o', 'day' => $filter_date, 'hour' => $hour));
                             $replaces['day' . ($day + 1)] .= $event_html->getContents();
                         }
                     }
                 } else {
                     for ($hour = 0; $hour < 24; $hour++) {
                         $event_html = new THtmlRenderer('app/resources/event_empty.html');
                         $event_html->enableSection('main', array('popmenu' => 'fa-plus-square-o', 'day' => $filter_date, 'hour' => $hour));
                         $replaces['day' . ($day + 1)] .= $event_html->getContents();
                     }
                 }
             }
         } else {
             for ($day = 0; $day < 7; $day++) {
                 $dt = new DateTime($first_date);
                 $dt->add(new DateInterval('P' . $day . 'D'));
                 $filter_date = $dt->format('Y-m-d');
                 $replaces['day' . ($day + 1)] = '';
                 for ($hour = 0; $hour < 24; $hour++) {
                     $event_html = new THtmlRenderer('app/resources/event_empty.html');
                     $event_html->enableSection('main', array('popmenu' => 'fa-plus-square-o', 'day' => $filter_date, 'hour' => $hour));
                     $replaces['day' . ($day + 1)] .= $event_html->getContents();
                 }
             }
         }
         // enable products section as repeatable
         $this->html->enableSection('main', $replaces);
         TTransaction::close();
     } catch (Exception $e) {
         new TMessage('error', $e->getMessage());
     }
     // wrap the page content using vertical box
     $vbox = new TVBox();
     $vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
     $vbox->add($this->html);
     parent::add($vbox);
 }