Ejemplo n.º 1
0
 /**
  * @covers AppSolr::getCasesCount
  *
  */
 public function testGetCasesCount()
 {
     $userUid = '00000000000000000000000000000001';
     $result = $this->object->getCasesCount($userUid);
     print_r($result);
     $this->assertNotEmpty($result, 'Empty array of counters');
 }
Ejemplo n.º 2
0
function getAllCounters()
{
    $userUid = isset($_SESSION['USER_LOGGED']) && $_SESSION['USER_LOGGED'] != '' ? $_SESSION['USER_LOGGED'] : null;
    $oAppCache = new AppCacheView();
    $aTypes = array();
    $aTypes['to_do'] = 'CASES_INBOX';
    $aTypes['draft'] = 'CASES_DRAFT';
    $aTypes['cancelled'] = 'CASES_CANCELLED';
    $aTypes['sent'] = 'CASES_SENT';
    $aTypes['paused'] = 'CASES_PAUSED';
    $aTypes['completed'] = 'CASES_COMPLETED';
    $aTypes['selfservice'] = 'CASES_SELFSERVICE';
    //$aTypes['to_revise']   = 'CASES_TO_REVISE';
    //$aTypes['to_reassign'] = 'CASES_TO_REASSIGN';
    $solrEnabled = false;
    if (($solrConf = System::solrEnv()) !== false) {
        G::LoadClass('AppSolr');
        $ApplicationSolrIndex = new AppSolr($solrConf['solr_enabled'], $solrConf['solr_host'], $solrConf['solr_instance']);
        if ($ApplicationSolrIndex->isSolrEnabled() && $solrConf['solr_enabled'] == true) {
            $solrEnabled = true;
        }
    }
    if ($solrEnabled) {
        $aCount = $ApplicationSolrIndex->getCasesCount($userUid);
        //get paused count
        $aCountMissing = $oAppCache->getAllCounters(array('completed', 'cancelled'), $userUid);
        $aCount = array_merge($aCount, $aCountMissing);
    } else {
        $aCount = $oAppCache->getAllCounters(array_keys($aTypes), $userUid);
    }
    $response = array();
    $i = 0;
    foreach ($aCount as $type => $count) {
        $response[$i] = new stdclass();
        $response[$i]->item = $aTypes[$type];
        $response[$i]->count = $count;
        $i++;
    }
    echo G::json_encode($response);
}