src/Controller/CustomerCareController.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Pimcore\Controller\FrontendController;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
  8. use App\Services\ApiService;
  9. use Pimcore\Translation\Translator;
  10. class CustomerCareController extends FrontendController
  11. {
  12.     private $apiService;
  13.     protected $translator;
  14.     public function __construct(Translator $translator)
  15.     {
  16.         $this->apiService = new ApiService();
  17.         $this->translator $translator;
  18.     }
  19.     /**
  20.      * @param Request $request
  21.      * @return Response
  22.      */
  23.     public function defaultAction(Request $request): Response
  24.     {
  25.         return $this->render('customer-care/customer-service-flow.html.twig');
  26.     }
  27.      /**
  28.      * @param Request $request
  29.      * @return Response
  30.      */
  31.     public function listPartnerWorkshopsAction(Request $request): Response
  32.     {
  33.         return $this->render('customer-care/list-partner-workshops.html.twig');
  34.     }
  35.     /**
  36.      * @param Request $request
  37.      * @return Response
  38.      */
  39.     public function listOfProvidersAction(Request $request): Response
  40.     {
  41.         return $this->render('customer-care/list-of-providers.html.twig');
  42.     }
  43.     /**
  44.      * @param Request $request
  45.      * @return Response
  46.      */
  47.     public function cekPolisAction(Request $request): Response
  48.     {
  49.         return $this->render('customer-care/cek-polis.html.twig');
  50.     }
  51.     /**
  52.      * @param Request $request
  53.      * @return Response
  54.      */
  55.     public function complaintResolutionMechanismAction(Request $request): Response
  56.     {
  57.         return $this->render('customer-care/complaint-resolution-mechanism.html.twig');
  58.     }
  59.     /**
  60.      * @param Request $request
  61.      * @return Response
  62.      */
  63.     public function complaintHandlingAction(Request $request): Response
  64.     {
  65.         return $this->render('customer-care/complaint-handling.html.twig');
  66.     }
  67.     /**
  68.      * @param Request $request
  69.      * @return Response
  70.      */
  71.     public function complaintHandlingPublicationAction(Request $request): Response
  72.     {
  73.         return $this->render('customer-care/complaint-handling-publication.html.twig');
  74.     }
  75.     /**
  76.      * @param Request $request
  77.      * @return Response
  78.      */
  79.     public function serviceProcedureAction(Request $request): Response
  80.     {
  81.         return $this->render('customer-care/service-procedure.html.twig');
  82.     }
  83.     /**
  84.      * @param Request $request
  85.      * @return Response
  86.      */
  87.     public function faqAction(Request $request): Response
  88.     {
  89.         return $this->render('customer-care/faq.html.twig');
  90.     }
  91.      /**
  92.      * @Route("api/customer-care/list-bengkel")
  93.      * @Method("GET")
  94.      */
  95.     public function apiListBengkelAction(Request $request)
  96.     {
  97.         $data $this->apiService->getListBengkel($request);
  98.         $response = [];
  99.         foreach($data->data as $value => $res){
  100.             $response[] = [
  101.                 'nama' => $res->Nama,
  102.                 'alamat' => $res->Alamat,
  103.                 'phone' => $res->Telp,
  104.                 'contact_person' => $res->Contact_Person,
  105.             ];
  106.         }
  107.         if ($response) {
  108.             return $this->json(array(
  109.                 'code' => 200,
  110.                 'status' => 'success',
  111.                 'message' => 'Success get list bengkel',
  112.                 'data' => $response,
  113.             ));
  114.         } else {
  115.             return $this->json(array(
  116.                 'code' => 404,
  117.                 'status' => 'failed',
  118.                 'message' => 'Failed get list bengkel ',
  119.                 'data' => []
  120.             ));
  121.         }
  122.     }
  123.      /**
  124.      * @Route("api/customer-care/list-provider")
  125.      * @Method("GET")
  126.      */
  127.     public function apiListProviderAction(Request $request)
  128.     {
  129.         $data $this->apiService->getListProvider($request);
  130.         
  131.         $response = [];
  132.         foreach($data->data as $value => $res){
  133.             $response[] = [
  134.                 'nama' => $res->Nama,
  135.                 'kota' => $res->Kota,
  136.                 'provinsi' => $res->Provinsi,
  137.                 'alamat' => $res->Alamat,
  138.             ];
  139.         }
  140.         if ($response) {
  141.             return $this->json(array(
  142.                 'code' => 200,
  143.                 'status' => 'success',
  144.                 'message' => 'Success get list provider',
  145.                 'data' => $response,
  146.             ));
  147.         } else {
  148.             return $this->json(array(
  149.                 'code' => 404,
  150.                 'status' => 'failed',
  151.                 'message' => 'Failed get list provider ',
  152.                 'data' => []
  153.             ));
  154.         }
  155.     }
  156.     /**
  157.      * @Route("api/cek-polis")
  158.      * @Method("GET")
  159.      */
  160.     public function apiCekPolisAction(Request $request)
  161.     {
  162.         $data $this->apiService->getCekPolis($request);
  163.         
  164.         if ($data) {
  165.             $response = [
  166.                 'policyno' => $data->PolicyNo,
  167.                 'insured' => $data->Insured,
  168.                 'payment_status' => $data->PaymentStatus,
  169.                 'start_date' => $data->StartDate,
  170.                 'expired_date' => $data->ExpiredDate,
  171.                 'field_policy_name' =>  $this->translator->trans('check-policy.field_policy_name'),
  172.                 'field_policy_number' =>  $this->translator->trans('check-policy.field_policy_number'),
  173.                 'field_policy_period_start' =>  $this->translator->trans('check-policy.field_policy_period_start'),
  174.                 'field_policy_period_end' =>  $this->translator->trans('check-policy.field_policy_period_end'),
  175.             ];
  176.             return $this->json(array(
  177.                 'code' => 200,
  178.                 'status' => 'success',
  179.                 'message' => 'Success get polis',
  180.                 'data' => $response,
  181.             ));
  182.         }else{
  183.             return $this->json(array(
  184.                 'code' => 404,
  185.                 'status' => 'failed',
  186.                 'message' => $this->translator->trans('check-policy.message_not_found'),
  187.             ));
  188.         }
  189.     }
  190. }