public function mfinalAction() { $userId = $this->getUserId(); $groupId = $this->getGroupId(); if($groupId != 5) { $this->_redirect('/pment/mplan'); } $id = $this->_getParam('id',0); if($id > 0) { //display plan info $mplans = new Pment_Models_MplanMapper(); $mplan = new Pment_Models_Mplan(); $errorMsg = null; $mplans->find($id,$mplan); $materials = new Pment_Models_MaterialMapper(); $condition = "planId"; $arrayMaterials = $materials->fetchAllOrganize($id,$condition); //load history of modification $bhistories = new Pment_Models_BhistoryMapper(); $arrayBhistories = $bhistories->fetchAllBhistories($id,1); //load reviewers info $reviewers = new Pment_Models_ReviewerMapper(); $arrayReviewers = $reviewers->fetchAllNames($id); if($this->getRequest()->isPost()) { $redirect = true; $formData = $this->getRequest()->getPost(); $array = $materials->mfinalValidator($formData); $trigger = $array['trigger']; $errorMsg = $array['errorMsg']; if($trigger == 0) { $arrayMtrIds = $materials->fetchArryMtrIds($id); foreach($arrayMtrIds as $mtrId) { $material = new Pment_Models_Material(); $materials->find($mtrId,$material); $material->setVendorName($formData['vendorName_'.$mtrId]); $material->setAmountf($formData['amountf_'.$mtrId]); $material->setCost($formData['cost_'.$mtrId]); $material->setCostTotal($formData['costTotal_'.$mtrId]); $materials->save($material); } $bhistory = new Pment_Models_Bhistory(); $bhistory->setPlanId($id); $bhistory->setStatus(1); $userId = $this->getUserId(); $users = new System_Models_UserMapper(); $contactId = $users->getContactId($userId); $bhistory->setContactId($contactId); $bhistory->setEditDate(date('Y-m-d,H:i')); $bhistory->setEditType('添加采购信息'); $bhistories->save($bhistory); $message = General_Models_Text::$text_mplan_mfinal_sucess; $this->_helper->flashMessenger->addMessage($message); $this->_redirect('/pment/mplan/mindex'); } } $this->view->errorMsg = $errorMsg; $this->view->mplan = $mplan; $this->view->arrayReviewers = $arrayReviewers; $this->view->id = $id; $this->view->modelName = "材料部材料计划信息"; $this->view->arrayBhistories = $arrayBhistories; //display material info $this->view->arrayMaterials = $arrayMaterials; } else { $this->_redirect('/pment/mplan'); } }
public function ajaxaddAction() { $this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $materials = new Pment_Models_MaterialMapper(); $material = new Pment_Models_Material(); $material->setPlanId($this->_getParam('planId')); $material->setType($this->_getParam('type')); $material->setMName($this->_getParam('mName')); $material->setSpec($this->_getParam('spec')); $material->setUnit($this->_getParam('unit')); $material->setAmount(0); $material->setAmountc($this->_getParam('amountc')); $material->setBudget($this->_getParam('budget')); $material->setBudgetTotal($this->_getParam('budgetTotal')); $material->setInDate($this->_getParam('inDate')); $material->setRemark($this->_getParam('remark')); $material->setAmountf($this->_getParam('amountf')); $material->setCost($this->_getParam('cost')); $material->setCostTotal($this->_getParam('costTotal')); $material->setVendorName($this->_getParam('vendorName')); $id = $materials->save($material); echo $id; }