mirror of
https://github.com/Ekokumppanit/ystavakylaecard.git
synced 2026-01-26 03:04:00 +00:00
Manage added cards!
This commit is contained in:
@@ -37,6 +37,89 @@ class Yllapito extends CI_Controller
|
||||
$this->load->view('_footer', $data);
|
||||
}
|
||||
|
||||
public function ecards($section = 'list')
|
||||
{
|
||||
if (empty($this->user)) {
|
||||
redirect("/yllapito/kirjaudu");
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'page_title' => array( 'Ystäväkylä eKortti' ),
|
||||
'page_classes' => array( 'frontpage' ),
|
||||
'user' => $this->user,
|
||||
'count' => $this->card_count,
|
||||
'messages' => $this->session->flashdata('messages')
|
||||
);
|
||||
|
||||
$page_title = array();
|
||||
|
||||
switch ($section) {
|
||||
case 'save':
|
||||
$page = 'yllapito/list_cards';
|
||||
$post = $this->input->post();
|
||||
$from_page = $this->input->post('from_page');
|
||||
$post = $this->ecard->formatPost($post);
|
||||
|
||||
$save = false;
|
||||
if (! empty($post)) {
|
||||
$save = $this->ecard->saveCards($post);
|
||||
}
|
||||
|
||||
if (empty($save)) {
|
||||
$this->session->flashdata('message', 'Tallennus onnistui');
|
||||
$this->session->keep_flashdata('message');
|
||||
redirect($from_page);
|
||||
} else {
|
||||
$this->session->flashdata('message', 'Tallennus epäonnistui');
|
||||
$this->session->keep_flashdata('message');
|
||||
redirect($from_page);
|
||||
}
|
||||
break;
|
||||
case 'queue':
|
||||
$page = "yllapito/list_cards";
|
||||
$page_title[] = "Jonossa";
|
||||
$page_classes = array('admin', 'ecards', 'queue');
|
||||
$limit = $section;
|
||||
break;
|
||||
case 'public':
|
||||
$page = "yllapito/list_cards";
|
||||
$page_title[] = "Julkisia";
|
||||
$page_classes = array('admin', 'ecards', 'public');
|
||||
$limit = $section;
|
||||
break;
|
||||
case 'private':
|
||||
$page = "yllapito/list_cards";
|
||||
$page_title[] = "Yksityisiä";
|
||||
$page_classes = array('admin', 'ecards', 'private');
|
||||
$limit = $section;
|
||||
break;
|
||||
case 'hidden':
|
||||
$page = "yllapito/list_cards";
|
||||
$page_title[] = "Piilotetut";
|
||||
$page_classes = array('admin', 'ecards', 'hidden');
|
||||
$limit = $section;
|
||||
break;
|
||||
default:
|
||||
$page = "yllapito/list_cards";
|
||||
$page_title[] = "Kaikki";
|
||||
$limit = null;
|
||||
$page_classes = array('admin', 'ecards', 'list_all');
|
||||
break;
|
||||
}
|
||||
|
||||
if (empty($limit)) {
|
||||
$data['cards'] = $this->ecard->order_by('created_at')->get_all();
|
||||
} else {
|
||||
$data['cards'] = $this->ecard->order_by('created_at')->get_many_by('card_status', $limit);
|
||||
}
|
||||
|
||||
$data['page_title'] = array_merge($page_title, $data['page_title']);
|
||||
|
||||
$this->load->view('_header', $data);
|
||||
$this->load->view($page, $data);
|
||||
$this->load->view('_footer', $data);
|
||||
}
|
||||
|
||||
public function kirjaudu()
|
||||
{
|
||||
// POST
|
||||
|
||||
@@ -3,19 +3,61 @@
|
||||
<div class="large-12 columns">
|
||||
<div class="panel">
|
||||
<?php
|
||||
if( $ecard and $ecard->response == "200" ) {
|
||||
?>
|
||||
<h2>Postikortti #<?php echo $ecard->id;?></h2>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
if (empty($ecard)) {
|
||||
$ecard = new stdClass();
|
||||
}
|
||||
|
||||
if ($ecard and $ecard->response == "200") {
|
||||
|
||||
|
||||
$time = date("d.m.Y \k\l\o H.i", strtotime($ecard->created_at));
|
||||
|
||||
?>
|
||||
<img src="<?php echo site_url('assets/cards/' . $ecard->hash . '.png'); ?>" width="100%">
|
||||
|
||||
<h2><?php echo $ecard->message_title; ?></h2>
|
||||
<p>
|
||||
<?php echo nl2br($ecard->message_content); ?>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<?php
|
||||
if ($ecard->card_status == "queue") { ?>
|
||||
<div data-alert class="alert-box">
|
||||
Tämä kortti on vielä ylläpidon jonossa, eikä se näy kuin linkkiä seuraamalla.<br>
|
||||
<?php
|
||||
if ($ecard->private == "yes") { ?>
|
||||
Koska valitsit että korttia ei saa julkaista,
|
||||
ei ylläpitokaan sitä pysty lisäämään sivuston "Listaa kaikki"-osioon.
|
||||
<?php
|
||||
} else { ?>
|
||||
Kun ylläpito on tarkastanut kortin, päätetään voidaanko korttia julkaista "Listaa kaikki"-osioon.
|
||||
<?php
|
||||
}
|
||||
?></div><?php
|
||||
}
|
||||
?>
|
||||
|
||||
<p>
|
||||
<ul style="list-style: none">
|
||||
<li>Lähettäjä: <?php echo $ecard->uploader_name; ?></li>
|
||||
<li>Vastaanottaja: <?php echo $ecard->receiver_name; ?></li>
|
||||
<li>Koska lähetetty: <?php echo $time; ?></li>
|
||||
<li>Osoite tähän korttiin: <code><?php echo site_url('ecards/' . $ecard->hash); ?></code></li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<h2>Tunnuksella ei löytynyt ainuttakaan korttia</h2>
|
||||
<p>Sähköpostikortti on joko poistettu järjestelmästä, tai sitten seurasit rikkinäistä linkkiä.</p>
|
||||
<p></p>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<pre><?php var_export($ecard); ?></pre>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,6 +2,58 @@
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<div class="panel">
|
||||
<?php
|
||||
$all = $count->all;
|
||||
|
||||
// Percentages
|
||||
if ($all > 0) {
|
||||
$p_queue = round($count->queue/$all*100, 2);
|
||||
$p_public = round($count->public/$all*100, 2);
|
||||
$p_private = round($count->private/$all*100, 2);
|
||||
$p_hidden = round($count->hidden/$all*100, 2);
|
||||
}
|
||||
?>
|
||||
|
||||
<h2>Tilastot</h2>
|
||||
Kortteja yhteensä tietokannassa: <?php echo $all; ?> kpl.
|
||||
<div class="progress large-12">
|
||||
<?php
|
||||
if ($p_queue > 0) { ?>
|
||||
<span data-tooltip
|
||||
class="has-tip left queue meter"
|
||||
data-width="210"
|
||||
title="Kortteja jonossa <?=$count->queue; ?> kpl"
|
||||
style="width: <?=$p_queue;?>%"></span>
|
||||
<?php
|
||||
}
|
||||
if ($p_public > 0) { ?>
|
||||
<span data-tooltip
|
||||
class="has-tip left public meter"
|
||||
data-width="210"
|
||||
title="Kortteja julkaistuna <?=$count->public; ?> kpl"
|
||||
style="width: <?=$p_public;?>%"></span>
|
||||
<?php
|
||||
}
|
||||
if ($p_private > 0) { ?>
|
||||
<span data-tooltip
|
||||
class="has-tip left private meter"
|
||||
data-width="210"
|
||||
title="Kortteja piilotettuna <?=$count->private; ?> kpl"
|
||||
style="width: <?=$p_private;?>%"></span>
|
||||
<?php
|
||||
}
|
||||
if ($p_hidden > 0) { ?>
|
||||
<span data-tooltip
|
||||
class="has-tip left hidden meter"
|
||||
data-width="210"
|
||||
title="Poistettuja kortteja <?=$count->hidden; ?> kpl"
|
||||
style="width: <?=$p_hidden;?>%"></span>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
<pre><?php
|
||||
|
||||
if (empty($user)) {
|
||||
|
||||
139
application/views/yllapito/list_cards.php
Normal file
139
application/views/yllapito/list_cards.php
Normal file
@@ -0,0 +1,139 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<div class="panel">
|
||||
|
||||
<?php
|
||||
$message = $this->session->flashdata('message');
|
||||
if (empty($message)) {
|
||||
$message = array();
|
||||
}
|
||||
if (! empty($message)) { ?>
|
||||
<div data-alert class="alert-box <?php echo $message?>">
|
||||
<?php echo $message;?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<dl class="sub-nav">
|
||||
<dt>Näytä:</dt>
|
||||
<dd><?= lnk("yllapito/ecards", "Kaikki {$count->all}"); ?></dd>
|
||||
<dd><?= lnk("yllapito/ecards/queue", "Jonossa {$count->queue}"); ?></dd>
|
||||
<dd><?= lnk("yllapito/ecards/public", "Julkiset {$count->public}"); ?></dd>
|
||||
<dd><?= lnk("yllapito/ecards/private", "Yksityiset {$count->private}"); ?></dd>
|
||||
<dd><?= lnk("yllapito/ecards/hidden", "Hylätyt {$count->hidden}"); ?></dd>
|
||||
</dl>
|
||||
|
||||
<form action="<?php echo site_url("yllapito/ecards/save");?>" method="post" accept-charset="utf-8">
|
||||
<input type="hidden" name="from_page" value="<?php echo current_url();?>">
|
||||
<input type="hidden" name="page" value="<?php echo current_url();?>">
|
||||
<table id="cardlist" class="valign">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="130">Koska lähetetty</th>
|
||||
<th width="150">Kortti</th>
|
||||
<th>Tiedot</th>
|
||||
<th>Viesti</th>
|
||||
<th width="160">Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<?php
|
||||
|
||||
if (!empty($cards)) {
|
||||
foreach ($cards as $card) {
|
||||
$i = $card->id;
|
||||
|
||||
?>
|
||||
<tr class="valign-top">
|
||||
<td class="center valign"><?php echo date("j.n.Y H.i", strtotime($card->created_at)); ?></td>
|
||||
<td><img src="<?php echo site_url('assets/cards/' . $card->hash . '.png'); ?>" alt="">
|
||||
<span class="label"><?php
|
||||
if ($card->email_sent == 'no') {
|
||||
echo "Korttia ei vielä lähetetty";
|
||||
} else {
|
||||
echo "Kortti lähetetty";
|
||||
}
|
||||
|
||||
?></span>
|
||||
</td>
|
||||
<td><strong>Lähettäjä</strong><br>
|
||||
<?= $card->uploader_name; ?><br>
|
||||
<?= $card->uploader_email; ?><br><br>
|
||||
|
||||
<strong>Vastaanottaja</strong><br>
|
||||
<?= $card->receiver_name; ?><br>
|
||||
<?= $card->receiver_email; ?><br><br>
|
||||
</td>
|
||||
<td><!-- Message -->
|
||||
<strong><?= $card->message_title; ?></strong><br>
|
||||
<?php
|
||||
if (count(explode(" ", $card->message_content)) < 21) {
|
||||
?>
|
||||
<?php echo $card->message_content; ?>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<span data-tooltip
|
||||
class="has-tip tip-top"
|
||||
data-width="380"
|
||||
title="<?= $card->message_content; ?>"
|
||||
><?= word_limiter($card->message_content, 20); ?></span>
|
||||
<?php
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</td>
|
||||
<td><!-- Status -->
|
||||
<?php echo "\n";
|
||||
|
||||
$checkboxes = array(
|
||||
'queue' => 'Jonossa',
|
||||
'public' => 'Julkaise',
|
||||
'private' => 'Piilota',
|
||||
'hidden' => 'Hylkää'
|
||||
);
|
||||
|
||||
|
||||
foreach ($checkboxes as $value => $label) {
|
||||
|
||||
$private = false;
|
||||
|
||||
// Can't make private cards public
|
||||
if ($value == "public") {
|
||||
$private = ($card->private == "yes") ? true : false;
|
||||
}
|
||||
|
||||
echo str_repeat(" ", 28)
|
||||
. checkboxed(
|
||||
'card_status',
|
||||
$card->card_status,
|
||||
$value,
|
||||
$label,
|
||||
$card->id,
|
||||
$private
|
||||
). "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<input type="submit" name="" class="button success" value="Tallenna muutokset">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -8,6 +8,8 @@ html {
|
||||
body {
|
||||
color: #333;
|
||||
background: transparent url('../img/headerbg2.png') top center no-repeat;
|
||||
font-family: 'Open Sans', sans-serif;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
body footer {
|
||||
@@ -43,6 +45,19 @@ table.valign thead tr,
|
||||
table thead th button {
|
||||
margin: 0px;
|
||||
}
|
||||
#cardlist td label {
|
||||
display: block;
|
||||
}
|
||||
#cardlist td label input {
|
||||
margin-right: 10px;
|
||||
padding: 0px;
|
||||
margin-bottom: 0px !important;
|
||||
}
|
||||
|
||||
#cardlist img {
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
|
||||
.center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user