Esempio n. 1
0
 /**
  * Class constructor
  * Creates the page
  */
 public function __construct()
 {
     parent::__construct();
     new TSession();
     // creates the items form and add a table inside
     $this->form_item = new TForm('form_pos');
     $this->form_item->class = 'tform';
     $table_item = new TTable();
     $table_item->width = '100%';
     $this->form_item->add($table_item);
     // create the form fields
     $product_id = new TDBSeekButton('product_id', 'samples', 'form_pos', 'Product', 'description', 'product_id', 'product_description');
     $product_description = new TEntry('product_description');
     $sale_price = new TEntry('sale_price');
     $amount = new TEntry('amount');
     $discount = new TEntry('discount');
     $total = new TEntry('total');
     // add validators
     $product_id->addValidation('Product', new TRequiredValidator());
     $amount->addValidation('Amount', new TRequiredValidator());
     // define the exit actions
     $product_id->setExitAction(new TAction(array($this, 'onExitProduct')));
     $amount->setExitAction(new TAction(array($this, 'onUpdateTotal')));
     $discount->setExitAction(new TAction(array($this, 'onUpdateTotal')));
     // define some attributes
     $product_id->style = 'font-size: 17pt; height: 30px';
     $product_description->style = 'font-size: 17pt; height: 30px';
     $sale_price->style = 'font-size: 17pt; height: 30px';
     $amount->style = 'font-size: 17pt; height: 30px';
     $discount->style = 'font-size: 17pt; height: 30px';
     $total->style = 'font-size: 17pt; height: 30px';
     $product_id->button->style = 'height: 30px; margin-top:0px; vertical-align:top';
     // define some properties
     $product_id->setSize(50);
     $product_description->setEditable(FALSE);
     $sale_price->setEditable(FALSE);
     $total->setEditable(FALSE);
     $sale_price->setNumericMask(2, '.', ',');
     $discount->setNumericMask(2, '.', ',');
     $total->setNumericMask(2, '.', ',');
     $sale_price->setSize(100);
     $amount->setSize(100);
     $discount->setSize(100);
     $total->setSize(100);
     // add a row for the form title
     $row = $table_item->addRow();
     $row->class = 'tformtitle';
     // CSS class
     $cell = $row->addCell(new TLabel('Point of Sales'));
     $cell->colspan = 4;
     // create the field labels
     $lab_pro = new TLabel('Product');
     $lab_des = new TLabel('Description');
     $lab_pri = new TLabel('Price');
     $lab_amo = new TLabel('Amount');
     $lab_dis = new TLabel('Discount');
     $lab_tot = new TLabel('Total');
     $lab_pro->setFontSize(17);
     $lab_des->setFontSize(17);
     $lab_pri->setFontSize(17);
     $lab_amo->setFontSize(17);
     $lab_dis->setFontSize(17);
     $lab_tot->setFontSize(17);
     $lab_pro->setFontFace('Trebuchet MS');
     $lab_des->setFontFace('Trebuchet MS');
     $lab_pri->setFontFace('Trebuchet MS');
     $lab_amo->setFontFace('Trebuchet MS');
     $lab_dis->setFontFace('Trebuchet MS');
     $lab_tot->setFontFace('Trebuchet MS');
     $lab_pro->setFontColor('red');
     $lab_amo->setFontColor('red');
     // creates the action button
     $button1 = new TButton('add');
     $button1->setAction(new TAction(array($this, 'onAddItem')), 'Add item');
     $button1->setImage('ico_add.png');
     // add the form fields
     $table_item->addRowSet($lab_pro, $product_id, $lab_des, $product_description);
     $table_item->addRowSet($lab_pri, $sale_price, $lab_amo, $amount);
     $table_item->addRowSet($lab_dis, $discount, $lab_tot, array($total, $button1));
     // define the form fields
     $this->form_item->setFields(array($product_id, $product_description, $sale_price, $amount, $discount, $total, $button1));
     // creates the customer form and add a table inside it
     $this->form_customer = new TForm('form_customer');
     $this->form_customer->class = 'tform';
     $table_customer = new TTable();
     $table_customer->width = '100%';
     $this->form_customer->add($table_customer);
     // add a row for the form title
     $row = $table_customer->addRow();
     $row->class = 'tformtitle';
     // CSS class
     $cell = $row->addCell(new TLabel('Customer'));
     $cell->colspan = 5;
     // create the form fields
     $customer_id = new TDBSeekButton('customer_id', 'samples', 'form_customer', 'Customer', 'name', 'customer_id', 'customer_name');
     $customer_name = new TEntry('customer_name');
     // define validation and other properties
     $customer_id->addValidation('Customer', new TRequiredValidator());
     $customer_id->style = 'font-size: 17pt; height: 30px';
     $customer_name->style = 'font-size: 17pt; height: 30px';
     $customer_id->button->style = 'height: 30px; margin-top:0px; vertical-align:top';
     $customer_id->setSize(50);
     $customer_name->setEditable(FALSE);
     // create tha form labels
     $lab_cus = new TLabel('Customer');
     $lab_nam = new TLabel('Name');
     $lab_cus->setFontSize(17);
     $lab_nam->setFontSize(17);
     $lab_cus->setFontFace('Trebuchet MS');
     $lab_nam->setFontFace('Trebuchet MS');
     $lab_cus->setFontColor('red');
     // action button
     $button2 = new TButton('save');
     $button2->setAction(new TAction(array($this, 'onSave')), 'Save and finish');
     $button2->setImage('ico_save.png');
     // add the form fields inside the table
     $table_customer->addRowSet($lab_cus, $customer_id, $lab_nam, $customer_name, $button2);
     // define the form fields
     $this->form_customer->setFields(array($customer_id, $customer_name, $button2));
     // creates the grid for items
     $this->cartgrid = new TQuickGrid();
     $this->cartgrid->class = 'tdatagrid_table customized-table';
     $this->cartgrid->makeScrollable();
     $this->cartgrid->setHeight(150);
     parent::include_css('app/resources/custom-table.css');
     $this->cartgrid->addQuickColumn('ID', 'product_id', 'right', 25);
     $this->cartgrid->addQuickColumn('Description', 'product_description', 'left', 230);
     $this->cartgrid->addQuickColumn('Price', 'sale_price', 'right', 80);
     $this->cartgrid->addQuickColumn('Amount', 'amount', 'right', 70);
     $this->cartgrid->addQuickColumn('Discount', 'discount', 'right', 70);
     $this->cartgrid->addQuickColumn('Total', 'total', 'right', 100);
     $this->cartgrid->addQuickAction('Delete', new TDataGridAction(array($this, 'onDelete')), 'product_id', 'ico_delete.png');
     $this->cartgrid->createModel();
     // wrap the page content using vertical box
     $vbox = new TVBox();
     $vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
     $vbox->add($this->form_item);
     $vbox->add(new TLabel(' '));
     $vbox->add($this->cartgrid);
     $vbox->add(new TLabel(' '));
     $vbox->add($this->form_customer);
     parent::add($vbox);
 }
Esempio n. 2
0
 /**
  * Class constructor
  * Creates the page and the registration form
  */
 function __construct()
 {
     parent::__construct();
     // creates the form
     $this->form = new TForm('form_Sale');
     $this->form->class = 'tform';
     // CSS class
     parent::include_css('app/resources/custom-frame.css');
     $table_master = new TTable();
     $table_master->width = '100%';
     $table_master->addRowSet(new TLabel('Sale'), '', '')->class = 'tformtitle';
     // add a table inside form
     $table_general = new TTable();
     $table_general->width = '100%';
     $tableProduct = new TTable();
     $tableProduct->width = '100%';
     $frame_general = new TFrame();
     $frame_general->setLegend('General data');
     $frame_general->style = 'background:whiteSmoke';
     $frame_general->add($table_general);
     $table_master->addRow()->addCell($frame_general)->colspan = 2;
     $row = $table_master->addRow();
     $row->addCell($tableProduct);
     $this->form->add($table_master);
     // master fields
     $id = new TEntry('id');
     $date = new TDate('date');
     $customer_id = new TDBSeekButton('customer_id', 'samples', $this->form->getName(), 'Customer', 'name', 'customer_id', 'customer_name');
     $customer_name = new TEntry('customer_name');
     $obs = new TText('obs');
     // detail fields
     $product_id = new TDBSeekButton('product_id', 'samples', $this->form->getName(), 'Product', 'description', 'product_id', 'product_name');
     $product_name = new TEntry('product_name');
     $sale_price = new TEntry('product_price');
     $amount = new TEntry('product_amount');
     $discount = new TEntry('product_discount');
     $total = new TEntry('product_total');
     $product_id->setExitAction(new TAction(array($this, 'onProductChange')));
     $id->setSize(40);
     $date->setSize(100);
     $obs->setSize(400, 100);
     $product_id->setSize(50);
     $customer_id->setSize(50);
     $id->setEditable(false);
     $product_name->setEditable(false);
     $customer_name->setEditable(false);
     $date->addValidation('Date', new TRequiredValidator());
     $customer_id->addValidation('Customer', new TRequiredValidator());
     // pedido
     $table_general->addRowSet(new TLabel('ID'), $id);
     $table_general->addRowSet($label_date = new TLabel('Date (*)'), $date);
     $table_general->addRowSet($label_customer = new TLabel('Customer (*)'), array($customer_id, $customer_name));
     $table_general->addRowSet(new TLabel('Obs'), $obs);
     $label_date->setFontColor('#FF0000');
     // products
     $frame_product = new TFrame();
     $frame_product->setLegend('Products');
     $row = $tableProduct->addRow();
     $row->addCell($frame_product);
     $add_product = new TButton('add_product');
     $action_product = new TAction(array($this, 'onProductAdd'));
     $add_product->setAction($action_product, 'Register');
     $add_product->setImage('fa:save');
     $subtable_product = new TTable();
     $frame_product->add($subtable_product);
     $subtable_product->addRowSet($label_product = new TLabel('Product (*)'), array($product_id, $product_name));
     $subtable_product->addRowSet($label_sale_price = new TLabel('Price (*)'), $sale_price);
     $subtable_product->addRowSet($label_amount = new TLabel('Amount(*)'), $amount);
     $subtable_product->addRowSet(new TLabel('Discount'), $discount);
     $subtable_product->addRowSet($add_product);
     $label_product->setFontColor('#FF0000');
     $label_amount->setFontColor('#FF0000');
     $label_sale_price->setFontColor('#FF0000');
     $this->product_list = new TQuickGrid();
     $this->product_list->setHeight(175);
     $this->product_list->makeScrollable();
     $this->product_list->disableDefaultClick();
     $this->product_list->addQuickColumn('', 'edit', 'left', 50);
     $this->product_list->addQuickColumn('', 'delete', 'left', 50);
     $this->product_list->addQuickColumn('ID', 'product_id', 'center', 40);
     $this->product_list->addQuickColumn('Product', 'product_name', 'left', 200);
     $this->product_list->addQuickColumn('Amount', 'product_amount', 'left', 60);
     $this->product_list->addQuickColumn('Price', 'product_price', 'right', 80);
     $this->product_list->addQuickColumn('Discount', 'product_discount', 'right', 80);
     $this->product_list->createModel();
     $row = $tableProduct->addRow();
     $row->addCell($this->product_list);
     // 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, 'onClear')), _t('New'));
     $new_button->setImage('ico_new.png');
     // define form fields
     $this->formFields = array($id, $date, $customer_id, $customer_name, $obs, $product_id, $product_name, $sale_price, $amount, $discount, $total, $add_product, $save_button, $new_button);
     $this->form->setFields($this->formFields);
     $table_master->addRowSet(array($save_button, $new_button), '', '')->class = 'tformaction';
     // CSS class
     // create the page container
     $container = new TVBox();
     $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
     $container->add($this->form);
     parent::add($container);
 }