public function indexAction() { $userId = $this->getUserId(); $planId = $this->_getParam('planId',0); $errorMsg = null; if($planId > 0) { $mplans = new Pment_Models_MplanMapper(); $mplan = new Pment_Models_Mplan(); $mplans->find($planId,$mplan); $reviewers = new Pment_Models_ReviewerMapper(); $arrayIds = $reviewers->fetchAllIds($planId); $trueUser = false; foreach($arrayIds as $id) { if($id == $userId) { $trueUser = true; } } if($trueUser) { $materials = new Pment_Models_MaterialMapper(); $condition = "planId"; $arrayMaterials = $materials->fetchAllOrganize($planId,$condition); if($this->getRequest()->isPost()) { $users = new System_Models_UserMapper(); $formData = $this->getRequest()->getPost(); $password = $formData['tbPassword']; if($users->checkPassword($password,$userId)) { $reviewer = $reviewers->findReviewer($planId,$userId); $reviewer->setStatus(1); $reviewer->setAddDate(date('Y-m-d,H:i')); $reviewers->save($reviewer); $message = General_Models_Text::$text_mplan_validation_sucess; $this->_helper->flashMessenger->addMessage($message); $this->_redirect('/'); } else { $errorMsg = General_Models_Text::$text_mplan_validation_wrong_password; } } $this->view->errorMsg = $errorMsg; $this->view->arrayMaterials = $arrayMaterials; $this->view->mplan = $mplan; } else { $this->_redirect('/pment/mplan'); } } else { $this->_redirect('/pment/mplan'); } }
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 ajaxfindAction() { $this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $mtrId = $this->_getParam('mtrId',0); if($mtrId > 0) { $materials = new Pment_Models_MaterialMapper(); $arrayMaterial = $materials->findMaterial($mtrId); $json = Zend_Json::encode($arrayMaterial); echo $json; } else { $this->_redirect('/pment/mplan'); } }