Exemple #1
0
 public function indexAction()
 {
     $toolbar = new Statistics_Form_Toolbar();
     $options = $this->_helper->Options->getOptions($toolbar, $this->_user['clientid']);
     $params = $this->_helper->Params->getParams($toolbar, $options);
     $charts = new Statistics_Model_Charts();
     $charts->createCharts(13, 500, 300, $this->view->translate('STATISTICS_UNCATEGORIZED'), $params, $options);
     $quotesDb = new Sales_Model_DbTable_Quote();
     $quotes = $quotesDb->fetchAll($quotesDb->select()->where('quoteid = ?', 0)->order('id desc')->limit(5));
     $this->view->quotes = $quotes;
     $salesordersDb = new Sales_Model_DbTable_Salesorder();
     $salesorders = $salesordersDb->fetchAll($salesordersDb->select()->where('salesorderid = ?', 0)->order('id desc')->limit(5));
     $this->view->salesorders = $salesorders;
     $invoicesDb = new Sales_Model_DbTable_Invoice();
     $invoices = $invoicesDb->fetchAll($invoicesDb->select()->where('invoiceid = ?', 0)->order('id desc')->limit(5));
     $this->view->invoices = $invoices;
     $quoterequestsDb = new Purchases_Model_DbTable_Quoterequest();
     $quoterequests = $quoterequestsDb->fetchAll($quoterequestsDb->select()->where('quoterequestid = ?', 0)->order('id desc')->limit(5));
     $this->view->quoterequests = $quoterequests;
     $purchaseordersDb = new Purchases_Model_DbTable_Purchaseorder();
     $purchaseorders = $purchaseordersDb->fetchAll($purchaseordersDb->select()->where('purchaseorderid = ?', 0)->order('id desc')->limit(5));
     $this->view->purchaseorders = $purchaseorders;
     $this->view->options = $options;
     $this->view->toolbar = new Application_Form_Toolbar();
     $this->view->messages = $this->_flashMessenger->getMessages();
 }
Exemple #2
0
 /**
  * Récupère les messages
  *
  * @return array
  */
 private function getMessages()
 {
     // Messages
     $array_messages = $this->flashMessenger->getMessages();
     // Current Messages
     $array_currentMessages = $this->flashMessenger->getCurrentMessages();
     return $this->arrayUnique(array_merge($array_currentMessages, $array_messages));
 }
Exemple #3
0
 public function searchAction()
 {
     $this->_helper->viewRenderer->setRender('index');
     $this->_helper->getHelper('layout')->disableLayout();
     $lenght = $this->_getParam('lenght', 25);
     $toolbar = new Statistics_Form_Toolbar();
     $options = $this->_helper->Options->getOptions($toolbar, $this->_user['clientid']);
     $params = $this->_helper->Params->getParams($toolbar, $options);
     $chart = new Statistics_Model_Charts();
     $chart->createCharts($lenght, 1000, 400, $this->view->translate("STATISTICS_UNCATEGORIZED"), $params, $options);
     $this->view->lenght = $lenght;
     $this->view->options = $options;
     $this->view->toolbar = $toolbar;
     $this->view->messages = $this->_flashMessenger->getMessages();
 }
Exemple #4
0
 public function viewAction()
 {
     $id = $this->_getParam('id', 0);
     $processDb = new Processes_Model_DbTable_Process();
     $process = $processDb->getProcess($id);
     $process['processdate'] = date('d.m.Y', strtotime($process['processdate']));
     //Get positions
     $positionsDb = new Processes_Model_DbTable_Processpos();
     $positionsObject = $positionsDb->fetchAll($positionsDb->select()->where('processid = ?', $id)->order('ordering'));
     $positions = array();
     foreach ($positionsObject as $positionObject) {
         foreach ($positionObject as $key => $value) {
             $positions[$positionObject->id][$key] = $value;
         }
         $positions[$positionObject->id]['price'] = $this->_currency->toCurrency($positions[$positionObject->id]['price']);
         $positions[$positionObject->id]['quantity'] = Zend_Locale_Format::toNumber($positions[$positionObject->id]['quantity'], array('precision' => 2, 'locale' => Zend_Registry::get('Zend_Locale')));
     }
     //Get units of measurement
     $uomDb = new Application_Model_DbTable_Uom();
     $uom = $uomDb->fetchAll();
     $uoms = array();
     foreach ($uom as $value) {
         $uoms[$value->title] = $value->title;
     }
     $toolbar = new Processes_Form_Toolbar();
     $this->view->toolbar = $toolbar;
     $this->view->process = $process;
     $this->view->positions = $positions;
     $this->view->uoms = $uoms;
     $this->view->evaluate = $this->evaluate($positionsObject, $process['taxfree']);
     $this->view->messages = $this->_flashMessenger->getMessages();
 }
Exemple #5
0
 public function viewAction()
 {
     $id = $this->_getParam('id', 0);
     $locale = Zend_Registry::get('Zend_Locale');
     $invoiceDb = new Sales_Model_DbTable_Invoice();
     $invoice = $invoiceDb->getInvoice($id);
     $invoice['taxes'] = $this->_currency->toCurrency($invoice['taxes']);
     $invoice['subtotal'] = $this->_currency->toCurrency($invoice['subtotal']);
     $invoice['total'] = $this->_currency->toCurrency($invoice['total']);
     $positions = $this->getPositions($id);
     foreach ($positions as $position) {
         $position->description = str_replace("\n", '<br>', $position->description);
         $position->price = $this->_currency->toCurrency($position->price);
         $position->quantity = Zend_Locale_Format::toNumber($position->quantity, array('precision' => 2, 'locale' => $locale));
     }
     //E-Mail form
     $email = new Application_Form_Email();
     $files = array(0 => "/cache/invoice/" . $id . ".pdf");
     $toolbar = new Sales_Form_Toolbar();
     $this->view->toolbar = $toolbar;
     $this->view->files = $files;
     $this->view->invoice = $invoice;
     $this->view->positions = $positions;
     $this->view->email = $email;
     $this->view->messages = $this->_flashMessenger->getMessages();
 }
Exemple #6
0
 /**
  * View feed information
  * 
  * @return void
  */
 public function viewAction()
 {
     //get flash messages
     $this->view->messages = $this->_flashMessenger->getMessages();
     $id = $this->getRequest()->getParam('id');
     //get feedinfo
     $feeds = new Feeds();
     $this->view->feed = $feeds->getBySlug($id);
     if (!$this->view->feed) {
         throw new Zend_Exception('Feed doesn\'t exist');
     }
     $this->view->feed->views++;
     $this->view->feed->save();
     //get posts
     $limit = 5;
     $page = $this->getRequest()->getParam('page') ? $this->getRequest()->getParam('page') : 1;
     $posts = new Posts();
     $this->view->posts = $posts->getByFeedId($this->view->feed->id, $page, $limit);
     $total = $posts->getByFeedId($this->view->feed->id, $page, 0, true)->total;
     $this->view->paginator = Zend_Paginator::factory($total);
     $this->view->paginator->setCurrentPageNumber($page);
     $this->view->paginator->setItemCountPerPage($limit);
     $this->view->keywords = implode('', array('ifphp', 'news aggragator', 'support,' . $this->view->feed->title));
     $this->view->description = 'ifPHP, The PHP news Aggragator: ' . $this->view->feed->description;
 }
Exemple #7
0
 /**
  * Events after the controller dispatching
  */
 public function postDispatch()
 {
     $infoProfiler = '';
     //-------------------------
     $request = $this->getRequest();
     if ($this->_breadcrumbs) {
         $this->view->breadcrumbs = $this->_breadcrumbs;
         $this->view->title = $this->_breadcrumbs->getTitle();
     }
     //Передадим признак Ajax запроса
     $this->view->isAjaxRequest = $this->_isAjaxRequest;
     //Передадим сообщения в шаблоны
     $this->view->messages = $this->_flashMessenger->getMessages();
     // Запомним время выполения цикла диспетчеризации
     $params = $request->getParams();
     foreach ($params as $key => $value) {
         if (!is_string($value)) {
             continue;
         }
         if ($infoProfiler) {
             $infoProfiler .= "{$key} = {$value}<br>";
         } else {
             $infoProfiler .= $this->Translate("Время выполнения запроса") . ":<br />{$key} = {$value}<br />";
         }
     }
     $infoProfiler .= "<br />" . $this->Translate("Равно") . " = ";
     Default_Plugin_SysBox::profilerTime2Registry($this->_startTimeDispatch, $infoProfiler);
 }
Exemple #8
0
 public function init()
 {
     parent::init();
     // Messages
     $flashMessenger = new Zend_Controller_Action_Helper_FlashMessenger();
     $this->view->messages = $flashMessenger->getMessages();
     $flashMessenger->clearMessages();
 }
 /**
  * The default action - show the home page
  */
 public function indexAction()
 {
     $this->view->messages = $this->_flashMessenger->getMessages();
     $loginForm = new Zend_Form();
     $unField = new Zend_Form_Element_Text('un');
     $unField->setLabel('User Name');
     $pwField = new Zend_Form_Element_Password('pw');
     $pwField->setLabel('Password');
     $loginForm->addElement($unField);
     $loginForm->addElement($pwField);
     $loginForm->addDisplayGroup(array('un', 'pw'), 'authGroup')->getDisplayGroup('authGroup')->setLegend('Authentication');
     //view specific form additions
     //TODO: not sure if $_SERVER['HTTP_HOST'] is dependable enough to use in this case .. XSS vulnerability
     //TODO: programmatically determine http/https
     $loginForm->setAction('http://' . $_SERVER['HTTP_HOST'] . $this->getFrontController()->getBaseUrl() . $this->_helper->url('authenticate'));
     $loginForm->addElement('submit', 'login');
     $this->view->loginForm = $loginForm;
 }
 /**
  * getMessages() - Get messages from a specific namespace
  *
  * @param unknown_type $namespace
  * @return array
  */
 public function getMessages($type = null)
 {
     if ($type === null) {
         return parent::getMessages();
     }
     if (isset(self::$_messages[$this->_namespace][$type])) {
         return self::$_messages[$this->_namespace][$type];
     }
     return array();
 }
Exemple #11
0
 /**
  * Action - message
  * message display
  *
  * @return void
  */
 public function messageAction()
 {
     $params = $this->_getAllParams();
     if (isset($params['message'])) {
         $this->view->class_message = $params['class_message'];
         $this->view->message = $params['message'];
     }
     if ($this->_flashMessenger->hasMessages()) {
         $this->view->class_message = 'warning';
         $this->view->message = $this->_flashMessenger->getMessages();
     }
     //Добавим путь к действию
     $this->_breadcrumbs->addStep('Ошибка');
 }
Exemple #12
0
 /**
  * (non-PHPdoc)
  * @see Zend_Controller_Action::init()
  */
 public function init()
 {
     parent::init();
     // Load the module, controller and action names
     $this->view->module_name = $this->_moduleName = ucfirst($this->getRequest()->getModuleName());
     $this->view->controller_name = $this->_controllerName = ucfirst($this->getRequest()->getControllerName());
     $this->view->action_name = $this->_actionName = ucfirst($this->getRequest()->getActionName());
     // Load the translation name
     $this->view->translation_name = $this->_translationName = $this->_moduleName . $this->_controllerName . $this->_actionName;
     // Load the log
     $this->_log = $this->getInvokeArg('bootstrap')->log;
     // Load the flashmessenger
     $this->_flashMessenger = $this->_helper->getHelper('FlashMessenger');
     $this->view->messages = $this->_flashMessenger->getMessages();
     // Load the user
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $this->_user = $auth->getIdentity();
         if ($this->_user->isConnected()) {
             $this->_user->connect();
         }
     }
 }
Exemple #13
0
 public function editAction()
 {
     header('Content-type: application/json');
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->getHelper('layout')->disableLayout();
     $request = $this->getRequest();
     $id = $this->_getParam('id', 0);
     $activeTab = $request->getCookie('tab', null);
     $categoryDb = new Admin_Model_DbTable_Category();
     $category = $categoryDb->getCategory($id);
     if ($this->isLocked($category['locked'], $category['lockedtime'])) {
         if ($request->isPost()) {
             header('Content-type: application/json');
             $this->_helper->viewRenderer->setNoRender();
             $this->_helper->getHelper('layout')->disableLayout();
             echo Zend_Json::encode(array('message' => $this->view->translate('MESSAGES_LOCKED')));
         } else {
             $this->_flashMessenger->addMessage('MESSAGES_LOCKED');
             $this->_helper->redirector('index');
         }
     } else {
         $categoryDb->lock($id, $this->_user['id'], $this->_date);
         $form = new Admin_Form_Category();
         $options = $this->_helper->Options->getOptions($form);
         $params = $this->_helper->Params->getParams($form, $options);
         $categories = $this->_helper->Categories->getCategories($form, $params['clientid'], $params['type']);
         if ($request->isPost()) {
             $data = $request->getPost();
             $element = key($data);
             if (isset($form->{$element}) && $form->isValidPartial($data)) {
                 $data['modified'] = $this->_date;
                 $data['modifiedby'] = $this->_user['id'];
                 $categoryDb = new Admin_Model_DbTable_Category();
                 $categoryDb->updateCategory($id, $data);
                 echo Zend_Json::encode($categoryDb->getCategory($id));
             } else {
                 echo Zend_Json::encode(array('message' => $this->view->translate('MESSAGES_FORM_IS_INVALID')));
             }
         }
     }
     $this->view->messages = $this->_flashMessenger->getMessages();
 }
 public function viewAction()
 {
     $id = $this->_getParam('id', 0);
     $locale = Zend_Registry::get('Zend_Locale');
     $deliveryorderDb = new Sales_Model_DbTable_Deliveryorder();
     $deliveryorder = $deliveryorderDb->getDeliveryorder($id);
     $deliveryorder['taxes'] = $this->_currency->toCurrency($deliveryorder['taxes']);
     $deliveryorder['subtotal'] = $this->_currency->toCurrency($deliveryorder['subtotal']);
     $deliveryorder['total'] = $this->_currency->toCurrency($deliveryorder['total']);
     $positions = $this->getPositions($id);
     foreach ($positions as $position) {
         $position->description = str_replace("\n", '<br>', $position->description);
         $position->price = $this->_currency->toCurrency($position->price);
         $position->quantity = Zend_Locale_Format::toNumber($position->quantity, array('precision' => 2, 'locale' => $locale));
     }
     $toolbar = new Sales_Form_Toolbar();
     $this->view->toolbar = $toolbar;
     $this->view->deliveryorder = $deliveryorder;
     $this->view->positions = $positions;
     $this->view->messages = $this->_flashMessenger->getMessages();
 }
Exemple #15
0
 /**
  * Return immediate messages merged with session messages
  *
  * @return array
  */
 public function getMessages()
 {
     return array_merge(parent::getMessages(), $this->_immediateMessages);
 }
Exemple #16
0
 public function editAction()
 {
     $request = $this->getRequest();
     $id = $this->_getParam('id', 0);
     $activeTab = $request->getCookie('tab', null);
     $itemDb = new Items_Model_DbTable_Item();
     $item = $itemDb->getItem($id);
     if (false) {
         $this->_helper->redirector->gotoSimple('view', 'item', null, array('id' => $id));
     } elseif ($this->isLocked($item['locked'], $item['lockedtime'])) {
         if ($request->isPost()) {
             header('Content-type: application/json');
             $this->_helper->viewRenderer->setNoRender();
             $this->_helper->getHelper('layout')->disableLayout();
             echo Zend_Json::encode(array('message' => $this->view->translate('MESSAGES_LOCKED')));
         } else {
             $this->_flashMessenger->addMessage('MESSAGES_LOCKED');
             $this->_helper->redirector('index');
         }
     } else {
         $itemDb->lock($id, $this->_user['id'], $this->_date);
         $form = new Items_Form_Item();
         $options = $this->_helper->Options->getOptions($form, $this->_user['clientid']);
         if ($request->isPost()) {
             $this->_helper->viewRenderer->setNoRender();
             $this->_helper->getHelper('layout')->disableLayout();
             $data = $request->getPost();
             $element = key($data);
             if (isset($form->{$element}) && $form->isValidPartial($data)) {
                 $data['modified'] = $this->_date;
                 $data['modifiedby'] = $this->_user['id'];
                 if (array_key_exists('price', $data)) {
                     $locale = Zend_Registry::get('Zend_Locale');
                     $data['price'] = Zend_Locale_Format::getNumber($data['price'], array('precision' => 2, 'locale' => $locale));
                 }
                 if (array_key_exists('quantity', $data)) {
                     $locale = Zend_Registry::get('Zend_Locale');
                     $data['quantity'] = Zend_Locale_Format::getNumber($data['quantity'], array('precision' => 2, 'locale' => $locale));
                 }
                 if (array_key_exists('margin', $data)) {
                     $locale = Zend_Registry::get('Zend_Locale');
                     $data['margin'] = Zend_Locale_Format::getNumber($data['margin'], array('precision' => 2, 'locale' => $locale));
                 }
                 if (array_key_exists('weight', $data)) {
                     $locale = Zend_Registry::get('Zend_Locale');
                     $data['weight'] = Zend_Locale_Format::getNumber($data['weight'], array('precision' => 4, 'locale' => $locale));
                 }
                 $item = new Items_Model_DbTable_Item();
                 $item->updateItem($id, $data);
             } else {
                 throw new Exception('Form is invalid');
             }
         } else {
             if ($id > 0) {
                 $item['cost'] = $this->_currency->toCurrency($item['cost']);
                 $item['price'] = $this->_currency->toCurrency($item['price']);
                 $item['margin'] = $this->_currency->toCurrency($item['margin']);
                 $locale = Zend_Registry::get('Zend_Locale');
                 $item['weight'] = $this->_currency->toCurrency($item['weight'], array('precision' => 4, 'locale' => $locale));
                 $form->populate($item);
                 //Toolbar
                 $toolbar = new Items_Form_Toolbar();
                 $this->view->form = $form;
                 $this->view->activeTab = $activeTab;
                 $this->view->toolbar = $toolbar;
             }
         }
     }
     $this->view->messages = $this->_flashMessenger->getMessages();
 }
Exemple #17
0
 public function preDispatch()
 {
     $this->view->messages = $this->_flash->getMessages();
     $this->view->identity = Zend_Auth::getInstance()->getIdentity();
 }
 public function indexAction()
 {
     $this->view->contacts = $this->mapper->findAll();
     $this->view->flashMessages = $this->_flashMessenger->getMessages();
 }
Exemple #19
0
 public function init()
 {
     $this->_flashMessenger = $this->_helper->getHelper('FlashMessenger');
     $this->initView();
     $this->view->messages = $this->_flashMessenger->getMessages();
 }
Exemple #20
0
 public function editAction()
 {
     $request = $this->getRequest();
     $id = $this->_getParam('id', 0);
     $activeTab = $request->getCookie('tab', null);
     $contactDb = new Contacts_Model_DbTable_Contact();
     $contact = $contactDb->getContact($id);
     if (false) {
         $this->_helper->redirector->gotoSimple('view', 'contact', null, array('id' => $id));
     } elseif ($this->isLocked($contact['locked'], $contact['lockedtime'])) {
         if ($request->isPost()) {
             header('Content-type: application/json');
             $this->_helper->viewRenderer->setNoRender();
             $this->_helper->getHelper('layout')->disableLayout();
             echo Zend_Json::encode(array('message' => $this->view->translate('MESSAGES_LOCKED')));
         } else {
             $this->_flashMessenger->addMessage('MESSAGES_LOCKED');
             $this->_helper->redirector('index');
         }
     } else {
         $contactDb->lock($id, $this->_user['id'], $this->_date);
         $form = new Contacts_Form_Contact();
         $options = $this->_helper->Options->getOptions($form, $this->_user['clientid']);
         if ($request->isPost()) {
             $this->_helper->viewRenderer->setNoRender();
             $this->_helper->getHelper('layout')->disableLayout();
             $data = $request->getPost();
             $element = key($data);
             if ($element == 'contactinfo') {
                 $data['info'] = $data['contactinfo'];
                 unset($data['contactinfo']);
                 $element = 'info';
             }
             if ($element == 'customerinfo') {
                 $data['info'] = $data['customerinfo'];
                 unset($data['customerinfo']);
                 $element = 'info';
             }
             if (isset($form->{$element}) && $form->isValidPartial($data)) {
                 $data['modified'] = $this->_date;
                 $data['modifiedby'] = $this->_user['id'];
                 $contactDb = new Contacts_Model_DbTable_Contact();
                 $contactDb->updateContact($id, $data);
             } else {
                 throw new Exception('Form is invalid');
             }
         } else {
             if ($id > 0) {
                 $data = $contact;
                 $form->populate($data);
                 //Phone
                 $phoneDb = new Contacts_Model_DbTable_Phone();
                 $phone = $phoneDb->getPhone($id);
                 //Email
                 $emailDb = new Contacts_Model_DbTable_Email();
                 $email = $emailDb->getEmail($id);
                 //Internet
                 $internetDb = new Contacts_Model_DbTable_Internet();
                 $internet = $internetDb->getInternet($id);
                 $addressDb = new Application_Model_DbTable_Address();
                 //Primary Address
                 $primaryAddress = $addressDb->fetchRow($addressDb->select()->where('contactid = ?', $id)->where('type = ?', 'primaryAddress')->where('clientid = ?', $this->_user['clientid']));
                 $formPrimaryAddress = new Contacts_Form_Address();
                 $formPrimaryAddress->country->addMultiOptions($options['countries']);
                 $formPrimaryAddress->populate($primaryAddress->toArray());
                 foreach ($formPrimaryAddress as $element) {
                     $element->setAttrib('data-id', $primaryAddress['id']);
                     $element->setAttrib('data-controller', 'address');
                 }
                 //Shipping address
                 $shippingAddress = $addressDb->fetchRow($addressDb->select()->where('contactid = ?', $id)->where('type = ?', 'shippingAddress')->where('clientid = ?', $this->_user['clientid']));
                 $formShippingAddress = new Contacts_Form_Address();
                 $formShippingAddress->populate($shippingAddress->toArray());
                 foreach ($formShippingAddress as $element) {
                     $element->setAttrib('data-id', $shippingAddress['id']);
                     $element->setAttrib('data-controller', 'address');
                 }
                 $formShippingAddress->country->addMultiOptions($options['countries']);
                 //History
                 $history = $this->getHistory($id);
                 //Files
                 $files = array();
                 //Create contact folder if does not already exists
                 if (!file_exists(BASE_PATH . '/files/contacts/' . $id . '/')) {
                     mkdir(BASE_PATH . '/files/contacts/' . $id . '/');
                     chmod(BASE_PATH . '/files/contacts/' . $id . '/', 0777);
                 }
                 if ($handle = opendir(BASE_PATH . '/files/contacts/' . $id . '/')) {
                     $files['contactSpecific'] = array();
                     while (false !== ($entry = readdir($handle))) {
                         if (substr($entry, 0, strlen('.')) !== '.') {
                             array_push($files['contactSpecific'], $entry);
                         }
                     }
                     closedir($handle);
                 }
                 //Toolbar
                 $toolbar = new Contacts_Form_Toolbar();
                 $this->view->form = $form;
                 $this->view->formPrimaryAddress = $formPrimaryAddress;
                 $this->view->formShippingAddress = $formShippingAddress;
                 $this->view->history = $history;
                 $this->view->files = $files;
                 $this->view->phone = $phone;
                 $this->view->email = $email;
                 $this->view->internet = $internet;
                 $this->view->activeTab = $activeTab;
                 $this->view->toolbar = $toolbar;
             }
         }
         //Create contact folder if does not already exists
         if (!file_exists(BASE_PATH . '/files/contacts/' . $id . '/')) {
             mkdir(BASE_PATH . '/files/contacts/' . $id . '/');
             chmod(BASE_PATH . '/files/contacts/' . $id . '/', 0777);
         }
     }
     $this->view->messages = $this->_flashMessenger->getMessages();
 }