Question

I have a listing of all users, and it's done with cakephp 1.3 pagination-and a search function. It works perfectly in FF/Opera/Chrome, but has the following issue in IE8/IE9

step 1. Make a search that brings up > 1 page. step 2. Make a second search that brings up > 1 page. step 3. Click the next page/page 2 button. It brings up the second page of step 1. If you go to page 1, you are results of step 1.

I can't find anything on why IE would behave this way. I checked my session values, but they are correct as far as I can tell (ex. step 1 session = 145, step 2 session = 7, step 3 session = 7)

Controller (I've stripped out stuff to make it smaller, I can add in more if needed):

if(empty($this->data)) {
        $this->data['User']['inactive'] = $this->Session->read('User.inactive_store');
        $this->data['User']['pe'] = $this->Session->read('User.pe_store');
        $this->data['User']['district'] = $this->Session->read('User.district_store');
        $this->data['User']['ghq'] = $this->Session->read('User.ghq_store');
        $this->data['User']['last_name'] = $this->Session->read('User.last_name_store');
        $this->data['User']['first_name'] = $this->Session->read('User.first_name_store');
        $this->data['User']['rank'] = $this->Session->read('User.rank_store');
        $this->data['User']['status'] = $this->Session->read('User.status_store');
        $this->data['User']['race'] = $this->Session->read('User.race_store');
        $this->data['User']['sex'] = $this->Session->read('User.sex_store');
        $this->data['User']['type'] = $this->Session->read('User.type_store');
        $this->data['User']['radio'] = $this->Session->read('User.radio_store');
        $this->data['User']['unit'] = $this->Session->read('User.unit_store');
        $this->data['User']['results'] = $this->Session->read('User.results_store');
        if(empty($this->data['User']['results'])){$this->data['User']['results'] = 0;}
        $this->data['User']['psid'] = $this->Session->read('User.psid_store');
        $this->data['User']['psid_show'] = $this->Session->read('User.psid_show_store');
        $this->data['AirCard']['card_number'] = $this->Session->read('User.card_number_store');
        $this->data['AirCard']['esn'] = $this->Session->read('User.esn_store');
        $this->data['AirCard']['ip_address'] = $this->Session->read('User.ip_store');
    }
    $results = 'false';
    $message = '';

    if(!empty($this->data)){
        //set up some variables
        $pe = $this->data['User']['pe'];
        $district = $this->data['User']['district'];
        $ghq = $this->data['User']['ghq'];
        $first_name_store = $this->data['User']['first_name'];
        $last_name_store = $this->data['User']['last_name'];
        $first_name = $this->data['User']['first_name'].'%';
        $last_name = $this->data['User']['last_name'].'%';
        $rank = $this->data['User']['rank'];
        $status = $this->data['User']['status'];
        $race = $this->data['User']['race'];
        $sex = $this->data['User']['sex'];
        $type = $this->data['User']['type'];
        $results = $this->data['User']['results'];
        $psid = $this->data['User']['psid'];
        $psid_show = $this->data['User']['psid_show'];
        $car = $this->data['User']['radio'];
        $badge = $this->data['User']['unit'];

        //hidden admin controls
        if(empty($this->data['AirCard']['card_number']) && empty($this->data['AirCard']['esn']) && empty($this->data['AirCard']['ip_address']))
        {
            $card_number = '';
            $esn = '';
            $ip = '';
        } else {
            $card_number = $this->data['AirCard']['card_number'];
            $esn = $this->data['AirCard']['esn'];
            $ip = $this->data['AirCard']['ip_address'];
        }
        $run_mobile = 0;

        //this message will display to ensure user what was searched for/what was changed in search
        $message = $message.'<p> Searched for: </p>';

        //while loop to check for names.  for example someone searches Jon Burns, gets no results it should search for J Burns instead, no results just Burns, etc
        while(empty($datas))
        {
            //check for any empty variables/fill the ones that need to have values
            if(empty($pe)) 
            {
                $pe_empty = 1;
                $pe_query = '';
            } else {
                $message = $message.'<b>PE</b> = '.$pe.' || ';
                $pe_query = array('User.pe' => $pe);
            }
            if(empty($district)) 
            {
                $district_empty = 1;
                $district_query = '';
            } elseif(sizeof($district) == 1) {
                $message = $message.'<b>District</b> = '.$district_list[$district].' || ';
                $district_query = array('User.district_id' => $district);
            } else {
                $district_empty = 1;
            }
            if(empty($ghq)) 
            {
                $ghq_empty = 1;
                $ghq_query = '';
            } elseif(sizeof($ghq) == 1) {
                $message = $message.'<b>Assigned To</b> = '.$ghq_list[$ghq].' || ';
                $ghq_query = array('User.ghq_id' => $ghq);
            } else {
                $ghq_empty = 1;
            }
            if(empty($rank))
            {
                $rank_empty = 1;
                $rank_query = '';
            } elseif(sizeof($rank) == 1) {
                $message = $message.'<b>Rank</b> = '.$rank_list[$rank].' || ';
                $rank_query = array('User.rank_id' => $rank);
            }
            if(empty($first_name_store)) 
            {
                $first_empty = 1;
                $first_name_query = '';
            } else {
                $message = $message.'<b>First Name</b> = '.$first_name_store.' || ';
                $first_name_query = array('User.first_name LIKE' => $first_name);
            }
            if(empty($last_name_store)) 
            {
                $last_empty = 1;
                $last_name_query = '';
            } else {
                $message = $message.'<b>Last Name</b> = '.$last_name_store.' || ';
                $last_name_query = array('User.last_name LIKE' => $last_name);
            }
            if(empty($this->data['User']['inactive']))
            {
                $this->data['User']['inactive'] = 0;
            }
            if($this->data['User']['inactive'] == 0)
            {
                $active_query = array('User.active' => 1);
            } else {
                $active_query = '';
            }
            if(empty($status))
            {
                $status_query = '';
            } else {
                $message = $message.'<b>Status</b> = '.$status_list[$status].' || ';
                $status_query = array('User.special_status_id' => $status);
            }
            if(empty($race))
            {
                $race_query = '';
            } else {
                $message = $message.'<b>Race</b> = '.$race_list[$race].' || ';
                $race_query = array('User.race_id' => $race);
            }
            if(empty($sex))
            {
                $sex_query = '';
            } else {
                $message = $message.'<b>Sex</b> = '.$sex_list[$sex].' || ';
                $sex_query = array('User.sex_id' => $sex);
            }
            if(empty($type))
            {
                $type_query = '';
            } else {
                $message = $message.'<b>Type</b> = '.$type_list[$type].' || ';
                $type_query = array('User.employee_type_id' => $type);
            }
            if(empty($psid))
            {
                $psid_query = '';
            } else {
                $message = $message.'<b>Public Safety ID</b> = '.$psid.' || ';
                $psid_query = array('User.psid' => $psid);
            }
            if(empty($psid_show))
            {
                $psid_show_query = '';
            } else {
                $message = $message.'<b>Public Safety ID not empty</b> || ';
                $psid_show_query = array('User.psid !=' => null);
            }
            if(empty($car))
            {
                $car_query = '';
            } else {
                $message = $message.'<b>Car Number</b> = '.$car.' || ';
                $car_query = array('User.radio =' => $car);
            }
            if(empty($badge))
            {
                $badge_query = '';
            } else {
                $message = $message.'<b>Badge Number</b> = '.$badge.' || ';
                $badge_query = array('User.unit =' => $badge);
            }
            if(empty($card_number))
            {
                $card_number_query = '';
                $this->data['AirCard']['card_number'] = '';
            } else {
                $message = $message.'<b>Card Number = </b>'.$card_number.' || ';
                $card_number_query = array('AirCard.card_number' => $card_number);
                $run_mobile = 1;
            }
            if(empty($esn))
            {
                $esn_query = '';
                $this->data['AirCard']['esn'] = '';
            } else {
                $message = $message.'<b>ESN = </b>'.$esn.' || ';
                $esn_query = array('AirCard.esn' => $esn);
                $run_mobile = 1;
            }
            if(empty($ip))
            {
                $ip_query = '';
                $this->data['AirCard']['ip_address'] = '';
            } else {
                $message = $message.'<b>IP = </b>'.$ip;
                $ip_query = array('AirCard.ip_address' => $ip);
                $run_mobile = 1;
            }
            $message = $message.'</p>';
            $mobile_query = '';
            if($run_mobile == 1)
            {
                $mobile_user_ids = $this->AirCard->find('list',array(
                    'conditions' => array('AND' => array(
                        $card_number_query,
                        $esn_query,
                        $ip_query
                    )),'fields' => array('user_id')
                ));
                if(!empty($mobile_user_ids))
                {
                    $mobile_query = array('User.id' => $mobile_user_ids);
                } else {
                    $message = $message.'No results found';
                }
            }

            //List of users matching given parameters $datas
            $this->paginate = array(
                'conditions' => array('AND' => array(
                    $pe_query,
                    $district_query,
                    $ghq_query,
                    $active_query,
                    $last_name_query,
                    $first_name_query,
                    $rank_query,
                    $status_query,
                    $race_query,
                    $sex_query,
                    $type_query,
                    $hide_technical,
                    $psid_query,
                    $psid_show_query,
                    $mobile_query,
                    $car_query,
                    $badge_query
                )),
                'fields' => array('pe','last_name','first_name','middle_initial','id','district_id','ghq_id','rank_id','sworn','cps','mci','dor'),
                'limit'=> $results,

                'order' => array(
                    'User.pe' => 'asc'
                ),
                    'recursive'=>-1
            );

            //run the paginate
            $datas = $this->paginate('User');

            //if the paginate is empty put in message.  Then remove one of the variables in order first,last,pe,district,assigned
            if(empty($datas))
            {
                $message = $message.'<br /><p> Search returned no results.  Searching instead for:</p><p>';
                if($first_empty == 0)
                {
                    if(strlen($first_name_store) > 1)
                    {
                        $first_name = $first_name_store[0].'%';
                        $first_name_store = $first_name_store[0];
                    } else {
                        $first_name = '%';
                        $first_name_store = '';
                    }
                } elseif($last_empty == 0) {
                    if(strlen($last_name_store) > 1)
                    {
                        $last_name = $last_name_store[0].'%';
                        $last_name_store = $last_name_store[0];
                    } else {
                        $last_name = '%';
                        $last_name_store = '';
                    }
                } elseif($pe_empty == 0) {
                    $pe = '';
                } elseif($ghq_empty == 0) {
                    $ghq = '';
                } elseif($district_empty == 0) {
                    $district = '';
                } elseif($rank_empty == 0) {
                    $rank = '';
                } elseif(!empty($car)) {
                    $car = '';
                } elseif(!empty($badge)) {
                    $badge = '';
                }
            }
        }

        $this->Session->write('User.inactive_store',$this->data['User']['inactive']);
        $this->Session->write('User.pe_store',$this->data['User']['pe']);
        $this->Session->write('User.district_store',$this->data['User']['district']);
        $this->Session->write('User.ghq_store',$this->data['User']['ghq']);
        $this->Session->write('User.last_name_store',$this->data['User']['last_name']);
        $this->Session->write('User.first_name_store',$this->data['User']['first_name']);
        $this->Session->write('User.rank_store',$this->data['User']['rank']);
        $this->Session->write('User.status_store',$this->data['User']['status']);
        $this->Session->write('User.race_store',$this->data['User']['race']);
        $this->Session->write('User.sex_store',$this->data['User']['sex']);
        $this->Session->write('User.type_store',$this->data['User']['type']);
        $this->Session->write('User.results_store',$this->data['User']['results']);
        $this->Session->write('User.psid_store',$this->data['User']['psid']);
        $this->Session->write('User.psid_show_store',$this->data['User']['psid_show']);
        $this->Session->write('User.radio_store',$this->data['User']['radio']);
        $this->Session->write('User.unit_store',$this->data['User']['unit']);
        $this->Session->write('User.card_number_store',$this->data['AirCard']['card_number']);
        $this->Session->write('User.esn_store',$this->data['AirCard']['esn']);
        $this->Session->write('User.ip_store',$this->data['AirCard']['ip_address']);
        $this->set('pe',$pe);
        $this->set('district',$district);
        $this->set('ghq',$ghq);
        $this->set('datas', $datas);
        $this->set('message',$message);
        $this->set('rank',$rank);
        $this->set('psid',$psid);
        $this->set('psid_show',$psid_show);
        $results = 'true';
    }
    $this->set('results', $results);

View:

 <?php
    $html->addCrumb($user['User']['first_name'] . " " . $user['User']['last_name'], '/users');
?>
<?php echo $this->Html->script('jquery'); ?>
<!-- UNITBOOK index of users -->
<?php if($add == 1): ?>
    <div style="color:white; background-color:black;  padding-left:10px;">
        <table>
            <tr>
                <td><div style="font-size: 40px; color:white; background-color:black; padding-left:10px;">Unitbook</div></td>
                <td><div class = "mediumbuttons"><?php echo $this->Html->link('','/users/add/',array('class'=>'button_newuser')); ?></div></td>
            </tr>
        </table>
    </div>
<?php else: ?>
    <div style="height: 38px;  color:white; background-color:black;  padding-left:10px;">
        <table>
            <tr>
                <td><div style="margin-top:7px; font-size: 40px; color:white; background-color:black; padding-left:10px;">Unitbook</div></td>
            </tr>
        </table>
    </div>
<?php endif; ?>
<br />
<?php echo $form->create('User', array('action' => '/unitbook/'));?>

<fieldset class="ta_add_fieldset">
    <legend class="ta_add_legend">
        Search
    </legend>
    <table>
        <tr>
            <td>
                <label class = "gi_label"><b>Last Name:</b></label>
            </td>
            <td>
                <?php echo $this->Form->input('User.last_name',array('label' => ''));?>
            </td>
            <td>
                <label class = "gi_label"><b>First Name:</b></label>
            </td>
            <td>
                <?php echo $this->Form->input('User.first_name',array('label' => ''));?>
            </td>
        </tr>
        <tr>
            <td>
                <label class = "gi_label"><b>PE:</b></label>
            </td>
            <td>
                <?php echo $this->Form->input('User.pe',array('label' => '','size' => '10', 'maxlength' => '10'));?>
            </td>
            <td>
                <label class = "gi_label"><b>Assigned To:</b></label>
            </td>
            <td>
                <?php echo $form->select('User.district',$district_list);?>
            </td>
            <?php if($viewable): ?>
                <td>
                    <label class = "gi_label"><b>Check to include inactive users</b></label>
                </td>
                <td>
                    <?php echo $this->Form->checkbox('User.inactive');?>
                </td>
            <?php endif; ?>
        </tr>
    </table>
    <table>
        <tr>
            <td>
                <label class = "gi_label"><b>Located At:</b></label>
            </td>
            <td>
                <?php echo $form->select('User.ghq',$ghq_list);?>
            </td>
        </tr>
    </table>
    <table>
        <tr>
            <td>
                <label class = "gi_label"><b>Rank:</b></label>
            </td>
            <td>
                <?php echo $form->select('User.rank',$rank_list);?>
            </td>
            <td>
                <label class = "gi_label"><b>Status:</b></label>
            </td>
            <td>
                <?php echo $form->select('User.status',$status_list);?>
            </td>
        </tr>
    </table>
    <table>
        <tr>
            <td>
                <label class = "gi_label"><b>Race:</b></label>
            </td>
            <td>
                <?php echo $form->select('User.race',$race_list);?>
            </td>
            <td>
                <label class = "gi_label"><b>Sex:</b></label>
            </td>
            <td>
                <?php echo $form->select('User.sex',$sex_list);?>
            </td>
            <td>
                <label class = "gi_label"><b>Type:</b></label>
            </td>
            <td>
                <?php echo $form->select('User.type',$type_list);?>
            </td>
        </tr>
    </table>
    <table>
        <tr>
            <td>
                <label class = "gi_label"><b>Car Number:</b></label>
            </td>
            <td>
                <?php echo $this->Form->input('User.radio',array('label' => ''));?>
            </td>
            <td>
                <label class = "gi_label"><b>Badge Number:</b></label>
            </td>
            <td>
                <?php echo $this->Form->input('User.unit',array('label' => ''));?>
            </td>
        </tr>
    </table>
    <table>
        <tr>
            <td id='aggregatelabel'>
                <label class="gi_label"><b>Results per page: </b></label>
            </td>
            <td>
                <?php echo $this->Form->input('results', array('label' => '', 'options' => array(
                    '25' => '25',
                    '50' => '50',
                    '75' => '75',
                    '100' => '100',
                    '100000' => 'All'
                ))); ?>
            </td>
            <td>
                <label class = "gi_label"><b>Public Safety ID:</b></label>
            </td>
            <td>
                <?php echo $this->Form->input('User.psid',array('label' => ''));?>
            </td>
            <td>
                <label class = "gi_label"><b>Only show users with Public Safety ID</b></label>
            </td>
            <td>
                <?php echo $this->Form->checkbox('User.psid_show');?>
            </td>
    </table>
    <?php if($mobile == 1): ?>
        <table>
            <tr>
                <td>
                    <label class = "gi_label"><b>Air Card Number</b></label>
                </td>
                <td>
                    <?php echo $this->Form->input('AirCard.card_number',array('label' => ''));?>
                </td>
                <td>
                    <label class = "gi_label"><b>ESN</b></label>
                </td>
                <td>
                    <?php echo $this->Form->input('AirCard.esn',array('label' => ''));?>
                </td>
                <td>
                    <label class = "gi_label"><b>IP Address</b></label>
                </td>
                <td>
                    <?php echo $this->Form->input('AirCard.ip_address',array('label' => ''));?>
                </td>
            </tr>
        </table>
    <?php endif; ?>
    <?php echo $form->submit('Search'); ?>
</fieldset>

<?php if($results == 'true'): ?>
<?php $limit = $this->params['paging']['User']['options']['limit'];
if($limit != 1): ?>
<fieldset class="ta_add_fieldset">
    <legend class="ta_add_legend">
        Results
    </legend>
    <?php echo $message; ?>
    <div id="content">
        <?php
            $paginator->options(
                    array('update'=>'#content', 
                            'evalScripts' => true, 
                            'before' => $this->Js->get('#busy-indicator')->effect('fadeIn', array('buffer' => false)),
                            'complete' => $this->Js->get('#busy-indicator')->effect('fadeOut', array('buffer' => false)),
                            ));
        ?> 
        <?php echo $this->Js->writeBuffer(); ?>
        <?php echo $this->Html->image('http://ispspeis.isp.in.gov/Pictures/shield/logo/indicator.gif', array('id' => 'busy-indicator','class' => 'busy_float')); ?>
        <table>
            <tr>
                <th><?php echo $paginator->sort('PE','pe');?></th>
                <th><?php echo $paginator->sort('Name','last_name');?></th>
                <th><?php echo $paginator->sort('Assigned To','district_id');?></th>
                <th><?php echo $paginator->sort('Located At','ghq_id');?></th>
                <th><?php echo $paginator->sort('Rank','rank_id');?></th>
            </tr>
            <?php foreach($datas as $data): ?>
                <tr>
                    <td style="background-color: #FFFFFF; font-weight: bold; font-size:x-small;">
                        <?php echo $this->Html->link($data['User']['pe'],'/users/view/'.$data['User']['id']); ?>
                    </td>
                    <td style="background-color: #EEEEEE; font-weight: bold; font-size:x-small;">
                        <?php echo $this->Html->link($data['User']['last_name'].', '. $data['User']['first_name'].' '. $data['User']['middle_initial'],'/users/view/'.$data['User']['id']); ?>
                    </td>
                    <td style="background-color: #FFFFFF; font-weight: bold; font-size:x-small;">
                        <?php if(!empty($data['User']['district_id'])): echo $district_list[$data['User']['district_id']]; endif; ?>
                    </td>
                    <td style="background-color: #EEEEEE; font-weight: bold; font-size:x-small;">
                        <?php if(!empty($data['User']['ghq_id'])) :echo $ghq_list[$data['User']['ghq_id']]; endif; ?>
                    </td>
                    <td style="background-color: #FFFFFF; font-weight: bold; font-size:x-small;">
                        <?php if(!empty($data['User']['rank_id'])): echo $rank_list[$data['User']['rank_id']]; endif; ?>
                    </td>
                    <?php if($all == 1 || ($u_dist == 1 && $data['User']['district_id'] == $user['User']['district_id']) || ($u_div == 1 && $data['User']['ghq_id'] == $user['User']['ghq_id'])): ?>
                        <td>
                            <div class = "littlebuttons"><?php echo $this->Html->link('','/users/edit/'.$data['User']['id'],array('class'=>'button_edituser','title'=>'Edit User Information')); ?></div>
                        </td>
                    <?php endif; ?>
                    <td>
                        <div class = "littlebuttons"><?php echo $this->Html->link('','/users/printview/'.$data['User']['id'],array('class'=>'button_printer','title'=>'Print View')); ?></div>
                    </td>
                    <?php if($training == 1): ?>
                        <td>
                            <div class = "littlebuttons"><?php echo $this->Html->link('','/train_records/index/'.$data['User']['id'],array('class'=>'button_book','title'=>'Training Records')); ?></div>
                        </td>
                    <?php endif; ?>
                    <?php if($data['User']['sworn'] + $data['User']['cps'] + $data['User']['mci'] > 0): ?>
                        <?php if(($ta_all == 1) || ($ta_district == 1 && $data['User']['district_id'] == $user['User']['district_id']) || ($ta_division == 1 && $data['User']['ghq_id'] == $user['User']['ghq_id'])): ?>
                            <td>
                                <div class = "widelittlebuttons"><?php echo $this->Html->link('','/audits/index/'.$data['User']['id'],array('class'=>'button_microaudit','title'=>'Audit')); ?></div>
                            </td>
                            <td>
                                <div class = "littlebuttons"><?php echo $this->Html->link('','/trooper_activities/index/'.$data['User']['id'],array('class'=>'button_microactivity','title'=>'Trooper Activity')); ?></div>
                            </td>
                            <?php if($road == true): ?>
                                <td>
                                    <div class = "littlebuttons"><?php echo $this->Html->link('','/settings/adjust_mile/'.$data['User']['id'],array('class'=>'button_road','title'=>'Mileage Update')); ?></div>
                                </td>
                            <?php endif; ?>
                        <?php endif; ?>
                    <?php else: ?>
                        <td>
                            <div class = "littlebuttons"><?php echo $this->Html->link('','/users/index/'.$data['User']['id'],array('class'=>'button_microcalendar','title'=>'Calendar')); ?></div>
                        </td>
                    <?php endif; ?>
                    <?php if($dor_view == 1 and !empty($dor_list[$data['User']['rank_id']])): ?>
                        <td>
                            <div class = "littlebuttons"><?php echo $this->Html->link('','/ftos/index/'.$data['User']['id'],array('class'=>'button_fto','title'=>'Daily Observation Records')); ?></div>
                        </td>
                    <?php endif; ?>
                    <?php if($mobile == 1): ?>
                        <td>
                            <div class = "littlebuttons"><?php echo $this->Html->link('','/air_cards/index/'.$data['User']['id'],array('class'=>'button_micromobile','title'=>'Mobile Records')); ?></div>
                        </td>
                    <?php endif; ?>
                </tr>
            <?php endforeach; ?>
        </table>
        <?php echo $this->Paginator->numbers(); ?>
        <?php echo $this->Paginator->prev('< Previous', null, null, array('class' => 'disabled')); ?>
        <?php echo $this->Paginator->next('Next >', null, null, array('class' => 'disabled')); ?>
        <?php echo $this->Paginator->counter(array(
            'format' => 'Page %page% of %pages%, showing %start% - %end% records out of
            %count% total'
            ));  ?>
        <?php echo $this->Html->link('Export','/users/export_xls'); ?>
    </div>
</fieldset>
<?php endif; ?>
<?php endif; ?>

<?php echo $form->end(); ?> 
<?php echo $this->Js->writeBuffer(); ?>

Any help is greatly appreciated!

Was it helpful?

Solution

IE does wierd things with Ajax and caching. added the following to the page to force it to actually load each time:

<script>
$.ajaxSetup({ cache: false });
</script>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top