/** * cancel Mission */ public function executeCancelMissionLeg(sfWebRequest $request) { #Security if (!$this->getUser()->hasCredential(array('Administrator'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer()); $this->redirect('dashboard/index'); } //$request->checkCSRFProtection(); $this->forward404Unless($mission_leg = MissionLegPeer::retrieveByPk($request->getParameter('id')), sprintf('Object itinerary does not exist (%s).', $request->getParameter('id'))); $mission_leg = MissionLegPeer::retrieveByPk($request->getParameter('id')); if (isset($mission_leg)) { $mission_leg->setCancelMissionLeg(0); $mission_leg->save(); $emails_array = retrieveEmailAddressesRelatedToItinerary::getEmailAddressesOfPersonsRelatedToMissionLeg($mission_leg); if (preg_match('/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})$/', $emails_array)) { $receivers[] = $emails_array; } //mail $text = 'Mission Leg ' . $mission_leg->getMissionId() . ' - ' . $mission_leg->getLegNumber() . ' has been cancelled. Regards, Angel Flight West'; $this->getComponent('mail', 'itinerary_Mission_MissionLegCancel', array('email' => array_unique($receivers), 'subject' => 'Angel Flight West Mission Leg cancel information', 'text' => $text)); } $this->getUser()->setFlash('success', 'The mission leg ' . $mission_leg->getMissionId() . ' - ' . $mission_leg->getLegNumber() . ' has been cancelled successfully.'); $this->redirect('missionLeg/index'); }
/** * cancel Mission */ public function executeCancelMission(sfWebRequest $request) { if (!$this->getUser()->hasCredential(array('Administrator'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer()); $this->redirect('dashboard/index'); } //$request->checkCSRFProtection(); $this->forward404Unless($mission = MissionPeer::retrieveByPk($request->getParameter('id')), sprintf('Object itinerary does not exist (%s).', $request->getParameter('id'))); $mission = MissionPeer::retrieveByPk($request->getParameter('id')); $mLeg = MissionLegPeer::getAllMissionLegByMissionId($request->getParameter('id')); //$countLeg = MissionLegPeer::getMissionLegByMissionIdCount($request->getParameter('id')); if (isset($mission)) { //if(isset($countLeg)){ foreach ($mLeg as $ml) { $ml->setCancelMissionLeg(0); $ml->save(); } //} $mission->setCancelMission(0); $mission->save(); //mail $receivers = retrieveEmailAddressesRelatedToItinerary::getEmailAddressesOfPersonsRelatedToMission($mission); $mission_legs = $mission->getMissionLegs(); foreach ($mission_legs as $mission_leg) { $receivers = array_merge($receivers, retrieveEmailAddressesRelatedToItinerary::getEmailAddressesOfPersonsRelatedToMissionLeg($mission_leg)); } //print_r($receivers); exit (); $text = 'Mission ' . $mission->getId() . ' has been cancelled. Regards, Angel Flight West'; // unset($receivers); // $receivers[] = '*****@*****.**'; // $receivers[] = '*****@*****.**'; $this->getComponent('mail', 'itinerary_Mission_MissionLegCancel', array('email' => array_unique($receivers), 'subject' => 'Angel Flight West Mission cancel information', 'text' => $text)); } $this->getUser()->setFlash('success', 'The mission ' . $mission->getId() . ' has been cancelled successfully.'); $this->redirect('mission/index'); }