IMMREX7

aku nok ndi : /home/spdtg/www/gomygps/app/Http/
File Up :
aku nok ndi : /home/spdtg/www/gomygps/app/Http/GenerateReport.php

<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace App\Http;

/**
 * Description of GenerateReport
 *
 * @author Lenovo
 */
class GenerateReport {

    //put your code here
    static function genReport($dlno, $type, $chasis) {
        if ($type == 'parivahan') {
            $url = 'https://g2c.softpayapi.com/api/e_challan/challan_info?api_key=LRNS2NQ92M2111290445266493UTZW2ST52QLL1GJF4GGNYHKXB&client_order_id=123456&type=5&vehicle_no=' . $dlno;
        } else if ($type == 'bengaluru') {
            $url = 'https://g2c.softpayapi.com/api/e_challan/challan_info_south?api_key=LRNS2NQ92M2111290445266493UTZW2ST52QLL1GJF4GGNYHKXB&client_order_id=1234659898&type=2&vehicle_no='. $dlno;
            //$url = 'https://g2c.softpayapi.com/api/e_challan/challan_info?api_key=LRNS2NQ92M2111290445266493UTZW2ST52QLL1GJF4GGNYHKXB&client_order_id=123456&type=6&vehicle_no=' . $dlno;
        } else if ($type == 'delhi') {
            $url = 'https://apis.softcareinfotech.com/api/eChallan/echallan?tokenkey=LRNS2NQ92M2111290445266493UTZW2ST52QLL1GJF4GGNYHKXB&type=2&vehicle_no='.$dlno.'&chasis_no='. $chasis;
            //$url = 'https://g2c.softpayapi.com/api/e_challan/challan_info?api_key=LRNS2NQ92M2111290445266493UTZW2ST52QLL1GJF4GGNYHKXB&client_order_id=123456&type=6&vehicle_no=' . $dlno;
        } else if ($type == 'hyderabad') {
            $url = 'https://g2c.softpayapi.com/api/e_challan/challan_info_south?api_key=LRNS2NQ92M2111290445266493UTZW2ST52QLL1GJF4GGNYHKXB&client_order_id=1234659898&type=1&vehicle_no='. $dlno;
            //$url = 'https://g2c.softpayapi.com/api/e_challan/challan_info?api_key=LRNS2NQ92M2111290445266493UTZW2ST52QLL1GJF4GGNYHKXB&client_order_id=123456&type=6&vehicle_no=' . $dlno;
        } else {
            $url = 'https://g2c.softpayapi.com/api/e_challan/challan_info?api_key=LRNS2NQ92M2111290445266493UTZW2ST52QLL1GJF4GGNYHKXB&client_order_id=123456&type=1&dl_no=' . $dlno;
        }
        $ch = curl_init();
        curl_setopt_array($ch, array(
            CURLOPT_URL => $url,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_POST => false,
//            CURLOPT_POSTFIELDS => $postData
        ));


        //Ignore SSL certificate verification
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);


        //get response
        $output = curl_exec($ch);
        //return $output;
        $json_response = json_decode($output);
        if ($type == 'parivahan') {
            if ($json_response != null && $json_response->status == 'SUCCESS') {
                $details = $json_response->detail->data;
                $details_json = json_decode($details);
                $challan_details = $details_json->challanDetails;
                foreach ($challan_details as $var) {
                    $challan = \App\ParivahanReport::where('challanNo', '=', $var->challanno)->first();
                    if (empty($challan)) {
                        $mparivahan = new \App\ParivahanReport();
                        $mparivahan->challanNo = $var->challanno;
                        $mparivahan->vehicleNo = $dlno;
                        $mparivahan->offenceDateTime = $var->offencedate.' '.$var->offencetime;
                        $mparivahan->amount = $var->totalamount;
                        $mparivahan->challan_status = $var->paymentstatuscheck;
                        $mparivahan->resource_ids = $var->resourceids;
                        if(!empty($var->recieptno))
                        $mparivahan->receipt_no = $var->recieptno;
                        $mparivahan->save();
                    }
                }
                /*
                $results = $json_response->results;
                foreach($results as $result){
                    $challan = \App\ParivahanReport::where('challanNo', '=', $result->challan_no)->first();
                        /*if(!empty($results[0]->offences[0])){
                            $parivahan->offenceName = $results[0]->offences[0]->offence_name;
                        }*//*
                        foreach($result->offences as $offence){
                            $parivahan = new \App\ParivahanReport();
                            $parivahan->challanNo = $result->challan_no;
                            $parivahan->vehicleNo = $dlno;
                            $parivahan->offenceDateTime = $result->date_time;
                            $parivahan->amount = $result->amount;
                            $parivahan->challan_status = $result->challan_status;
                            $parivahan->paymentDate = $result->payment_date;
                            if(!empty($result->receipt_url))
                            {
                                $parivahan->receipt_url = $result->receipt_url;
                            }else $parivahan->receipt_url = $result->pdf_url;
                            $parivahan->offenceName = $offence->offence_name;
                            $parivahan->amount = $offence->penalty;
                            $parivahan->idOffence = $offence->offence_id;
                            $parivahan->save();
                        }
                }*/
                $job = \App\VehicleJobs::where('vehicle', '=', $dlno)->where('type', '=', $type)->where('created_at', '=', date('Y-m-d'))->first();
                if (!empty($job)) {
                    $job->status = "Success";
                    $job->update();
                }
            }
            curl_close($ch);
        } else if ($type == 'bengaluru') {
            if ($json_response != null && $json_response->status == 'SUCCESS') {
                //dd($json_response);
                $details = $json_response->cart;
                $results = $details->cart_items;
                foreach($results as $items){
                    foreach($items->service_options as $action){
                        foreach($action as $data){
                            foreach($data->updatedValues as $offence){
                                $challanNo = (array) $offence;
                                $challan = \App\BengaluruReport::where('challanNo', '=',  $challanNo["label"])->first();
                                if($challan == null){
                                    $parivahan = new \App\BengaluruReport();
                                    $parivahan->challanNo = $challanNo["label"];
                                    $parivahan->vehicleNo = $dlno;
                                    $parivahan->amount = $offence->billAmount;
                                    $parivahan->challanType = $offence->challan_type;
                                    
                                    foreach($offence->displayValues as $values){
                                        if($values->label == "VIOLATION_DATE"){
                                            $dateTime = strtotime($values->value);
                                            $parivahan->offenceDateTime = date('Y-m-d H:i:s', $dateTime);   ;
                                        }else if($values->label == "OFFENCE_DESCRIPTION"){
                                            $parivahan->offenceName = $values->value;
                                        }
                                    }
                                    $parivahan->save();
                                }
                            }
                        }
                    }
                }
                $job = \App\VehicleJobs::where('vehicle', '=', $dlno)->where('type', '=', $type)->where('created_at', '=', date('Y-m-d'))->first();
                if (!empty($job)) {
                    $job->status = "Success";
                    $job->update();
                }
            }
            curl_close($ch);
        } else if ($type == 'delhi') {
            if ($json_response != null && strtoupper($json_response->status) == 'SUCCESS') {
                foreach($json_response->results as $items){
                    foreach($items->offences as $offence){
                        $challan = \App\DelhiReport::where('challanNo', '=',  $items->challan_no)->first();
                        if($challan == null){
                            $parivahan = new \App\DelhiReport();
                            $parivahan->challanNo = $items->challan_no;
                            $parivahan->vehicleNo = $dlno;
                            $parivahan->amount = $items->amount;
                            $parivahan->offenceDateTime = $items->date_time;
                            $parivahan->offence = $offence->offence_name;
                            $parivahan->pdf_url = $items->pdf_url;
                            $parivahan->challan_status = $items->challan_status;
                            $parivahan->payment_date = $items->payment_date;
                            $parivahan->save();
                        }
                    }
                }
                $job = \App\VehicleJobs::where('vehicle', '=', $dlno)->where('type', '=', $type)->where('created_at', '=', date('Y-m-d'))->first();
                if (!empty($job)) {
                    $job->status = "Success";
                    $job->update();
                }
            }
            curl_close($ch);
        } else if ($type == 'hyderabad') {
            if ($json_response != null && $json_response->status == 'SUCCESS') {
                //return json_encode($json_response);
                $details = $json_response->cart;
                $results = $details->cart_items;
                foreach($results as $items){
                    foreach($items->service_options as $action){
                        foreach($action as $data){
                            foreach($data->updatedValues as $offence){
                                $challanNo = (array) $offence;
                                $challanNumber = null;
                                $parivahan = new \App\HyderabadReport();
                                foreach($offence->displayValues as $values){
                                    if($values->label == "Challan No"){
                                        $parivahan->challanNo = $values->value;
                                        $challanNumber = $values->value;
                                    }else if($values->label == "Date"){
                                        $dateTime = strtotime($values->value);
                                        $parivahan->offenceDateTime = date('Y-m-d H:i:s', $dateTime); 
                                    }else if($values->label == "Offence Type"){
                                        $parivahan->offenceName = $values->value;
                                    }
                                }
                                $challan = \App\HyderabadReport::where('challanNo', '=',  $challanNumber)->first();
                                if($challan == null){
                                    $parivahan->challanNo = $challanNo["label"];
                                    $parivahan->vehicleNo = $dlno;
                                    $parivahan->amount = $offence->billAmount;
                                    $parivahan->challanType = $offence->challan_type;
                                    $parivahan->save();
                                }
                            }
                        }
                    }
                }
                $job = \App\VehicleJobs::where('vehicle', '=', $dlno)->where('type', '=', $type)->where('created_at', '=', date('Y-m-d'))->first();
                if (!empty($job)) {
                    $job->status = "Success";
                    $job->update();
                }
            }
            curl_close($ch);
        } else  {

            //return $json_response;
            if ($json_response != null && $json_response->status == 'SUCCESS') {
                //return $json_response;
                $details = $json_response->detail->results;
                foreach ($details as $challan_details) {
                    $challan = \App\MaharastraReport::where('challanNo', '=', $challan_details->challan_no)->first();
                    if (empty($challan)) {
                            $mparivahan = new \App\MaharastraReport();
                            $mparivahan->challanNo = $challan_details->challan_no;
                            $mparivahan->vehicleNo = $dlno;
                            $mparivahan->date = date('Y-m-d');
                            //
                            $dt =explode(" ", $challan_details->date_time);
                            $mparivahan->offenceDate =$dt[0];
                            $mparivahan->offenceTime = $dt[1];  
                            $mparivahan->amount = $challan_details->amount;
                            $mparivahan->paymentstatuscheck = $challan_details->transaction_id;
                            $mparivahan->resource_ids = $challan_details->pdf_url;
                            $mparivahan->save();
                    }
                }
                //$details_json = json_decode($details);
                //$challan_details = $details_json->challanDetails;
                $job = \App\VehicleJobs::where('vehicle', '=', $dlno)->where('type', '=', $type)->where('created_at', '=', date('Y-m-d'))->first();
                if (!empty($job)) {
                    $job->status = "Success";
                    $job->update();
                }
            }
            curl_close($ch);
        }

        return $output;
    }

}

Copyright © 2021 - 2025 IMMREX7