function sms_poll_export_csv($poll_id, $poll_keyword) { $ret = ''; // header $items = array(array(_('SMS poll keyword'), $poll_keyword)); $ret .= core_csv_format($items); unset($items); $ret .= "\n"; // statistics $stat = sms_poll_statistics($poll_id); $items = array(array(_('Senders sent once'), $stat['once']), array(_('Senders sent multiple votes'), $stat['multi']), array(_('Grand total senders'), $stat['sender']), array(_('Total one time vote SMS'), $stat['once_sms']), array(_('Total multiple votes SMS'), $stat['multi_sms']), array(_('Total valid SMS'), $stat['valid']), array(_('Total invalid SMS'), $stat['invalid']), array(_('Grand total SMS'), $stat['all'])); $ret .= core_csv_format($items); unset($items); $ret .= "\n"; // choices $data = unserialize(sms_poll_output_serialize($poll_id, $poll_keyword)); $items[0] = array(_('Choice keyword'), _('Description'), _('Number of votes')); $i = 1; foreach ($data['choices'] as $key => $val) { $items[$i] = array($key, $val, $data['results'][$key]); $i++; } $ret .= core_csv_format($items); unset($items); $ret .= "\n"; return $ret; }
$db_query = "SELECT * FROM " . _DB_PREF_ . "_featurePoll " . $query_user_only . " ORDER BY poll_id"; $db_result = dba_query($db_query); while ($db_row = dba_fetch_array($db_result)) { if ($owner = user_uid2username($db_row['uid'])) { $poll_status = "<a href=\"" . _u('index.php?app=main&inc=feature_sms_poll&op=sms_poll_status&poll_id=' . $db_row['poll_id'] . '&ps=1') . "\"><span class=status_disabled /></a>"; if ($db_row['poll_enable']) { $poll_status = "<a href=\"" . _u('index.php?app=main&inc=feature_sms_poll&op=sms_poll_status&poll_id=' . $db_row['poll_id'] . '&ps=0') . "\"><span class=status_enabled /></a>"; } $action = "<a href=\"" . _u('index.php?app=main&inc=feature_sms_poll&route=view&op=list&poll_id=' . $db_row['poll_id']) . "\">" . $icon_config['view'] . "</a> "; $action .= "<a href=\"" . _u('index.php?app=main&inc=feature_sms_poll&route=export&op=list&poll_id=' . $db_row['poll_id']) . "\">" . $icon_config['export'] . "</a> "; $action .= "<a href=\"" . _u('index.php?app=main&inc=feature_sms_poll&op=sms_poll_edit&poll_id=' . $db_row['poll_id']) . "\">" . $icon_config['edit'] . "</a> "; $action .= "<a href=\"javascript: ConfirmURL('" . _('Are you sure you want to delete SMS poll with all its choices and votes ?') . " (" . _('keyword') . ": " . $db_row['poll_keyword'] . ")','" . _u('index.php?app=main&inc=feature_sms_poll&op=sms_poll_del&poll_id=' . $db_row['poll_id']) . "')\">" . $icon_config['delete'] . "</a>"; if (auth_isadmin()) { $option_owner = "<td>{$owner}</td>"; } $stat = sms_poll_statistics($db_row['poll_id']); $i++; $content .= "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>" . $db_row['poll_keyword'] . "</td>\n\t\t\t\t\t\t<td>" . $db_row['poll_title'] . "</td>\n\t\t\t\t\t\t<td>" . $stat['once'] . "</td>\n\t\t\t\t\t\t<td>" . $stat['multi'] . "</td>\n\t\t\t\t\t\t<td>" . $stat['valid'] . "</td>\n\t\t\t\t\t\t<td>" . $stat['invalid'] . "</td>\n\t\t\t\t\t\t<td>" . $stat['all'] . "</td>\n\t\t\t\t\t\t" . $option_owner . "\n\t\t\t\t\t\t<td>{$poll_status}</td>\n\t\t\t\t\t\t<td>{$action}</td>\n\t\t\t\t\t</tr>"; } } $content .= "\n\t\t\t</tbody>\n\t\t\t</table>\n\t\t\t</div>\n\t\t\t" . _button('index.php?app=main&inc=feature_sms_poll&op=sms_poll_add', _('Add SMS poll')); _p($content); break; case "sms_poll_view": $db_query = "SELECT poll_keyword FROM " . _DB_PREF_ . "_featurePoll WHERE poll_id='{$poll_id}'"; $db_result = dba_query($db_query); $db_row = dba_fetch_array($db_result); $poll_keyword = $db_row['poll_keyword']; header("Location: " . _u('index.php?app=webservices&op=sms_poll&keyword=' . $poll_keyword)); exit; break;
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with playSMS. If not, see <http://www.gnu.org/licenses/>. */ defined('_SECURE_') or die('Forbidden'); if (!auth_isvalid()) { auth_block(); } $poll_id = $_REQUEST['poll_id']; switch (_OP_) { case 'list': $conditions['poll_id'] = $poll_id; $list = dba_search(_DB_PREF_ . '_featurePoll', '*', $conditions); $poll_keyword = $list[0]['poll_keyword']; $poll_access_code = $list[0]['poll_access_code']; $output_serialize = $core_config['http_path']['base'] . "/index.php?app=webservices&op=sms_poll&keyword=" . urlencode($poll_keyword) . "&code=" . $poll_access_code . "&type=serialize"; $output_json = $core_config['http_path']['base'] . "/index.php?app=webservices&op=sms_poll&keyword=" . urlencode($poll_keyword) . "&code=" . $poll_access_code . "&type=json"; $output_xml = $core_config['http_path']['base'] . "/index.php?app=webservices&op=sms_poll&keyword=" . urlencode($poll_keyword) . "&code=" . $poll_access_code . "&type=xml"; $output_html = $core_config['http_path']['base'] . "/index.php?app=webservices&op=sms_poll&keyword=" . urlencode($poll_keyword) . "&code=" . $poll_access_code . "&type=html"; $output_graph = $core_config['http_path']['base'] . "/index.php?app=webservices&op=sms_poll&keyword=" . urlencode($poll_keyword) . "&code=" . $poll_access_code . "&type=graph"; $stat = sms_poll_statistics($poll_id); if ($err = $_SESSION['error_string']) { $content = "<div class=error_string>{$err}</div>"; } $content .= "\n\t\t\t<h2>" . _('Manage poll') . "</h2>\n\t\t\t<h3>" . _('Keyword') . " : " . $poll_keyword . "</h3>\n\t\t\t\n\t\t\t<h3>" . _('Statistics') . "</h3>\n\t\t\t<table class=playsms-table>\n\t\t\t\t<tr><td class=label-sizer>" . _('Senders sent once') . "</td><td width=5>:</td><td>" . $stat['once'] . "</td></tr>\n\t\t\t\t<tr><td>" . _('Senders sent multiple votes') . "</td><td>:</td><td>" . $stat['multi'] . "</td></tr>\n\t\t\t\t<tr><td>" . _('Grand total senders') . "</td><td>:</td><td>" . $stat['sender'] . "</td></tr>\n\t\t\t\t<tr><td>" . _('Total one time vote SMS') . "</td><td>:</td><td>" . $stat['once_sms'] . "</td></tr>\n\t\t\t\t<tr><td>" . _('Total multiple votes SMS') . "</td><td>:</td><td>" . $stat['multi_sms'] . "</td></tr>\n\t\t\t\t<tr><td>" . _('Total valid SMS') . "</td><td>:</td><td>" . $stat['valid'] . "</td></tr>\n\t\t\t\t<tr><td>" . _('Total invalid SMS') . "</td><td>:</td><td>" . $stat['invalid'] . "</td></tr>\n\t\t\t\t<tr><td>" . _('Grand total SMS') . "</td><td>:</td><td>" . $stat['all'] . "</td></tr>\n\t\t\t</table>\n\n\t\t\t<h3>" . _('Result table') . "</h3>\n\t\t\t" . sms_poll_output_html($poll_id, $poll_keyword) . "\n\t\t\t\n\t\t\t<h3>" . _('Result graph') . "</h3>\n\t\t\t<img src=\"" . $output_graph . "\">\n\t\t\t\t\t\n\t\t\t<h3>" . _('Webservices links') . "</h3>\n\t\t\t<table class=playsms-table>\n\t\t\t\t<tr><td class=label-sizer>" . _('PHP serialize output') . "</td><td width=5>:</td><td><a href=\"" . _u($output_serialize) . "\" target=_blank>" . _u($output_serialize) . "</a></td></tr>\n\t\t\t\t<tr><td>" . _('JSON output') . "</td><td>:</td><td><a href=\"" . _u($output_json) . "\" target=_blank>" . _u($output_json) . "</a></td></tr>\n\t\t\t\t<tr><td>" . _('XML output') . "</td><td>:</td><td><a href=\"" . _u($output_xml) . "\" target=_blank>" . _u($output_xml) . "</a></td></tr>\n\t\t\t\t<tr><td>" . _('HTML output') . "</td><td>:</td><td><a href=\"" . _u($output_html) . "\" target=_blank>" . _u($output_html) . "</a></td></tr>\n\t\t\t\t<tr><td>" . _('Graph output') . "</td><td>:</td><td><a href=\"" . _u($output_graph) . "\" target=_blank>" . _u($output_graph) . "</a></td></tr>\n\t\t\t</table>"; $content .= '<p>' . _back('index.php?app=main&inc=feature_sms_poll&op=sms_poll_list'); _p($content); break; }