root/trunk/app/views/messages/admin_listing.ctp

Revision 827, 3.9 kB (checked in by aarkerio, 5 weeks ago)

Models extendend

Line 
1<?php
2//die(debug($data));
3 echo $html->addCrumb('Control Panel', '/admin/entries/start'); 
4 echo $html->getCrumbs(' / ');
5
6 echo $html->para(null,$html->link($html->image('admin/compose_on.gif', array('alt'=>__('Compose new message', true), 'title'=>__('Compose new message', true))), '/admin/messages/add', null, false, false));
7
8if ( $session->read('Auth.User.group_id') == 1): // if user belongs to admin group
9   echo '<div style="position:absolute;right:300px;top:75px;">';
10   echo $html->link($html->image('admin/message_board.gif', array('alt'=>'General Message', 'title'=>'General Message')), '/admin/messages/general', null, false, false);
11   echo '</div>';
12endif;
13
14echo $form->create('Message', array('action'=>'delete', 'onsubmit'=>'return chkList();', 'name'=>'privmsg_list'));
15//echo $form->hidden('Message.several', array('value'=>1));
16//exit(print_r($data));
17
18$th = array(__('Flag', true), __('Subject', true), __('From', true), __('Date', true), __('Mark', true));
19echo '<table class="tbadmin">';
20echo $html->tableHeaders($th, array('style'=>'text-align:center'));
21
22foreach ($data as $val):
23  switch ($val['Message']['status'])
24  {
25           case 0:
26                $status = __('New', true);
27                $img    = 'message_n.gif';
28                break;
29           case 1:
30                $status = __('Readed', true);
31                $img    = 'message_r.gif';
32                break;
33           case 2:
34                $status = __('Reply', true);
35                $img    = 'message_e.gif';
36                break;
37  }
38
39  $tr = array(
40        $html->link($html->image('admin/'.$img, array('alt'=>$status,'title'=>$status)),'/admin/messages/display/'.$val['Message']['id'], null, null, false),
41        $html->link($val['Message']['title'], '/admin/messages/display/'.$val['Message']['id']),
42        $val['User']['username'],
43        $val['Message']['created'] . "\n",
44        $form->checkbox('Message.id'.$val['Message']['id'], array('value'=>$val['Message']['id'], 'id'=>'fieldid'.$val['Message']['id']))
45        );
46       
47   echo $html->tableCells($tr, array("class"=>"altRow", "onmouseover"=>"this.className='highlight'", "onmouseout"=>"this.className='altRow'"),
48                                array('class'=>'evenRow',"onmouseover"=>"this.className='highlight'", "onmouseout"=>"this.className='evenRow'"));
49   
50endforeach;
51 
52echo '<tr><td colspan="5" style="text-align:right">';
53 
54 if ( count($data) > 0 ):
55    echo $html->link(__('Mark all', true), "javascript:select_switch(true)", array('style'=>'font-size:7pt')) . ' | ';
56    echo $html->link(__('Unmark all', true), "javascript:select_switch(false)", array('style'=>'font-size:7pt')) . '<br /><br />';
57    echo $form->end(__('Delete marked', true));
58 endif;
59?>
60</form>
61</td></tr>
62</table>
63<?php
64$t  = $html->div(null,$paginator->prev('« '.__('Previous', true),null,null,array('class'=>'disabled')),array('style'=>'width:100px;float:left'));
65$t .= $html->div(null,$paginator->next(__('Next', true).' »', null, null, array('class' => 'disabled')),array('style'=>'width:100px;float:right'));
66$t .= $html->div(null,$paginator->counter(), array('style'=>'width:200px;float:center'));
67 echo  $html->div(null,$t, array('style'=>'font-size:9pt;width:400px;margin:15px auto;'));
68?>
69<script language="Javascript" type="text/javascript">
70    //
71    // Should really check the browser to stop this whining ...
72    //
73    function select_switch(status)
74    {
75        for (i = 0; i < document.privmsg_list.length; i++)
76        {
77            document.privmsg_list.elements[i].checked = status;
78        }
79    }
80   
81    function chkList()
82    {   
83        var j = 0;
84        for (i = 0; i < document.privmsg_list.length; i++)
85    {
86        if (document.privmsg_list.elements[i].checked == true)
87            {
88                j++;
89            }
90    }
91        //alert('Inside '+ j);
92       
93        if (j == 0 )
94        {
95            alert('<?php __('You must select at least one message');?>');
96            return false;
97        }
98       
99        return true;
100    }
101</script>
Note: See TracBrowser for help on using the browser.