uvote backend
This commit is contained in:
parent
dd4fcffb82
commit
5ad249b27b
@ -1,4 +1,3 @@
|
||||
<?php
|
||||
SYSTEM\autoload::registerFolder(dirname(__FILE__).'','');
|
||||
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_uvote_vote_edit','');
|
||||
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_uvote_data_input','');
|
||||
|
||||
@ -1,3 +1,2 @@
|
||||
<?php
|
||||
\SYSTEM\SAI\sai::register('saimod_uvote_vote_edit');
|
||||
\SYSTEM\SAI\sai::register('saimod_uvote_data_input');
|
||||
\SYSTEM\SAI\sai::register('saimod_uvote_vote_edit');
|
||||
@ -1,5 +0,0 @@
|
||||
<button id="realm_start" class="btn">(re)start realm</button>
|
||||
<button id="realm_stop" class="btn">stop realm</button>
|
||||
</br></br>
|
||||
<button id="world_start" class="btn">(re)start world</button>
|
||||
<button id="world_stop" class="btn">stop world</button>
|
||||
@ -1,20 +0,0 @@
|
||||
function init_saimod_uvote_data_input(){
|
||||
|
||||
$('#vote_data_submit').click(function (poll_ID) {
|
||||
//vote_click($(this).attr('poll_ID'));
|
||||
alert("doc ready works")
|
||||
vote_data_submit($(this).attr('poll_ID'));
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
function vote_data_submit (poll_ID, vote) {
|
||||
$.getJSON('./api.php?call=vote&action=vote&poll_ID=' + poll_ID, function(data) {
|
||||
var items = [];
|
||||
if(data.status == true){
|
||||
alert("success");
|
||||
} else {
|
||||
alert(data.result.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
<?php
|
||||
class saimod_uvote_data_input extends \SYSTEM\SAI\SaiModule {
|
||||
|
||||
public static function sai_mod__SYSTEM_SAI_saimod_uvote_data_input_action_add($poll_ID, $title, $text, $p_fields, $time_start, $time_end){
|
||||
$con = new \SYSTEM\DB\Connection(new \DBD\uVote());
|
||||
$res = null;
|
||||
$res = $con->prepare('addText' ,'INSERT INTO uvote_votes (poll_ID, title, text, p_fields, time_start, time_end) VALUES (?1, ?2, ?3, ?4, ?5, ?6);', array($poll_ID));
|
||||
return $res->affectedRows() == 0 ? \SYSTEM\LOG\JsonResult::error(new \SYSTEM\LOG\WARNING("no data added")) : \SYSTEM\LOG\JsonResult::ok();
|
||||
}
|
||||
|
||||
public function saimod_uvote_data_input(){
|
||||
$vars = array();
|
||||
return \SYSTEM\PAGE\replace::replaceFile(dirname(__FILE__).'/main.tpl', $vars);}
|
||||
|
||||
public static function html_li_menu(){return '<li><a href="#" saimenu="saimod_uvote_data_input">data completion</a></li><li class="divider"></li>';}
|
||||
public static function right_public(){return false;}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
public static function sai_mod_saimod_uvote_data_input_flag_js(){return \SYSTEM\LOG\JsonResult::toString(array(
|
||||
\SYSTEM\WEBPATH(new PSAI(),'saimod_uvote_data_input/saimod_uvote_data_input.js')
|
||||
));}
|
||||
public static function sai_mod_saimod_uvote_data_input_flag_css(){}
|
||||
}
|
||||
@ -15,11 +15,38 @@ class saimod_uvote_vote_edit extends \SYSTEM\SAI\SaiModule {
|
||||
}
|
||||
|
||||
public static function sai_mod_saimod_uvote_vote_edit(){
|
||||
$vars = array();
|
||||
/*$vars = array();
|
||||
$vars['frontend_logos'] = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL).'api.php?call=img&cat=frontend_logos&id=';
|
||||
return \SYSTEM\PAGE\replace::replaceFile(dirname(__FILE__).'/main.tpl', $vars);}
|
||||
return \SYSTEM\PAGE\replace::replaceFile(dirname(__FILE__).'/main.tpl', $vars);*/
|
||||
|
||||
public static function html_li_menu(){return '<li><a href="#" saimenu="saimod_uvote_vote_edit">votemask</a></li><li class="divider"></li>';}
|
||||
$result = '';
|
||||
$votes = votes::getAllVotesOfGroup(1);
|
||||
foreach($votes as $vote){
|
||||
$time_remain = strtotime($vote['time_end'])- microtime(true);
|
||||
$time_span = strtotime($vote['time_end']) - strtotime($vote['time_start']);
|
||||
$vote['vote_class'] = self::tablerow_class(votes::getUserPollData($vote['ID']));
|
||||
$vote['bt_vote_class'] = self::tablerow_class($vote['bt_choice']);
|
||||
$vote['time_left'] = round($time_remain/($time_span+1)*100,0);
|
||||
$vote['time_done'] = 100-$vote['time_left'];
|
||||
$result .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_uvote_vote_edit/vote.tpl'), $vote);
|
||||
}
|
||||
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_uvote_vote_edit/saimod_uvote_vote_edit.tpl'), array('list' => $result));
|
||||
}
|
||||
|
||||
private static function tablerow_class($choice){
|
||||
switch($choice){
|
||||
case 1:
|
||||
return 'pro';
|
||||
case 2:
|
||||
return 'contra';
|
||||
case 3:
|
||||
return 'ent';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
public static function html_li_menu(){return '<li><a href="#" saimenu="saimod_uvote_vote_edit">Edit Votes</a></li><li class="divider"></li>';}
|
||||
public static function right_public(){return false;}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
public static function sai_mod_saimod_uvote_vote_edit_flag_js(){return \SYSTEM\LOG\JsonResult::toString(array(
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
<table style="margin-bottom: 5px; width: 95%; border: solid lightgray 1px; background: beige;">
|
||||
${list}
|
||||
</table>
|
||||
32
uVote/sai/saimod_uvote_vote_edit/vote.tpl
Normal file
32
uVote/sai/saimod_uvote_vote_edit/vote.tpl
Normal file
@ -0,0 +1,32 @@
|
||||
<tr style="border: solid lightgray 1px;">
|
||||
<td style="padding: 5px;">
|
||||
${title}
|
||||
</td>
|
||||
<td>
|
||||
Nr.${ID}
|
||||
</td>
|
||||
<td>
|
||||
<a class="btn btn-primary btn-small btn_editvote" style="float:right" poll_ID="${ID}">Edit</a>
|
||||
</td>
|
||||
<td class="${bt_vote_class}" style="width: 80px; margin-top: 10px; border-left: 1px solid lightgray;">
|
||||
cdu<span class="badge badge-success" style="float:right;">123</span><br/>
|
||||
csu<span class="badge badge-important" style="float:right;">123</span><br/>
|
||||
spd<span class="badge" style="float:right;">123</span><br/>
|
||||
grüne<span class="badge badge-success" style="float:right;">123</span><br/>
|
||||
linke<span class="badge badge-important" style="float:right;">123</span>
|
||||
</td>
|
||||
<td class="" style="width: 30px; margin-top: 10px; border-left: 1px solid lightgray;">
|
||||
uv
|
||||
<span class="badge badge-success" style="float:right;">123</span>
|
||||
<span class="badge badge-important" style="float:right;">123</span>
|
||||
<span class="badge" style="float:right;">123</span>
|
||||
</td>
|
||||
<td class="${vote_class}" style="width: 20px; margin-top: 10px; border-left: 1px solid lightgray;">
|
||||
</td>
|
||||
<td style="margin: 0; padding: 0; width: 3px;" >
|
||||
<table class="poll_time" time="${time_end}" style="width: 100%; height: 100%; margin: 0; padding: 0;">
|
||||
<tr id="time_done" style="height: ${time_done}%; background: white; margin: 0; padding: 0;"><td style="width: 1px; margin: 0; padding: 0;"></td></tr>
|
||||
<tr id="time_left" style="height: ${time_left}%; background: blue; margin: 0; padding: 0;"><td style="width: 1px; margin: 0; padding: 0;"></td></tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
Loading…
x
Reference in New Issue
Block a user