Esempio n. 1
0
 function save($apply = false)
 {
     JRequest::checkToken() or jexit('Invalid Token');
     $mainframe = JFactory::getApplication();
     /* @var $mainframe JApplication */
     $user = JFactory::getUser();
     /* @var $user JUser */
     $config = JBFactory::getConfig();
     $post = JRequest::get('post');
     AImporter::model('customer');
     $model = new BookProModelCustomer();
     if ($user->id) {
         $customer = $model->getItemByUser();
         $post['id'] = $customer->id;
     } else {
         $post['id'] = 0;
     }
     $isNew = $post['id'] == 0;
     $id = $model->save($post);
     if ($id !== false) {
         $mainframe->enqueueMessage(JText::_('Successfully saved'), 'message');
     } else {
         $mainframe->enqueueMessage(JText::_('Save failed'), 'error');
         JBLog::add('Can not save customer info');
     }
     $mainframe->redirect('index.php?option=com_bookpro&view=account&form=profile&Itemid=' . JRequest::getVar('Itemid'));
 }
Esempio n. 2
0
 function display($tpl = null)
 {
     $user = JFactory::getUser();
     $this->customer = new JObject();
     if (!$user->get('guest') && !$is_agent) {
         $model = new BookProModelCustomer();
         $customer = $model->getItemByUser();
         $this->customer = $customer;
     }
     $this->config = JComponentHelper::getParams('com_bookpro');
     $this->plugins = $this->getPlugins();
     parent::display($tpl);
 }
Esempio n. 3
0
 function exportmonthpdf()
 {
     $datefrom = JFactory::$application->input->get('datefrom');
     $dateto = JFactory::$application->input->get('dateto');
     AImporter::helper('pdf', 'order');
     AImporter::model('customer');
     $customerModel = new BookProModelCustomer();
     $customer = $customerModel->getItemByUser();
     $user_id = $customer->id;
     AImporter::model('orders');
     $model = new BookProModelOrders();
     $state = $model->getState();
     $state->set('list.start', 0);
     $state->set('list.limit', 0);
     $state->set('filter.datefrom', $datefrom);
     $state->set('filter.dateto', $dateto);
     $state->set('filter.user_id', $user_id);
     $orders = $model->getItems();
     $object = new JObject();
     $object->orders = $orders;
     $object->customer = $customer;
     $object->order_number = time();
     $object->date = JText::sprintf('COM_BOOKPRO_BILL_FROM_TO', $datefrom, $dateto);
     $ticket_view = $this->getView('ordersagent', 'html', 'BookProView');
     if ($user_id) {
         $ticket_view->ordersComplex = $object;
         ob_start();
         $ticket_view->display();
         $pdf = ob_get_contents();
         ob_clean();
         PrintPdfHelper::printTicket($pdf, $object);
     } else {
         JFactory::getApplication()->enqueueMessage(JText::_('COM_BOOKPRO_CAN_NO_FIND_ORDERS_FOR_PRINTING'));
         $this->setRedirect(JURI::base() . 'controller=order&task=ordersdetailmonth');
     }
 }