KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Koolreport drilldown in laravel not working #754

Open lori opened this topic on on Mar 20, 2019 - 1 comments

lori commented on Mar 20, 2019

hello, drilldown in laravel in level 1 show correctly but when click on one item not working and show this error : error 405 Method Not Allowed.

///////////////////////////////////////////web.php
Route::post('admin/modirreportvosoli', "ModirReportVosoliController@index")->name('ModirReportVosoli');
//////////////////////////////////////////reportdaramad.view.php
<?php

use \koolreport\drilldown\DrillDown;
use \koolreport\processes\CopyColumn;
use \koolreport\processes\DateTimeFormat;
use \koolreport\chartjs\ColumnChart;
use \koolreport\widgets\koolphp\Table;


?>
<div class="report-content">

    <?php
    DrillDown::create(array(
        "name"=>"daramadkh_DrillDown",
        "title"=>"test",
        "scope" =>  array(
            "_token" => csrf_token(),
        ),
        "levels"=>array(
            array(
                //Level 1: Show all years and sales with column chart
               "title"=>"همه سالها",
                "widget"=>array(ColumnChart::class,array(
                    "dataSource"=>function($params,$scope)
                    {
                        return $this->src("mysql")->query("
									SELECT SUBSTR(pdat,1,4) as year,sum(daramad_kh) as sum_mab 
									FROM amar_dashboard_ab
									GROUP BY year
							");
                    },
                    "columns"=>array(
                        "year"=>array(
                            "type"=>"string",
                            "label"=>"سال",
                        ),
                        "sum_mab"=>array(
                            "label"=>"درآمد خالص",
                            "suffix"=>"ریال",
                        )
                    ),
                ))
            ),
            array(
                //Level 2: Show all months and sale amount in a selected year
                "title"=>function($params,$scope)
                {
                    return "سال ".$params["year"];
                },
                "widget"=>array(ColumnChart::class,array(
                    "dataSource"=>function($params,$scope)
                    {
                        return $this->src("mysql")->query("
								SELECT SUBSTR(amar_dashboard_ab.pdat,6,2) as month_id,codes.name as month,sum(amar_dashboard_ab.daramad_kh) as sum_mab 
								FROM amar_dashboard_ab LEFT JOIN codes ON 330300+SUBSTR(amar_dashboard_ab.pdat,6,2)= codes.id 
								WHERE  SUBSTR(amar_dashboard_ab.pdat,1,4)=:year
								GROUP BY month_id
						")->params(array(
                            ":year"=>$params["year"]
                        ));
                    },
                    "columns"=>array(
                        "month"=>array(
                            "label"=>"ماه",
                            "type"=>"string",
                        ),
                        "sum_mab"=>array(
                            "label"=>"درآمد خالص",
                            //"suffix"=>"ریال",
                        )
                    ),
                ))
            ),
            array(
                //Level 3; Show all days in selected month and year
                "title"=>function($params,$scope)
                {
                    return $params["month"];
                },
                //"widget"=>array(Table::class,array(
                "widget"=>array(ColumnChart::class,array(
                    "dataSource"=>function($params,$scope)
                    {
                        return $this->src("mysql")->query("
								SELECT amar_dashboard_ab.pdat,SUBSTR(amar_dashboard_ab.pdat,6,2) as month_id,codes.name as month,SUBSTR(pdat,9,2) as day,
								sum(amar_dashboard_ab.daramad_kh) as sum_mab 
								FROM amar_dashboard_ab LEFT JOIN codes ON 330300+SUBSTR(amar_dashboard_ab.pdat,6,2)= codes.id 
								WHERE YEAR(amar_dashboard_ab.pdat)=:year
                                    AND
                                    codes.name=:month 
                                GROUP BY day
							")->params(array(
                            ":year"=>$params["year"],
                            ":month"=>$params["month"],
                        ));
                    },
                    "columns"=>array(
                        "day"=>array(
                            "label"=>"روز",
                        ),
                        "sum_mab"=>array(
                            "label"=>"درآمد خالص",
                            //"suffix"=>"ریال",
                        )
                    )

                ))
            ),
        ),
    ));
    ?>
</div>

inspect element error

Request URL: http://localhost:8000/admin/dashboardmodir
Request method:POST
Remote address:127.0.0.1:8000
Status code:405 Method Not Allowed
Version:HTTP/1.0
Referrer Policy:no-referrer-when-downgrade
	
Response headers (256 B)	
Allow	
GET, HEAD
Cache-Control	
no-cache, private
Connection	
close
Content-Type	
application/json
Date	
Wed, 20 Mar 2019 05:59:30 +0000
Date	
Wed, 20 Mar 2019 05:59:30 GMT
Host	
localhost:8000
X-Powered-By	
PHP/7.1.16
Request headers (1.145 KB)	
Accept	
*/*
Accept-Encoding	
gzip, deflate
Accept-Language	
en-US,en;q=0.5
Connection	
keep-alive
Content-Length	
337
Content-Type	
application/x-www-form-urlencoded; charset=UTF-8
Cookie	
G_ENABLED_IDPS=google; __utma=…TlhZmUzODZlNTQyZDlhOGQ3In0%3D
Host	
localhost:8000
Referer	
http://localhost:8000/admin/dashboardmodir
User-Agent	
Mozilla/5.0 (Windows NT 6.1; W…) Gecko/20100101 Firefox/65.0
X-CSRF-TOKEN	
ycN39ILRcDUOIxdu8EJmMaPmkwfdQG3kQIjycEm6
X-Requested-With	
XMLHttpRequest

KoolReport commented on Mar 20, 2019

In your server response I see this:

Request method:POST

and

Allow	
GET, HEAD

So it seems there is issue with Laravel which does not allow POST to reach the method. Could you please check. You can type the error into google, you will get alot of solutions.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

DrillDown