src/CompanyGroupBundle/Modules/CommercialJourney/Controller/CustomerHandoffAdminController.php line 5

Open in your IDE?
  1. <?php
  2. namespace CompanyGroupBundle\Modules\CommercialJourney\Controller;
  3. use ApplicationBundle\Controller\GenericController;use ApplicationBundle\Modules\Authentication\Constants\UserConstants;use CompanyGroupBundle\Entity\CustomerSuccessHandoff;use Symfony\Component\HttpFoundation\Request;
  4. class CustomerHandoffAdminController extends GenericController
  5. {public function indexAction(Request $r){if(!$this->admin($r)){return $this->redirectToRoute('dashboard');}return $this->render('@CompanyGroup/Modules/CommercialJourney/handoffs.html.twig',array('page_title'=>'Customer Handoffs','queue'=>$this->get('app.customer_handoff_service')->queue(100,$r->query->get('view'))));}
  6. public function updateAction(Request $r,$id){if(!$this->admin($r)||!$this->isCsrfTokenValid('customer_handoff_'.$id,(string)$r->request->get('_token'))){throw $this->createAccessDeniedException();}$h=$this->getDoctrine()->getManager('company_group')->getRepository(CustomerSuccessHandoff::class)->find((int)$id);if($h){try{$this->get('app.customer_handoff_service')->update($h,$r->request->all());$this->addFlash('success','Handoff owner, review, and scope updated.');}catch(\InvalidArgumentException $e){$this->addFlash('warning',$e->getMessage());}}return $this->redirectToRoute('admin_customer_handoffs');}
  7. public function firstValueAction(Request $r,$id){if(!$this->admin($r)||!$this->isCsrfTokenValid('customer_first_value_'.$id,(string)$r->request->get('_token'))){throw $this->createAccessDeniedException();}$h=$this->getDoctrine()->getManager('company_group')->getRepository(CustomerSuccessHandoff::class)->find((int)$id);if($h){try{$this->get('app.customer_handoff_service')->recordFirstValue($h,$r->request->get('evidence_type'),$r->request->get('evidence_reference'),$r->request->get('milestone'));$this->addFlash('success','First-value evidence recorded. No adoption percentage was inferred.');}catch(\InvalidArgumentException $e){$this->addFlash('warning',$e->getMessage());}}return $this->redirectToRoute('admin_customer_handoffs');}
  8. private function admin(Request $r){$s=$r->getSession();return (int)$s->get(UserConstants::USER_ID,0)>0&&((int)$s->get(UserConstants::IS_BUDDYBEE_ADMIN,0)===1||(int)$s->get(UserConstants::ALL_MODULE_ACCESS_FLAG,0)===1);}}