]> ruin.nu Git - ndwebbie.git/blob - root/src/users/sms.tt2
21a611bbb5413adb8aad1d4c4f5b841763a5859a
[ndwebbie.git] / root / src / users / sms.tt2
1 [% META title = 'SMS' %]
2
3 <form action="postsms" method="post" id="sms"><fieldset class="forum-post">
4 <legend>New SMS</legend>
5         <p><span id="recadd">Receiver(s): </span><select name="uid" multiple size="5">
6 [% FOR u IN users %]
7                 <option value="[% u.uid %]" [% IF uid == u.uid %]selected[% END %]>[% u.username %]</option>
8 [% END %]
9                 </select></p>
10         <div id="receivers"></div>
11         <p>Message <input type="text" name="message" size="50" value=""></p>
12         <br>
13         <input type="submit" name="cmd" value="Submit">
14 </fieldset>
15 </form>
16
17 <table>
18         <tr><th>Sender</th><th>Receiver</th><th>Message</th><th>Cost</th><th>Status</th><th>Time</th></tr>
19 [% FOR s IN sms %]
20         <tr class="[% loop.count % 2 == 0 ? 'even' : 'odd' %]">
21                 <td>[% s.sender | html %]</td>
22                 <td>+[% s.number %] ([% s.receiver | html %])</td>
23                 <td>[% s.message | html %]</td>
24                 <td>[% s.cost %]</td>
25                 <td>[% s.status | html %]</td>
26                 <td>[% s.time %]</td>
27         </tr>
28 [% END %]
29 </table>
30
31 <script type="text/javascript">
32 $(document).ready(function(){
33         $('select').attr({name:'u', size: 1, multiple: null}).after($('<input type="button" id="add" value="Add">'));
34         $('#recadd').text('Users: ');
35         $('#receivers').append('Receiver(s):');
36
37         $('#add').click(function(){
38                 var u = $('option:selected');
39                 $('#receivers').append($('<p>'+u.text()+': <input type="checkbox" name="uid" checked value='+u.val()+'><\/p>'));
40         });
41
42         $('#sms').submit(function(){
43                 if(!$('#sms :checkbox[name=uid][checked]').val()){
44                         alert('You need to add a receiver.');
45                         return false;
46                 }
47                 if($('#sms :input[name=message]').val() == ''){
48                         alert('You need to write a message');
49                         return false;
50                 }
51         });
52 });
53 </script>