Now I made slight progress:
I created the actions:
Code:
$this->subscribe('beforeToolsMenuRender');
$this->subscribe('pTsIndex');
$this->subscribe('pTsCreate');
When I click the Menu Entry, the action "pTsIndex" works fine. This is for getting a form to enter the wanted number of new created tokens.
Code:
public function pTsIndex($surveyId)
{
if (!Permission::model()->hasSurveyPermission($surveyId, 'tokens', 'read')) {
throw new CHttpException(403, gT("You do not have permission to access this page."));
}
$surveyId = (int) $surveyId;
$survey = Survey::model()->findByPk($surveyId);
$tkcount = Token::model($surveyId)->count();
if (!$survey->hasTokensTable) {
// If no tokens table exists
$this->newtokentable($iSurveyId);
}
Yii::app()->loadHelper("surveytranslator");
if ($survey->hasTokensTable) {
$content = "There are a lot of Tokens in the database for this survey<br/>
<label for='ssid' class='control-label'>Umfrage-ID</label>
<input type='text' class='form-control' id='ssid' name='ssid' placeholder='$surveyId' readonly>
<label for='stitle' class='control-label'>Titel</label>
<input type='text' class='form-control' id='stitle' name='stitle' readonly>
<label for='count_tokens' class='control-label'>Anzahl TANs</label>
<input type='text' class='form-control' id='scount_tokens' name='scount_tokens' placeholder='$tkcount' readonly>
<label for='count_tokens' class='control-label'>Anfang</label>
<input type='text' class='form-control' id='sstartdate' name='sstartdate' readonly>
<label for='count_tokens' class='control-label'>Ende</label>
<input type='text' class='form-control' id='sexpires' name='sexpires' readonly>
<form id='tokenForm' action='pluginhelper?sa=printAction&surveyId=$surveyId'>
<input type='text' class='form-control' id='stokencount' name='stokencount' placeholder='Anzahl'>
<input type='submit' id='stokenButton' class='btn btn-primary'>Create Tokens</button>
</form>";
} if( isset($_POST['button']) )
{ $content = "ELSE TEST";
}
return $content;
}
The action "pTsCreate" works fine at the moment, it creates the given Number of Tokens. The next step is to create the QR codes in the PDF.
Code:
public function pTsCreate($surveyId)
{
if (!Permission::model()->hasSurveyPermission($surveyId, 'tokens', 'read')) {
throw new CHttpException(403, gT("You do not have permission to access this page."));
}
$surveyId = (int) $surveyId;
$stokencount = $_GET["stokencount"];
for ($i = 0; $i < $stokencount; $i++) {
$oToken = Token::create($surveyId);
$oToken->setAttributes(Yii::app()->getRequest()->getParam('tokenattribute'));
//$resultToken = $oToken->save();
$oToken->generateToken();
$oToken->save();
}
return "It works:
$surveyId
$stokencount
$oToken->token";
}
Now the question:
I use "admin/pluginhelper" for menu creation. So it works to get on the "public function pTsIndex"-part but when clicking the <form>-Button I cant get it work to send the $surveyId & $stokencount to the function "pTsCreate" - any ideas?