public function copyAction() { $this->_helper->viewRenderer->setNoRender(); $this->_helper->getHelper('layout')->disableLayout(); $request = $this->getRequest(); if ($request->isPost()) { $id = (int) $this->_getParam('id', 0); $position = new Processes_Model_DbTable_Processpos(); $data = $position->getPosition($id); $orderings = $this->getOrdering($data['processid']); foreach ($orderings as $ordering => $positionId) { if ($ordering > $data['ordering']) { $position->updatePosition($positionId, array('ordering' => $ordering + 1)); } } $data['ordering'] += 1; $data['created'] = $this->_date; $data['createdby'] = $this->_user['id']; $data['modified'] = '0000-00-00'; $data['modifiedby'] = 0; unset($data['id']); $position->addPosition($data); //Calculate //$this->_helper->Calculate($data['processid'], $this->_currency, $this->_date, $this->_user['id']); } }
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'); }
public function copyAction() { $this->_helper->viewRenderer->setNoRender(); $this->_helper->getHelper('layout')->disableLayout(); $id = $this->_getParam('id', 0); $processDb = new Processes_Model_DbTable_Process(); $process = $processDb->getProcess($id); $data = $process; unset($data['id'], $data['processid']); $data['title'] = $process['title'] . ' 2'; $data['state'] = 100; $data['completed'] = 0; $data['cancelled'] = 0; $data['contactperson'] = $this->_user['name']; $data['created'] = $this->_date; $data['createdby'] = $this->_user['id']; $data['modified'] = '0000-00-00'; $data['modifiedby'] = 0; $data['locked'] = 0; $data['lockedtime'] = 0; echo $newID = $processDb->addProcess($data); $positionsDb = new Processes_Model_DbTable_Processpos(); $positions = $positionsDb->fetchAll($positionsDb->select()->where('processid = ?', $id)->where('clientid = ?', $this->_user['clientid'])); foreach ($positions as $position) { $positionData = $position->toArray(); unset($positionData['id']); $positionData['processid'] = $newID; $positionData['created'] = $this->_date; $positionData['createdby'] = $this->_user['id']; $positionData['modified'] = '0000-00-00'; $positionData['modifiedby'] = 0; $positionsDb->addPosition($positionData); } $this->_flashMessenger->addMessage('MESSAGES_SUCCESFULLY_COPIED'); }