fetch($subject); $db->close(); // Si erreur if( $data === false ) return array( 'ModuleError' => ManagerError::ModuleError ); /* [2] S'il a un journal d'appel, on renvoie les données =========================================================*/ if( isset($data['logs']) && is_array($data['logs']) ){ /* (1) On initialise les compteurs */ $MISSED = 0; $OUTGOING = 0; $INCOMING = 0; /* (2) On incrémente les compteurs */ foreach($data['logs'] as $log){ /* (3) Si ce n'est pas un appel, on passe au suivant */ if( $log['type'] != 0 ) continue; /* (4) On incrémente les types */ $MISSED += ($log['direction']==2) ? 1 : 0; $OUTGOING += ($log['direction']==1) ? 1 : 0; $INCOMING += ($log['direction']==0) ? 1 : 0; } /* [3] Si aucun journal d'appel =========================================================*/ }else{ /* (1) On initialise les compteurs */ $MISSED = 0; $OUTGOING = 0; $INCOMING = 0; } return array( 'ModuleError' => ManagerError::Success, 'labels' => array('ENTRANT', 'SORTANT', 'MANQUÉ'), 'data' => array($INCOMING, $OUTGOING, $MISSED) ); } } ?>