Exemplo n.º 1
0
 public function generateprocessAction()
 {
     $id = $this->_getParam('id', 0);
     $salesorderDb = new Sales_Model_DbTable_Salesorder();
     $salesorder = $salesorderDb->getSalesorder($id);
     $data = array();
     $form = new Processes_Form_Process();
     $elements = $form->getElements();
     foreach ($elements as $key => $value) {
         if (isset($salesorder[$key])) {
             $data[$key] = $salesorder[$key];
         }
     }
     $data['subtotal'] = $salesorder['subtotal'];
     $data['taxes'] = $salesorder['taxes'];
     $data['total'] = $salesorder['total'];
     $data['customerid'] = $salesorder['contactid'];
     $data['deliverystatus'] = 'deliveryIsWaiting';
     $data['supplierorderstatus'] = 'supplierNotOrdered';
     $data['paymentstatus'] = 'waitingForPayment';
     $data['state'] = 100;
     $data['completed'] = 0;
     $data['cancelled'] = 0;
     $data["created"] = $this->_date;
     $data["createdby"] = $this->_user['id'];
     $data["modified"] = "0000-00-00";
     $data["modifiedby"] = 0;
     unset($data["id"]);
     $process = new Processes_Model_DbTable_Process();
     $processID = $process->addProcess($data);
     $positions = $this->getPositions($id);
     $processposDb = new Processes_Model_DbTable_Processpos();
     foreach ($positions as $position) {
         $positionData = array();
         $positionForm = new Processes_Form_Processpos();
         $positionElements = $positionForm->getElements();
         foreach ($positionElements as $key => $value) {
             if (isset($position->{$key})) {
                 $positionData[$key] = $position->{$key};
             }
         }
         $positionData['processid'] = $processID;
         $positionData['taxrate'] = $position->taxrate;
         $positionData['deliverystatus'] = 'deliveryIsWaiting';
         $positionData['supplierorderstatus'] = 'supplierNotOrdered';
         $positionData["created"] = $this->_date;
         $positionData["createdby"] = $this->_user['id'];
         $positionData["modified"] = "0000-00-00";
         $positionData["modifiedby"] = 0;
         unset($positionData['id']);
         $processposDb->addPosition($positionData);
     }
     $this->_flashMessenger->addMessage('MESSAGES_PROCESS_SUCCESFULLY_GENERATED');
     $this->_helper->redirector->gotoSimple('index', 'process', 'processes');
 }
Exemplo n.º 2
0
 public function validateAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->getHelper('layout')->disableLayout();
     $form = new Processes_Form_Processpos();
     $form->uom->addMultiOptions($this->_helper->Uom->getUoms());
     $form->ordering->addMultiOptions($this->getOrdering($processid));
     $form->shippingmethod->addMultiOptions($this->_helper->ShippingMethod->getShippingMethods($this->_user['clientid']));
     $data = $this->getRequest()->getPost();
     $form->{$data}['element']->isValid($data[$data['element']]);
     $json = $form->getMessages();
     header('Content-type: application/json');
     echo Zend_Json::encode($json);
 }