2016-12-24 80 views
0

我創建了一個名爲「atom」的Reportico項目和一個名爲「Receipts」的報告,然後在ReportController中創建了action = receipt。 This是我跟着教程:Reportico:yii2如何嵌入鏈接?

控制器代碼:

public function actionReceipts() 
{ 
    return $this->render('receipts'); 
} 

我創建receipts.php

<?php 

use yii\helpers\Html; 
use yii\helpers\Url; 

$this->title = Yii::t('app', 'Reports'); 
$this->params['breadcrumbs'][] = $this->title; 
?> 
<div class="report-index"> 



<div class="container"> 
<div class="row"> 
    <div class="col-sm-1"> 
    </div> 
    <div class="col-sm-11"> 


    <?php 
     $reportico = \Yii::$app->getModule('reportico'); 
    $engine = $reportico->getReporticoEngine();  // Fetches reportico engine 
    $engine->access_mode = "ONEREPORT";    // Allows access to single specified report 
    $engine->initial_execute_mode = "PREPARE";   // Starts user in report criteria selection mode 
    $engine->initial_project = "atom";   // Name of report project folder 
    $engine->initial_report = "receipts";   // Name of report to run 
    $engine->bootstrap_styles = "3";     // Set to "3" for bootstrap v3, "2" for V2 or false for no bootstrap 
    $engine->force_reportico_mini_maintains = true; // Often required 
    $engine->bootstrap_preloaded = true;    // true if you dont need Reportico to load its own bootstrap 
    $engine->clear_reportico_session = true;   // Normally required 
    $engine->execute(); 
    ?> 
    </div> 

</div> 

</div> 
</div> 

我的代碼應該打開

http://localhost/Atom/backend/web/index.php?r=report%2Freceipts 

當我嘗試它,我得到了像我附上的圖片

enter image description here

當我輸入在config.php define('SW_ADMIN_PASSWORD','1234');沒有顯示的密碼。

我不需要強制用戶輸入密碼!

我需要將報告嵌入到條件輸入模式中。 enter image description here

回答

0

首先,如果你不想提示輸入密碼的動作,然後取出密碼從config.php文件或使用項目配置選項將其空白。如果您想保留它,然後添加到代碼中(在執行調用之前)

$engine->initial_project_password = "1234";

其次,我認爲這不會幫助,因爲你看到空白...你可以嘗試上述選項之一來擺脫密碼提示,然後看看它是否工作。如果你仍然空白,那麼我們需要調查ajax調用。您是否無法進入您的網絡瀏覽器調試網絡選項卡並按下按鈕,請注意發送到服務器的鏈接並查看響應?

+0

我從config.php中刪除它,但仍然有空白頁!並仍然要求輸入密碼。 –

+0

順便說一句,當我打開'http://localhost/Atom/backend/web/index.php?r = reportico'時,密碼消失了。它沒有密碼打開儀表板。 –

+0

我得到了解決方案:它是在配置項目..我忘了添加主機名。或IP。 –

0

您可以使用網址幫手

use yii\helpers\Url; 


echo '<a href="' . Url:to(['/report/receipts']) . 
       '" type="button" class="btn btn-block btn-default">Receipts</a>'; 

可能是你應該設置相關

$engine->initial_report = Url:to(['/report/receipts']);  // Name of report to run 
+0

是的,我做的和鏈接工作正常..但網頁不能正常工作..報告我創建工作,但鏈接不工作..我會添加更多的圖片。 –

+0

請更好地解釋你的評論..你是什麼意思,「他報告我創造了工作,但鏈接沒有工作。」用相關的代碼和適當的信息更新問題 – scaisEdge

+0

安裝後Repotico有一些東西像儀表板,你可以創建一個項目和報告,你可以測試他們我創建了一個項目和報告,我測試它和它的工作在儀表板..之後有嵌入報告,這是我做的..然後有嵌入鏈接報告這是我的問題,我什麼都沒有。 –