/**
  * Setting the toolbar
  */
 protected function addToolBar()
 {
     JRequest::setVar('hidemainmenu', true);
     $user = JFactory::getUser();
     $userId = $user->get('id');
     $canDo = MaintHelper::getActions();
     $isNew = false == isset($this->order) || $this->order->id == 0;
     $this->canDeliver = $canDo->get('core.deliver');
     JToolBarHelper::title($isNew ? JText::_('COM_MAINT_ADD_APPLICATION') : JText::_('COM_MAINT_EDIT_APPLICATION'));
     if ($isNew) {
         // For new records, check the create permission.
         if ($canDo->get('core.create')) {
             JToolBarHelper::apply('maint.apply', 'JTOOLBAR_APPLY');
             JToolBarHelper::save('maint.save', 'JTOOLBAR_SAVE');
             JToolBarHelper::save2new('maint.save2new');
         }
     } else {
         if ($canDo->get('core.edit')) {
             JToolBarHelper::apply('maint.apply', 'JTOOLBAR_APPLY');
             JToolBarHelper::save('maint.save', 'JTOOLBAR_SAVE');
             // if we can return to make a new one.
             if ($canDo->get('core.create')) {
                 JToolBarHelper::save2new('maint.save2new');
             }
         }
         $bar = JToolBar::getInstance('toolbar');
         $bar->addButtonPath(JPATH_COMPONENT . '/button/');
         $bar->appendButton('Print', 'COM_MAINT_PRINT', 'index.php?option=com_maint&task=maints.pprint&id=' . $this->order->id);
     }
     JToolBarHelper::cancel('maint.cancel', 'JTOOLBAR_CANCEL');
 }
Example #2
0
 private function mergeOrderData($data, $orderObj, $clientObj)
 {
     $user = JFactory::getUser();
     $userId = $user->get('id');
     $canDo = MaintHelper::getActions(0);
     $canDeliver = $canDo->get('core.deliver');
     $order = array();
     $currentLoggedUser =& JFactory::getUser();
     $orderObj->load($data['id']);
     $leftMoney = $data['total_money'] - ($data['paied_money'] + $data['discount_money']);
     $order = array('device_type' => $data['device_type'], 'device_desc' => $data['device_desc'], 'device_accessories' => $data['device_accessories'], 'work_required' => $data['work_required'], 'entered_at' => $data['entered_at'], 'work_done' => $data['work_done'], 'total_money' => $data['total_money'], 'discount_money' => $data['discount_money'], 'paied_money' => $data['paied_money'], 'left_money' => $leftMoney, 'fixed_at' => $data['fixed_at'], 'delivered_at' => $data['delivered_at'], 'client_id' => $clientObj->id, 'extra_parts_notes' => $data['extra_parts_notes'], 'extra_parts_notes_paied' => $data['extra_parts_notes_paied']);
     if (!$orderObj->workers_recipient_id) {
         $order['workers_recipient_id'] = $currentLoggedUser->id;
     }
     if (strtotime($data['fixed_at']) > 0) {
         $order['fixed'] = 1;
         $order['workers_fixer_id'] = "{$currentLoggedUser->id}";
     } else {
         $order['fixed'] = 0;
     }
     $netMoney = 0;
     //calculate money paied
     if ($orderObj->paied_money) {
         $netMoney = $order['paied_money'] - $orderObj->paied_money;
     } else {
         $netMoney = $order['paied_money'];
     }
     if ($netMoney != 0) {
         // update worker holding money.
         $this->addMoneyToWorker($netMoney, $order);
     }
     $orderObj->bind($order);
     return $orderObj;
 }
 /**
  * Method to set up the document properties
  *
  * @return void
  */
 protected function setDocument()
 {
     $canDo = MaintHelper::getActions();
     $document = JFactory::getDocument();
     $document->setTitle(JText::_('COM_MAINT'));
     JToolBarHelper::title(JText::_('COM_MAINT'));
     $document->addStyleSheet(JURI::base(true) . '/components/com_maint/assets/css/admin.css');
     JToolBarHelper::back('JTOOLBAR_BACK', 'index.php?option=com_maint');
     $bar = JToolBar::getInstance('toolbar');
     $bar->addButtonPath(JPATH_COMPONENT . '/button/');
     $bar->appendButton('Print', 'COM_MAINT_PRINT', 'index.php?option=com_maint&task=maints.pprint&id=' . $this->id);
     if ($canDo->get('core.edit')) {
         JToolBarHelper::editList('maint.edit');
     }
 }
 /**
  * Setting the toolbar
  */
 protected function addToolBar()
 {
     $canDo = MaintHelper::getActions();
     $bar = JToolBar::getInstance('toolbar');
     JToolBarHelper::title(JText::_('COM_MAINT'));
     $toolbar = JToolBar::getInstance('toolbar');
     JToolBarHelper::custom('maints.reports', 'icon-32-xml.png', '', 'COM_MAINT_MENU_REPORTS', false, false);
     JToolBarHelper::customX('maints.show', 'preview', '', 'COM_MAINT_MENU_PREVIEW');
     if ($canDo->get('core.delete')) {
         JToolBarHelper::deleteListX('', 'maints.delete');
     }
     if ($canDo->get('core.edit')) {
         JToolBarHelper::editListX('maint.edit');
     }
     if ($canDo->get('core.create')) {
         JToolBarHelper::addNewX('maint.add');
     }
     if ($canDo->get('core.admin')) {
         JToolBarHelper::divider();
         JToolBarHelper::custom('maints.money', 'money.png', '', 'COM_MAINT_MONEY', false, false);
         JToolBarHelper::preferences('com_maint');
     }
 }