Пример #1
0
 public function deleteAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->getHelper('layout')->disableLayout();
     if ($this->getRequest()->isPost()) {
         $id = $this->_getParam('id', 0);
         $internetDb = new Contacts_Model_DbTable_Internet();
         $internetDb->deleteInternet($id);
     }
     //$this->_flashMessenger->addMessage('MESSAGES_SUCCESFULLY_DELETED');
 }
Пример #2
0
 public function editAction()
 {
     $request = $this->getRequest();
     $id = $this->_getParam('id', 0);
     $activeTab = $request->getCookie('tab', null);
     $quoteDb = new Sales_Model_DbTable_Quote();
     $quote = $quoteDb->getQuote($id);
     if ($quote['quoteid']) {
         $this->_helper->redirector->gotoSimple('view', 'quote', null, array('id' => $id));
     } elseif ($this->isLocked($quote['locked'], $quote['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 {
         $quoteDb->lock($id, $this->_user['id'], $this->_date);
         $form = new Sales_Form_Quote();
         $options = $this->_helper->Options->getOptions($form, $this->_user['clientid']);
         //Get contact
         if ($quote['contactid']) {
             $contactDb = new Contacts_Model_DbTable_Contact();
             $contact = $contactDb->getContact($quote['contactid']);
             //Phone
             $phoneDb = new Contacts_Model_DbTable_Phone();
             $contact['phone'] = $phoneDb->getPhone($quote['contactid']);
             //Email
             $emailDb = new Contacts_Model_DbTable_Email();
             $contact['email'] = $emailDb->getEmail($quote['contactid']);
             //Internet
             $internetDb = new Contacts_Model_DbTable_Internet();
             $contact['internet'] = $internetDb->getInternet($quote['contactid']);
             $this->view->contact = $contact;
         }
         if ($request->isPost()) {
             header('Content-type: application/json');
             $this->_helper->viewRenderer->setNoRender();
             $this->_helper->getHelper('layout')->disableLayout();
             $data = $request->getPost();
             $element = key($data);
             if (isset($form->{$element}) && $form->isValidPartial($data)) {
                 $data['contactperson'] = $this->_user['name'];
                 $data['modified'] = $this->_date;
                 $data['modifiedby'] = $this->_user['id'];
                 if (isset($data['taxfree'])) {
                     $calculations = $this->_helper->Calculate($id, $this->_currency, $this->_date, $this->_user['id'], $data['taxfree']);
                     $data['subtotal'] = $calculations['subtotal'];
                     $data['taxes'] = $calculations['taxes'];
                     $data['total'] = $calculations['total'];
                 }
                 $quoteDb->updateQuote($id, $data);
                 echo Zend_Json::encode($quoteDb->getQuote($id));
             } else {
                 echo Zend_Json::encode(array('message' => $this->view->translate('MESSAGES_FORM_IS_INVALID')));
             }
         } else {
             if ($id > 0) {
                 $data = $quote;
                 if ($quote['contactid']) {
                     $data['contactinfo'] = $contact['info'];
                     $form->contactinfo->setAttrib('data-id', $contact['id']);
                     $form->contactinfo->setAttrib('data-controller', 'contact');
                     $form->contactinfo->setAttrib('data-module', 'contacts');
                     $form->contactinfo->setAttrib('readonly', null);
                 }
                 $form->populate($data);
                 //Toolbar
                 $toolbar = new Sales_Form_Toolbar();
                 $toolbar->state->setValue($data['state']);
                 $toolbarPositions = new Sales_Form_ToolbarPositions();
                 $this->view->form = $form;
                 $this->view->activeTab = $activeTab;
                 $this->view->toolbar = $toolbar;
                 $this->view->toolbarPositions = $toolbarPositions;
                 $this->view->textblocks = $this->getTextblocks();
             }
         }
     }
     $this->view->messages = $this->_flashMessenger->getMessages();
 }
Пример #3
0
 public function deleteAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->getHelper('layout')->disableLayout();
     if ($this->getRequest()->isPost()) {
         $id = $this->_getParam('id', 0);
         $contactDb = new Contacts_Model_DbTable_Contact();
         $contactDb->deleteContact($id);
         $phoneDb = new Contacts_Model_DbTable_Phone();
         $phones = $phoneDb->getPhone($id);
         foreach ($phones as $phone) {
             $phoneDb->deletePhone($phone['id']);
         }
         $emailDb = new Contacts_Model_DbTable_Email();
         $emails = $emailDb->getEmail($id);
         foreach ($emails as $email) {
             $emailDb->deleteEmail($email['id']);
         }
         $internetDb = new Contacts_Model_DbTable_Internet();
         $internets = $internetDb->getInternet($id);
         foreach ($internets as $internet) {
             $internetDb->deleteInternet($internet['id']);
         }
     }
     $this->_flashMessenger->addMessage('MESSAGES_SUCCESFULLY_DELETED');
 }
Пример #4
0
 public function editAction()
 {
     $request = $this->getRequest();
     $id = $this->_getParam('id', 0);
     //		$element = $this->_getParam('element', null);
     $activeTab = $request->getCookie('tab', null);
     $processDb = new Processes_Model_DbTable_Process();
     $process = $processDb->getProcess($id);
     if ($process['completed'] || $process['cancelled']) {
         $this->_helper->redirector->gotoSimple('view', 'process', null, array('id' => $id));
     } elseif ($this->isLocked($process['locked'], $process['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 {
         $processDb->lock($id, $this->_user['id'], $this->_date);
         $form = new Processes_Form_Process();
         $options = $this->_helper->Options->getOptions($form, $this->_user['clientid']);
         //Get contact
         if ($process['customerid']) {
             $contactDb = new Contacts_Model_DbTable_Contact();
             $contact = $contactDb->getContact($process['customerid']);
             //Phone
             $phoneDb = new Contacts_Model_DbTable_Phone();
             $contact['phone'] = $phoneDb->getPhone($process['customerid']);
             //Email
             $emailDb = new Contacts_Model_DbTable_Email();
             $contact['email'] = $emailDb->getEmail($process['customerid']);
             //Internet
             $internetDb = new Contacts_Model_DbTable_Internet();
             $contact['internet'] = $internetDb->getInternet($process['customerid']);
             $this->view->contact = $contact;
         }
         if ($request->isPost()) {
             header('Content-type: application/json');
             $this->_helper->viewRenderer->setNoRender();
             $this->_helper->getHelper('layout')->disableLayout();
             $data = $request->getPost();
             $element = key($data);
             if (isset($form->{$element}) && $form->isValidPartial($data)) {
                 $data['contactperson'] = $this->_user['name'];
                 $data['modified'] = $this->_date;
                 $data['modifiedby'] = $this->_user['id'];
                 if (isset($data['taxfree'])) {
                     $calculations = $this->_helper->Calculate($id, $this->_currency, $this->_date, $this->_user['id'], $data['taxfree']);
                     $data['subtotal'] = $calculations['subtotal'];
                     $data['taxes'] = $calculations['taxes'];
                     $data['total'] = $calculations['total'];
                 }
                 if (isset($data['total'])) {
                     $data['total'] = Zend_Locale_Format::getNumber($data['total'], array('precision' => 2, 'locale' => $locale));
                 }
                 if (isset($data['supplierinvoicetotal'])) {
                     $data['supplierinvoicetotal'] = Zend_Locale_Format::getNumber($data['supplierinvoicetotal'], array('precision' => 2, 'locale' => $locale));
                 }
                 if (isset($data['prepaymenttotal'])) {
                     $data['prepaymenttotal'] = Zend_Locale_Format::getNumber($data['prepaymenttotal'], array('precision' => 2, 'locale' => $locale));
                 }
                 $processDb->updateProcess($id, $data);
                 echo Zend_Json::encode($processDb->getProcess($id));
             } else {
                 echo Zend_Json::encode(array('message' => $this->view->translate('MESSAGES_FORM_IS_INVALID')));
             }
         } else {
             if ($id > 0) {
                 $data = $process;
                 if ($process['customerid']) {
                     $data['customerinfo'] = $contact['info'];
                     $form->customerinfo->setAttrib('data-id', $contact['id']);
                     $form->customerinfo->setAttrib('data-controller', 'contact');
                     $form->customerinfo->setAttrib('data-module', 'contacts');
                     $form->customerinfo->setAttrib('readonly', null);
                 }
                 $data['total'] = $this->_currency->toCurrency($data['total']);
                 $data['prepaymenttotal'] = $this->_currency->toCurrency($data['prepaymenttotal']);
                 $data['creditnotetotal'] = $this->_currency->toCurrency($data['creditnotetotal']);
                 if ($process['editpositionsseparately']) {
                     $form->deliverystatus->setAttrib('disabled', 'disabled');
                     $form->shippingmethod->setAttrib('disabled', 'disabled');
                     $form->deliverydate->setAttrib('disabled', 'disabled');
                     $form->shipmentdate->setAttrib('disabled', 'disabled');
                     $form->shipmentnumber->setAttrib('disabled', 'disabled');
                     $form->deliveryorderid->setAttrib('disabled', 'disabled');
                     $form->deliveryorderdate->setAttrib('disabled', 'disabled');
                     $form->supplierid->setAttrib('disabled', 'disabled');
                     $form->purchaseorderid->setAttrib('disabled', 'disabled');
                     $form->suppliersalesorderid->setAttrib('disabled', 'disabled');
                     $form->supplierinvoiceid->setAttrib('disabled', 'disabled');
                     $form->supplierinvoicetotal->setAttrib('disabled', 'disabled');
                     $form->supplierorderstatus->setAttrib('disabled', 'disabled');
                     $form->suppliername->setAttrib('disabled', 'disabled');
                     $form->purchaseorderdate->setAttrib('disabled', 'disabled');
                     $form->suppliersalesorderdate->setAttrib('disabled', 'disabled');
                     $form->supplierinvoicedate->setAttrib('disabled', 'disabled');
                     $form->supplierpaymentdate->setAttrib('disabled', 'disabled');
                 }
                 $form->populate($data);
                 //Toolbar
                 $toolbar = new Processes_Form_Toolbar();
                 $toolbar->state->setValue($data['state']);
                 $toolbarPositions = new Processes_Form_ToolbarPositions();
                 $this->view->form = $form;
                 $this->view->activeTab = $activeTab;
                 $this->view->toolbar = $toolbar;
                 $this->view->toolbarPositions = $toolbarPositions;
             }
         }
     }
     $this->view->messages = $this->_flashMessenger->getMessages();
 }