Ejemplo n.º 1
0
 function userHistoryAction()
 {
     $guid = $this->_getParam('guid') ? $this->_getParam('guid') : '';
     $tblUser = new Pandamp_Modules_Identity_User_Model_User();
     $req = $this->getRequest();
     $sortDir = $req->getParam('dir') ? $req->getParam('dir') : 'ASC';
     $sortBy = $req->getParam('sort') ? $req->getParam('sort') : 'username';
     $start = $req->getParam('start') ? $req->getParam('start') : 0;
     $end = $req->getParam('limit') ? $req->getParam('limit') : 10;
     $fields = $req->getParam('fields') ? $req->getParam('fields') : '';
     $query = $req->getParam('query') ? $req->getParam('query') : '';
     $selectedRows = Zend_Json::decode($fields);
     $rowval = Zend_Json::decode($query);
     $rowset = $tblUser->fetchUserHistory($guid, "{$sortBy} {$sortDir}", $start, $end);
     $a = array();
     $a['totalCount'] = count($rowset);
     $i = 0;
     if ($a['totalCount'] != 0) {
         foreach ($rowset as $row) {
             $a['history'][$i]['id'] = $row->idUser;
             $a['history'][$i]['uid'] = $row->uidUser;
             $a['history'][$i]['fullName'] = $row->fullName;
             $a['history'][$i]['username'] = $row->username;
             $a['history'][$i]['company'] = !empty($row->company) ? $row->company : '-';
             $a['history'][$i]['createdDate'] = Pandamp_Lib_Formater::get_date_english($row->createdDate);
             $a['history'][$i]['expirationDate'] = $row->expirationDate ? Pandamp_Lib_Formater::get_date_english($row->expirationDate) : '-';
             $a['history'][$i]['paymentId'] = $row->paymentId;
             $a['history'][$i]['DaysLeft'] = $row->DaysLeft;
             $a['history'][$i]['value'] = $row->packageId;
             $a['history'][$i]['packageId'] = $row->value;
             $a['history'][$i]['periodeId'] = $row->status ? $row->status : "unknown";
             $a['history'][$i]['isEmailSent'] = $row->isEmailSent;
             $a['history'][$i]['isActive'] = $row->isActive;
             $i++;
         }
     }
     if ($a['totalCount'] == 0) {
         $a['history'][0]['id'] = '';
         $a['history'][0]['uid'] = '';
         $a['history'][0]['fullName'] = '';
         $a['history'][0]['username'] = '';
         $a['history'][0]['company'] = '';
         $a['history'][0]['createdDate'] = '';
         $a['history'][0]['expirationDate'] = '';
         $a['history'][0]['paymentId'] = '';
         $a['history'][0]['DaysLeft'] = 'x';
         $a['history'][0]['value'] = '';
         $a['history'][0]['packageId'] = '';
         $a['history'][0]['periodeId'] = '';
         $a['history'][0]['isEmailSent'] = 'x';
         $a['history'][0]['isActive'] = 'x';
     }
     echo Zend_Json::encode($a);
 }