[eluser]Unknown[/eluser]
I am trying to pass some values(ticket_id) from view page to controller using hidden fields of form and according to that ticket_id corresponding page is displayed. this part is working fine but the problem is when I am refreshing the page I am unable to store that ticket_id in the controller and in my view page nothing is displayed.
I tried session but its not working..
here is my first view page..
Code:
<style type="text/css">
table {
margin:0 auto;
font-size: 12px;
}
td {
padding:.5em 1em;
border:2px solid #e2e2e2;
}
th{
font-size: 14px;
text-decoration: bold;
text-align: center;
}
</style>
[removed]
$(function(){
$('tr:odd').css("background-color","#e2e2e2");
});
[removed]
<?php $count=Template::get('count'); ?>
<?php if($count > 0) : ?>
<h2>Here are your tickets </h2>
<table name = "ticket_table" id = "myTickets">
<tr>
<th>Title</th>
<th>Category</th>
<th>Priority</th>
<th>Date Of Post</th>
<th>Status</th>
</tr>
<?php foreach($result->result_array() as $ticketRow) : ?>
<tr>
<td><?php echo word_wrap($ticketRow['title'],15); ?></td>
<td><?php echo $ticketRow['category']; ?></td>
<td><?php echo $ticketRow['priority']; ?></td>
<td><?php echo $ticketRow['date']; ?></td>
<td><?php echo $ticketRow['post_status']; ?></td>
<td><?php echo form_open('/helpdesk/full_post_view'); ?>
<?php echo form_hidden('ticket_id',$ticketRow['id']); ?>
<?php echo form_hidden('post_content',$ticketRow['post_content']); ?>
<?php echo form_submit('submit', 'Full View'); ?>
<?php echo form_close(); ?></td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
here is my controller code :-
Code:
function full_post_view(){
$data= array(
'ticket_id' => $this->input->post('ticket_id'),
'post_content' => $this->input->post('post_content')
);
session_start();
$this->session->set_userdata($data);
$ticket_id = ($this->input->post('ticket_id')) ? $this->input->post('ticket_id') : $this->session->userdata('ticket_id');
// $post_content = ($this->input->post('post_content')) ? $this->input->post('post_content') : $this->session->userdata('post_content');
$post_content = ($this->input->post('post_content'));
$this->load->model('helpdesk_model');
$all_comments = $this->helpdesk_model->fetchComments($ticket_id);
$is_post_closed = $this->helpdesk_model->fetchPostStatus($ticket_id);
if($all_comments->num_rows > 0) {
foreach ($all_comments->result() as $comments_value) {
$comments = $comments_value->comments;
}
$count=1;
Template::set('all_comments',$all_comments);
Template::set_view('helpdesk/full_post_view');
}
else {
$count=0;
Template::set('post_content',$this->input->post('post_content'));
}
Template::set('is_post_close',$is_post_closed);
//Template::set('ticket_id',$ticket_id);
Template::set('is_post_closed',$is_post_closed);
Template::set('post_content',$post_content);
Template::set('count',$count);
Template::set('is_post_closed',$is_post_closed);
Template::render();
}
here is my another view page :- full_post_view.php
Code:
<?php $ticket_id = $this->session->userdata('ticket_id'); ?>
<?php $post=Template::get('post_content'); ?>
<?php $ticket_id=Template::get('ticket_id'); ?>
<?php $is_close = Template::get('is_close'); ?>
<h4>Your Problem :- </h4>
<?php echo $post; ?>
<hr/>
<?php foreach ($is_post_closed->result() as $value) {
$is_close = $value->is_close;
} ?>
<?php if(Template::get('count') > 0) : ?>
<?php foreach($all_comments->result_array() as $commentsRow) : ?>
<?php echo word_wrap($commentsRow['comments'],15); ?>
<?php echo " by->"; ?>
<?php echo $commentsRow['username']; ?>
<?php echo $commentsRow['role_name']; ?>
<hr/>
<?php endforeach; ?>
<?php else : ?>
<br/>
No Comments Yet
<?php endif; ?>
<?php if($is_close == 0 ) : ?>
<?php echo form_open('helpdesk/newComment'); ?>
<?php echo form_hidden('ticket_id',$ticket_id); ?>
<?php echo form_hidden('post_content', $post); ?>
<?php echo form_textarea('comment_from_user'); ?>
<?php echo form_submit('submit', 'Comment '); ?>
<?php echo form_close(); ?>
<?php endif; ?>
<?php if($is_close==0) : ?>
<?php echo form_open('helpdesk/closePost'); ?>
<?php echo form_hidden('ticket_id', $ticket_id); ?>
<?php echo form_hidden('post_content', $post); ?>
<?php echo form_submit('submit','close post'); ?>
<?php echo form_close(); ?>
<?php else : ?>
<?php echo form_open('helpdesk/reopenPost'); ?>
<?php echo form_hidden('ticket_id', $ticket_id); ?>
<?php echo form_submit('submit','Reopen post'); ?>
<?php echo form_close(); ?>
<?php endif; ?>
I am using bonfire..