public function mapproveAction() { $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); //MISS:load history of modification $bhistories = new Pment_Models_BhistoryMapper(); $arrayBhistories = $bhistories->fetchAllBhistories($id,1); //MISS:load reviewers info $reviewers = new Pment_Models_ReviewerMapper(); $arrayReviewers = $reviewers->fetchAllNames($id); if($this->getRequest()->isPost()) { $redirect = true; $btClicked = $this->getRequest()->getPost('btSub'); $formData = $this->getRequest()->getPost(); $bhistory = new Pment_Models_Bhistory(); if($btClicked == "临时保存") { if($mplan->getStatus() == 3) { $mplan->setStatus(5); $bhistory->setEditType('材料计划首次审批'); } else { $bhistory->setEditType('材料计划继续审批'); } } else { $reviewers = new Pment_Models_ReviewerMapper(); //$messages = new Admin_Models_MessageMapper(); //$message = new Admin_Models_Message(); if($btClicked =="完成审批") { if($reviewers->checkAllValidated($id)) { $mplan->setStatus(6); //$message->setTitle(General_Models_Text::$text_mplan_mapprove_complete_message_title); //$message->setContent(General_Models_Text::$text_mplan_mapprove_complete_message_content); $bhistory->setEditType('材料计划审批完成'); } else { $errorMsg = General_Models_Text::$text_mplan_mapprove_validate_reviewer; $redirect = false; } } elseif($btClicked =="退回预算部重审") { $mplan->setStatus(4); $reviewers->resetAllReviewers($id); $bhistory->setEditType('材料计划退回重审'); // $message->setTitle(General_Models_Text::$text_mplan_mapprove_return_message_title); // $message->setContent(General_Models_Text::$text_mplan_mapprove_return_message_content); } if($redirect) { $users = new System_Models_UserMapper(); $approvfId = $users->getContactId($userId); $mplan->setApprovfId($approvfId); $mplan->setApprovfDate(date('Y-m-d,H:i')); //$message->setSendTime(date("Y-m-d,H:i")); //$message->setStatus(0); //$message->setFromId($this->getUserId()); //$mapprovcId = $users->getUserIdById($mplan->getApprovcId()); //$mcontactId = $users->getUserIdById($mplan->getContactId()); //$message->setToId($mcontactId); //$messages->sendByUserId($message); //$message->setToId($mapprovcId); //$messages->sendByUserId($message); } } if($redirect) { $mplan->setApprovfRemark($formData['approvfRemark']); $mplans->save($mplan); $bhistory->setPlanId($id); $bhistory->setStatus(1); $users = new System_Models_UserMapper(); $contactId = $users->getContactId($userId); $bhistory->setContactId($contactId); $bhistory->setEditDate(date('Y-m-d,H:i')); $bhistories->save($bhistory); $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'); } }