minor changes in db queries

problem with main frame loading from db (Q1 condition unclear)
This commit is contained in:
Nael 2014-02-13 14:53:18 +01:00
parent 4c28d3890e
commit cb9a202f3b
8 changed files with 71 additions and 26 deletions

View File

@ -6,6 +6,11 @@ class api_uvote extends \SYSTEM\API\api_login {
}
public static function call_vote_action_new_vote($ID, $title, $iframe_link) {
return votes::write_poll($ID, $title, $iframe_link);
}
public static function call_vote_action_feedback($feedback) {
return votes::write_feedback($feedback);

View File

@ -61,6 +61,13 @@ class votes {
return $return_as_json ? JsonResult::toString($result) : $result;
}
public static function get_all_votes(){
$res = \DBD\UVOTE_DATA_ALL_VOTES::Q1();
$votes = mysql_query($res);
$result = mysql_num_rows($votes);
return $result;
}
public static function get_bar_bt_per_poll($poll_ID){
return \DBD\UVOTE_DATA_BT_PER_POLL::Q1(array($poll_ID));}
@ -98,6 +105,15 @@ class votes {
return JsonResult::ok();
}
public static function write_poll($ID, $title, $iframe_link ){
$con = new \SYSTEM\DB\Connection(new \DBD\uVote());
$res = $con->prepare( 'insertPoll',
'INSERT INTO uvote_votes
VALUES (?, ?, ?);',
array($ID, $title, $iframe_link));
return JsonResult::ok();
}
public static function write_feedback($feedback){
if(!\SYSTEM\SECURITY\Security::isLoggedIn()){
throw new ERROR("You need to be logged in.");}

View File

@ -1,8 +1,7 @@
<div class="row" style="margin: 0;">
<div class="span6" style="width: 50%;">
<h4>${title}</h4>
<iframe src="${iframe_link}" width="730" height="580"></iframe>
<iframe src="${iframe_link}" width="730" height="650"></iframe>
</div>
</div>

View File

@ -3,8 +3,16 @@
class user_main extends SYSTEM\PAGE\Page {
public function get_main_uVote(){
return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_uVote/uVote.tpl'), array());}
private static function user_all_votes(){
$result = '';
$res = votes::get_all_votes($result);
return $result;
}
public function html(){
$vars = array();
// $vars['votes_all'] = $this->user_all_votes();
$vars['uVote'] = $this->get_main_uVote();
$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(SYSTEM\SERVERPATH(new PPAGE(),'user_main/main_menu.tpl'),$vars);

View File

@ -1,3 +1,4 @@
${votes_all}
<img src="${frontend_logos}logo2.png"/>
<form>
<br />

View File

@ -14,12 +14,17 @@ class user_main_uVote extends SYSTEM\PAGE\Page {
return $pbpp;
}
private static function user_all_votes(){
$res = votes::get_all_votes();
return $res;
}
public function html(){
$poll_data = array();
$poll_data[] = DBD\UVOTE_DATA_CHOICE_OVERALL::Q1(array(1));
$poll_data[] = DBD\UVOTE_DATA_CHOICE_OVERALL::Q1(array(2));
$poll_data[] = DBD\UVOTE_DATA_CHOICE_OVERALL::Q1(array(3));
$vars['votes_overall'] = $this->votes_overall();
$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(SYSTEM\SERVERPATH(new PPAGE(),'user_main_uVote/uVote.tpl'),$vars);
}

View File

@ -1,8 +1,9 @@
<input type="text" id="vote_title" placeholder="${vote_title}"/>
<input type="text" id="iframe_link" placeholder="${iframe_link}"/>
<input type="text" id="poll_ID" placeholder="${poll_ID}"/>
<br>
<br>
<h4>Eingebracht durch</h4>
<!-- <h4>Eingebracht durch</h4>
<label><input type="checkbox" id="checkbox_breg" style="margin-top: -1px;">BReg</label>
<label><input type="checkbox" id="checkbox_cdu" style="margin-top: -1px;">CDU</label>
<label><input type="checkbox" id="checkbox_csu" style="margin-top: -1px;">CSU</label>
@ -33,7 +34,7 @@
<label><input type="checkbox" id="checkbox_Verteidigungspolitik" style="margin-top: -1px;">Verteidigungspolitik</label>
<label><input type="checkbox" id="checkbox_Wirtschaftspolitik" style="margin-top: -1px;">Wirtschaftspolitik</label>
<label><input type="checkbox" id="checkbox_Europapolitik" style="margin-top: -1px;">Europapolitik</label>
-->
@ -42,7 +43,7 @@
<h4>poll end</h4>
<input type="text" placeholder="JJJJ-TT-MM"/> - 00:00
<div id="user_main" style="border: 2px solid #ccc; right: 0px; position: fixed; padding: 0px; padding-right: 10px; width: 35%; top: 50px; bottom: 50px; overflow-y: scroll;">
<!-- <div id="user_main" style="border: 2px solid #ccc; right: 0px; position: fixed; padding: 0px; padding-right: 10px; width: 35%; top: 50px; bottom: 50px; overflow-y: scroll;">
<div style="margin-right: 10px;">
<img src="${frontend_logos}logo2.png" style="float: right" height="100%" width="200px"/>
<h5>Auf einen Blick</h5>
@ -69,6 +70,6 @@
poll_ID="${poll_ID}"><font
size="3">Enthaltung</font></a>
</div>
</div>
</div> -->
<br>
<a class="btn btn-primary" id="vote_data_submit">Submit</a>

View File

@ -1,28 +1,38 @@
function init_saimod_uvote_vote_edit(){
$('#vote_data_submit').click(function() {
var data = new Array();
alert("bla")
$.ajax({
url: SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_uvote_vote_edit&action='+ vote,
contentType : "application/json; charset=utf-8",
vote : JSON.stringify({
sai_mod: 'saimod_uvote_vote_edit',
action: 'new_vote',
json: data,
}),
dataType : 'json',
type : 'POST' ,
success: function(vote) {
alert("success");
}});
alert("js läuft");
$('#vote_data_submit').click(function() {
alert ('bla');
vote_data_edit(array(
$('#vote_title').val(title),
$('#iframe_link').val(iframe_link),
$('#poll_ID').val(poll_ID)
));
alert ('');
// var data = new Array();
// alert("bla")
// $.ajax({
// url: SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_uvote_vote_edit&action='+ vote,
// contentType : "application/json; charset=utf-8",
// vote : JSON.stringify({
// sai_mod: 'saimod_uvote_vote_edit',
// action: 'new_vote',
// json: data,
// }),
// dataType : 'json',
// type : 'POST' ,
// success: function(vote) {
// alert("success");
// }});
// alert("js läuft");
})};
function vote_data_edit (poll_ID, vote) {
$.getJSON('./api.php?call=vote&action=vote&poll_ID=' + poll_ID, function(data) {
function vote_data_edit (poll_ID, title, iframe_link) {
$.getJSON('./api.php?call=vote&action=vote&poll_ID=' + poll_ID + 'title=' + title + '&iframe_link=' + iframe_link, function(data) {
var items = [];
if(data.status == true){
alert("success");