src/OfficeBrain/Bundle/OrderBundle/Controller/CustomOrderController.php line 118

Open in your IDE?
  1. <?php
  2. namespace App\OfficeBrain\Bundle\OrderBundle\Controller;
  3. // use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  6. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  7. use Symfony\Component\HttpFoundation\JsonResponse;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Symfony\Component\DependencyInjection\ContainerInterface;
  11. use App\OfficeBrain\Bundle\OrderBundle\Manager\Service\OrderService;
  12. use App\OfficeBrain\Bundle\CoreBundle\Service\OBCommon;
  13. use App\OfficeBrain\Bundle\CoreBundle\Service\SessionManager;
  14. use App\OfficeBrain\Bundle\CoreBundle\Helper\Validation;
  15. use App\OfficeBrain\Bundle\UserBundle\Manager\Service\UserService;
  16. use Symfony\Component\HttpFoundation\RequestStack;
  17. use Symfony\Component\Routing\RouterInterface;
  18. use Symfony\Component\Validator\Validator\ValidatorInterface;
  19. /**
  20.  *
  21.  * @author 4488
  22.  * @Route("{_locale}/")
  23.  */
  24. class CustomOrderController extends AbstractController
  25. {
  26.     /**
  27.      * @author Employee Id: 4488
  28.      * set Default Value
  29.      */
  30.     protected $user;
  31.     protected $projectUserSetting;
  32.     protected $tioryApiURL;
  33.     public function __construct(ContainerInterface $containerUserService $userServiceSessionManager $sessionManagerValidation $validationOrderService $orderServiceRequestStack $requestStackRouterInterface $routerValidatorInterface $validatorInterface)
  34.     {
  35.         $commonLibraryManager = new OBCommon($router$validatorInterface$requestStack);
  36.         $this->request null;
  37.         $this->user null;
  38.         $this->userId null;
  39.         $this->locale null;
  40.         $this->cultureId null;
  41.         $this->session null;
  42.         $this->totalProduct 0;
  43.         $this->refererUrl null;
  44.         $this->productIdArray null;
  45.         $this->orderManager $orderService->getOrderManagerExtended();
  46.         $this->validationManager $validation;
  47.         $this->userManager $userService->getUserExtended();
  48.         $this->sessionManager $sessionManager;
  49.         $this->commonLibraryManager $commonLibraryManager;
  50.         $this->responseArray = array();
  51.         $this->projectSetting null;
  52.         $this->productCultureIdArray null;
  53.         $this->inlineViewProductMaxLimit null;
  54.         $this->productId null;
  55.         $this->productSlug null;
  56.         $this->productCultureId null;
  57.         $this->config null;
  58.         $this->productDetailconfigurationRule null;
  59.         $this->searchParameterArray = array();
  60.         $this->searchKeyWordsArray = array();
  61.         $this->tioryApiURL null;
  62.         $this->serviceContainer $container;
  63.     }
  64.     /**
  65.      *
  66.      * @author Employee Id: 4488
  67.      * To unset member variables
  68.      * @return NULL
  69.      */
  70.     public function __destruct()
  71.     {
  72.         unset($this->user);
  73.         unset($this->userId);
  74.         unset($this->locale);
  75.         unset($this->session);
  76.         unset($this->request);
  77.         unset($this->refererUrl);
  78.         unset($this->cultureId);
  79.         unset($this->cultureProductId);
  80.         unset($this->responseArray);
  81.         unset($this->totalProduct);
  82.         unset($this->entityManager);
  83.         unset($this->productIdArray);
  84.         unset($this->sessionManager);
  85.         unset($this->projectSetting);
  86.         unset($this->productCultureIdArray);
  87.         unset($this->productId);
  88.         unset($this->productSlug);
  89.         unset($this->productCultureId);
  90.         unset($this->inlineViewProductMaxLimit);
  91.         unset($this->commonLibraryManager);
  92.         unset($this->config);
  93.         unset($this->searchParameterArray);
  94.         unset($this->searchKeyWordsArray);
  95.         unset($this->tioryApiURL);
  96.     }
  97.     /**
  98.      *
  99.      * @author Employee Id: 4488
  100.      * Create various objects required action in this class
  101.      * @return NULL
  102.      */
  103.     public function initAction(Request $request)
  104.     {
  105.         $this->request $request;
  106.         $this->projectSetting $this->request->get('project_setting');
  107.         $this->locale $this->projectSetting['culture_code'];
  108.         $this->userId $this->projectSetting['user_id'];
  109.         $this->instanceType $this->projectSetting['instance_type'];
  110.         // $this->orderManager = $this->serviceContainer->get('office_brain_order_manager');
  111.         $this->orderManager $this->orderManager;
  112.         // $this->commonLibraryManager = $this->serviceContainer->get('office_brain_common_library');
  113.         $this->commonLibraryManager $this->commonLibraryManager;
  114.         // $this->sessionManager = $this->serviceContainer->get('office_brain_session_manager');
  115.         $this->sessionManager $this->sessionManager;
  116.         // $this->validationManager = $this->serviceContainer->get('office_brain_validation_manager');
  117.         $this->validationManager $this->validationManager;
  118.         // $this->userManager = $this->serviceContainer->get('office_brain_user_manager');
  119.         $this->userManager $this->userManager;
  120.         $this->projectUserSetting $this->request->get('project_user_setting');
  121.         $this->page $this->request->get('page''1');
  122.         $this->recordsPerPage $this->request->get('records_per_page'100);
  123.         $this->user $this->projectUserSetting['user_data'];
  124.         $this->tioryApiURL $this->serviceContainer->getParameter('tiory_url');
  125.     }
  126.     /**
  127.      * @author Employee Id: 4488
  128.      * Description : Order Status
  129.      * @Route("order-status",
  130.      * name="office_brain_orderbundle_customorder_order_status",
  131.      * options={"expose"=true}
  132.      * )
  133.      * @Template("OfficeBrain/Bundle/OrderBundle/Order/orderStatus.html.twig")
  134.      */
  135.     public function orderStatusAction(Request $request)
  136.     {
  137.         $this->initAction($request);
  138.         if(!is_object($this->user))
  139.         {
  140.             return $this->redirect($this->generateUrl('office_brain_userbundle_login_login'));
  141.         }
  142.         $this->responseArray['userObj']=$this->user;
  143.         return $this->responseArray;
  144.     }
  145.     
  146.     /**
  147.      * @author Employee Id: 4488
  148.      * Description : Order Status
  149.      * @Route("cc-payment-status",
  150.      * name="office_brain_orderbundle_customorder_order_ccpayments",
  151.      * options={"expose"=true}
  152.      * )
  153.      * @Template("OfficeBrain/Bundle/OrderBundle/Order/ccpayment.html.twig")
  154.      */
  155.     public function ccpaymentsAction(Request $request)
  156.     {
  157.         $this->initAction($request);
  158.         if(!is_object($this->user))
  159.         {
  160.             return $this->redirect($this->generateUrl('office_brain_userbundle_login_login'));
  161.         }
  162.         // $userId = $this->user->getId();
  163.         $userAccountId $this->user->getUserCompany()->getTioryCustomerAccountId();
  164.         //$userAccountId = 234;
  165.         $this->responseArray['records_per_page'] = $this->recordsPerPage;
  166.         $this->responseArray['page'] = $this->page;
  167.         $this->prepareSearchParameterArray();
  168.         $this->responseArray['data'] = $this->orderManager->getccPaymentList($userAccountId$this->page,$this->recordsPerPage,$this->searchParameterArray,$this->searchKeyWordsArray);
  169.         $this->responseArray['total'] = $this->orderManager->getccTotalCountUserWise($userAccountId);
  170.         //print_r($this->responseArray);
  171.         //$this->responseArray['payment']=$this->orderManager->getCcpayments($userId,$userAccountId);
  172.         //die("Here");
  173.         $this->responseArray['userObj']=$this->user;
  174.         return $this->responseArray;
  175.     }
  176.     
  177.     private function prepareSearchParameterArray()
  178.     {
  179.         $this->option $this->request->get('option'null);
  180.         $this->keywords $this->request->get('keyword'null);
  181.         $this->searchKeyWordsArray[$this->option]=trim($this->keywords);
  182.          
  183.     }
  184.      
  185.     /**
  186.      * @author Employee Id: 4488
  187.      * Description : Order Status Detail ajax
  188.      * @Route("order-status-detail",
  189.      * name="office_brain_orderbundle_customorder_order_status_detail",
  190.      * options={"expose"=true}
  191.      * )
  192.      * @Template("OfficeBrain/Bundle/OrderBundle/Order/orderStatusDetail.html.twig")
  193.      */
  194.     public function orderStatusDetailAction(Request $request)
  195.     {
  196.         $this->initAction($request);
  197.         $data $this->request->request->all();
  198.         $data['url'] = $this->tioryApiURL;
  199.         /*if(empty($data['aakronCustomer'])){
  200.          //$this->responseArray['recordSet'][]['errorMessage'] = "Customer Account is required";
  201.          $this->responseArray['fail']=1;
  202.          }*/
  203.         //print_r($this->container->getParameter('order_status_setting'));exit;
  204.         
  205.         $this->responseArray['recordSet'][] = $this->orderManager->getOrderStatusDetails($data);
  206.         $this->responseArray['recordSet'][count($this->responseArray['recordSet'])]['order_status_setting']=$this->serviceContainer->getParameter('order_status_setting');
  207.         /*echo "<pre>";
  208.         print_r($this->responseArray); die;*/
  209.         //$this->responseArray['recordSet'][]=$this->orderManager->getOrderStatusDetails($this->responseArray['aakronCustomer'],$this->responseArray['aakronOrder'],$this->responseArray['aakronCustomerPO']);
  210.         /*$this->responseArray['aakronCustomer']=$this->request->get('aakronCustomer',null);
  211.          $this->responseArray['aakronOrder']=$this->request->get('aakronOrder',null);
  212.          $this->responseArray['aakronCustomerPO']=$this->request->get('aakronCustomerPO',null);
  213.          
  214.          if($this->responseArray['aakronCustomer'] !='' && ($this->responseArray['aakronOrder']!='' || $this->responseArray['aakronCustomerPO']!='' ))
  215.          $this->responseArray['recordSet'][]=$this->orderManager->getOrderStatusDetails($this->responseArray['aakronCustomer'],$this->responseArray['aakronOrder'],$this->responseArray['aakronCustomerPO']);
  216.          else
  217.          $this->responseArray['fail']=1;
  218.          */
  219.          return $this->responseArray;
  220.          
  221.     }
  222.     
  223.     /**
  224.      * @author Employee Id: 4488
  225.      * Description : Order Invoice
  226.      * @Route("order-invoice",
  227.      * name="office_brain_orderbundle_customorder_order_invoice",
  228.      * options={"expose"=true}
  229.      * )
  230.      * @Template("OfficeBrain/Bundle/OrderBundle/Order/orderInvoice.html.twig")
  231.      */
  232.     public function orderInvoiceAction(Request $request)
  233.     {
  234.         $this->initAction($request);
  235.         if(!is_object($this->user))
  236.         {
  237.             return $this->redirect($this->generateUrl('office_brain_userbundle_login_login'));
  238.         }
  239.         $this->responseArray['userObj']=$this->user;
  240.         return $this->responseArray;
  241.         
  242.     }
  243.     /**
  244.      * @author Employee Id: 4488
  245.      * Description : Order invoice list ajax
  246.      * @Route("order-invocie-list",
  247.      * name="office_brain_orderbundle_customorder_order_invoice_detail",
  248.      * options={"expose"=true}
  249.      * )
  250.      * @Template("OfficeBrain/Bundle/OrderBundle/Order/orderInvoiceDetail.html.twig")
  251.      */
  252.     public function orderInvoiceDetailAction(Request $request)
  253.     {
  254.         $this->initAction($request);
  255.         $userAccountId null;
  256.         if(is_object($this->user))
  257.         {
  258.             if($this->user->getUserCompany()!=null){
  259.                 if($this->user->getUserCompany()->getTioryCustomerAccountId()!=null){
  260.                     $userAccountId $this->user->getUserCompany()->getTioryCustomerAccountId();
  261.                 }
  262.             }
  263.         }
  264.         //$userAccountId = 194171;
  265.         $this->responseArray['aakronCustomer']=$this->request->get('aakronCustomer',$userAccountId);
  266.         $this->responseArray['aakronOrder']=$this->request->get('aakronOrder',null);
  267.         $this->responseArray['aakronCustomerPO']=$this->request->get('aakronCustomerPO',null);
  268.         $this->responseArray['aakronInvoiceNo']=$this->request->get('aakronCustomerPO',null);
  269.         $this->responseArray['aakronInvoiceType']=$this->request->get('aakronInvoceType',null);
  270.         $this->responseArray['aakronInvoiceReqDate']=$this->request->get('aakronInvoiceReqDate',null);
  271.         $this->responseArray['aakronInvoiceAvalDate']=$this->request->get('aakronInvoiceAvalDate',null);
  272.         $this->responseArray['aakronInvoiceStartDate']=$this->request->get('aakronInvoiceStartDate',null);
  273.         $this->responseArray['aakronInvoiceEndDate']=$this->request->get('aakronInvoiceEndDate',null);
  274.         if($this->responseArray['aakronCustomer'] !='' &&  $this->responseArray['aakronInvoiceType'] !='' && ($this->responseArray['aakronOrder']!='' || $this->responseArray['aakronCustomerPO']!='' || $this->responseArray['aakronInvoiceNo']!='' || $this->responseArray['aakronInvoiceReqDate']!='' || $this->responseArray['aakronInvoiceAvalDate']!='' || $this->responseArray['aakronInvoiceStartDate']!='' || $this->responseArray['aakronInvoiceEndDate'])){
  275.             $this->responseArray['recordSet'][]=$this->orderManager->getOrderInvoiceDetails($this->responseArray['aakronCustomer'],$this->responseArray['aakronOrder'],$this->responseArray['aakronCustomerPO'],$this->responseArray['aakronInvoiceNo'],$this->responseArray['aakronInvoiceType'],$this->responseArray['aakronInvoiceReqDate'],$this->responseArray['aakronInvoiceAvalDate'],$this->responseArray['aakronInvoiceStartDate'],$this->responseArray['aakronInvoiceEndDate'],'',$this->tioryApiURL);
  276.         }else{ 
  277.             //$this->responseArray['fail']=1;
  278.             if($this->responseArray['aakronCustomer'] !=''){
  279.                 $this->responseArray['recordSet'][]=$this->orderManager->getOrderInvoiceDetails($this->responseArray['aakronCustomer'],$this->responseArray['aakronOrder'],$this->responseArray['aakronCustomerPO'],$this->responseArray['aakronInvoiceNo'],$this->responseArray['aakronInvoiceType'],$this->responseArray['aakronInvoiceReqDate'],$this->responseArray['aakronInvoiceAvalDate'],$this->responseArray['aakronInvoiceStartDate'],$this->responseArray['aakronInvoiceEndDate'],'no',$this->tioryApiURL); 
  280.             }else{
  281.                 $this->responseArray['fail']=1;
  282.             }
  283.         }
  284.         
  285.         //print_r($this->responseArray); die;    
  286.         return $this->responseArray;
  287.     }
  288.     /**
  289.      * @author Employee Id: 4488
  290.      * Description : Order invoice Detail Report ajax
  291.      * @Route("order-invocie-detail",
  292.      * name="office_brain_orderbundle_customorder_order_invoice_report",
  293.      * options={"expose"=true}
  294.      * )
  295.      * @Template("OfficeBrain/Bundle/OrderBundle/Order/orderInvoiceDetailReport.html.twig")
  296.      */
  297.     public function orderInvoiceReportAction(Request $request)
  298.     {
  299.         $this->initAction($request);
  300.         $this->responseArray['OrderNo']=$this->request->get('invoiceno',null);
  301.         $this->responseArray['recordSet']=$this->orderManager->getOrderInvoiceReport($this->responseArray['OrderNo']);
  302.         
  303.         return $this->responseArray;
  304.     }
  305.     
  306.     /**
  307.      * @author Vendor
  308.      * Description : Review Proof
  309.      * @Route("proof-review/{orderId}",
  310.      * name="office_brain_orderbundle_customorder_review_proof",
  311.      * options={"expose"=true}
  312.      * )
  313.      * @Template("OfficeBrain/Bundle/OrderBundle/Order/orderReviewProof.html.twig")
  314.      */
  315.     public function orderProofReviewAction(Request $request$orderId=0)
  316.     {
  317.         $this->initAction($request);
  318. /*         if(!is_object($this->user)){
  319.              return $this->redirect($this->generateUrl('office_brain_userbundle_login_login'));
  320.         }
  321.  */       
  322.         $this->responseArray['userObj']=$this->user;
  323.         $this->responseArray['orderId']=$orderId;
  324.         $this->responseArray['APIUrl']= "https://arc1967.tiory.com/api/";
  325.         $this->responseArray['attachmentBasePath']= "https://aakronline-erp.s3.amazonaws.com/";
  326.         
  327.         return $this->responseArray;
  328.     }
  329.     
  330.            /**
  331.          *
  332.          * @author Vendor
  333.          *        
  334.          * Desciption: download pdf of proof
  335.          * @return Response
  336.          *
  337.          * @Route("download-order-review-proof/{orderId}",
  338.          *     name="officebrain_custombundle_orderbundle_download_order_review_proof"
  339.          * )
  340.          */
  341.         public function downloadOrderReviewProofAction(Request $request$orderId)
  342.         {
  343.             $this->initAction($request);
  344.         $this->responseArray['userObj']=$this->user;
  345.         $this->responseArray['orderId']=$orderId;
  346.         $this->responseArray['APIUrl']= "https://arc1967.tiory.com/api/";
  347.         $this->responseArray['attachmentBasePath']= "https://aakronline-erp.s3.amazonaws.com/";
  348.                 
  349.         try{
  350.         $curl curl_init();
  351.         curl_setopt_array($curl, array(
  352.           CURLOPT_URL => 'https://arc1967.tiory.com/api/en_us/proof-view/'.$orderId,
  353.           CURLOPT_RETURNTRANSFER => true,
  354.           CURLOPT_ENCODING => '',
  355.           CURLOPT_MAXREDIRS => 10,
  356.           CURLOPT_TIMEOUT => 0,
  357.           CURLOPT_FOLLOWLOCATION => true,
  358.           CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  359.           //CURLOPT_CUSTOMREQUEST => 'GET',
  360.           CURLOPT_HTTPHEADER => array(
  361.             'Content-Type: application/json'
  362.           ),
  363.         ));
  364.         $response curl_exec($curl);
  365.         curl_close($curl);
  366.         $this->responseArray['privewDataPdf'] = json_decode($response,true);
  367.         
  368.         $twigResponse $this->render('project/OfficeBrain/CustomBundle/OrderBundle/Order/downloadOrderReviewProof.html.twig'$this->responseArray);
  369.         //echo $twigResponse->getContent();
  370.         
  371.         return new Response($this->get('knp_snappy.pdf')->getOutputFromHtml($twigResponse->getContent()), 200, array(
  372.             'Content-Type' => 'application/pdf',
  373.             'Content-Disposition' => 'attachment; filename="E-proof.pdf"'
  374.         ));
  375.         }
  376.         
  377.         catch(Exception $e) {
  378.           echo 'Message: ' .$e->getMessage();
  379.         }
  380.                 
  381.         }
  382.     
  383. }