mercredi 5 août 2015

How To Fix Error Pagination with Search Data Using session


i have a problem pagination with search data using session. if i am not using search data using session, pagination will be work. but when i am using search data. pagination could not be work. when i click on a pagination link, The requested address '/..../..../page:2' was not found on this server. so i need help to fix error the pagination.

public function index($id=null) {
    if($id='flush'){
        $this->Session->delete('inboxes_index.date_start');
        $this->Session->delete('inboxes_index.date_end');
    }

    $this->loadModel('Product');
    $this->LoadModel('ResponseStats')  ;
    $this->ResponseStats->reqursive = -1;
    $this->Product->recursive = -1;


    if($this->request->data['Inbox']['date_start']){
        $conditions["Inbox.create_date >="] = date("d-M-Y", strtotime($this->request->data['Inbox']['date_start']))." 00:00:00";
        $this->Session->write('inboxes_index.date_start', $conditions["Inbox.create_date >="]);
    }else{
        $conditions["Inbox.create_date >="] = date("d-M-Y")." 00:00:00";
        $this->request->data['Inbox']['date_start'] = date("d-M-Y", strtotime($this->request->data['Inbox']['date_start']." 00:00:00"));
    }

    if($this->request->data['Inbox']['date_end']){
        $conditions["Inbox.create_date <="] = date("d-M-Y", strtotime($this->request->data['Inbox']['date_end']))." 23:59:59";
        $this->Session->write('inboxes_index.date_end', $conditions["Inbox.create_date <="]);
    }else{
        $conditions["Inbox.create_date <="] = date("d-M-Y")." 23:59:59";
        $this->request->data['Inbox']['date_end'] = date("d-M-Y", strtotime($this->request->data['Inbox']['date_end']."23:59:59"));
    }


    //read session date start
    if($this->Session->read('inboxes_index.date_start')!=NULL) {
        $conditions["Inbox.create_date >="] = $this->Session->read('inboxes_index.date_start');
        $this->request->data['Inbox']['date_start'] = date("d-M-Y", strtotime($this->Session->read('inboxes_index.date_start')));
    }

    //read session date end
    if($this->Session->read('inboxes_index.date_end')!=NULL) {
        $conditions["Inbox.create_date <="] = $this->Session->read('inboxes_index.date_end');
        $this->request->data['Inbox']['date_end'] = date("d-M-Y", strtotime($this->Session->read('inboxes_index.date_end')));
    }


    $this->Inbox->recursive = -1 ;
    $this->paginate = array(
    //$report_inbox = $this->Inbox->find('all', array(
                                'conditions'=> array_merge($conditions),
                                'joins' => array(
                                    array(
                                        'table' => 'users',
                                        'alias' => 'User',
                                        'type' => 'INNER',
                                        'conditions' => array('User.id = Inbox.user_id')
                                    ),
                                    array(
                                        'table' => 'response_stats',
                                        'alias' => 'Respon',
                                        'type' => 'inner',
                                        'conditions' => array('Respon.code::int4 = Inbox.status')
                                    )
                                ),
                                'fields' => array(
                                    'User.username', 
                                    'User.company', 
                                    'User.cid', 
                                    'Inbox.idpel', 
                                    'Inbox.status', 
                                    'Inbox.trx_type',
                                    'Respon.name',
                                    'Inbox.trxid', 
                                    'date(Inbox.create_date)'
                                ),
    );


    $this->set('report_inbox', $this->paginate());



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire