/**
  * This function retrieves AuditTrails
  *
  * It receives as inputs Smsr-Id (Mandatory), EID (Mandatory) and AuditTrail identifier (Optional)
  * It searches in the audittrail model and retrieves the audittrail requested
  * Smsr-Id, EID and AuditTrail input paramater may include the 'all' wilcard
  * When Audittrail is omitted, it searches all audit trails in the scope of the SMSSRId and Eid.
  * The function returns a HTTP response object. It contains the either the result of the search or an eror code. 
  * 
  * @param string $smsrid
  * @param string $eid
  * @param string $audittrailid
  * @return response
  * 
  */
 public function getAuditTrail($SmsrId, $Eid, $AuditTrailId = null)
 {
     $AuditTrail = new AuditTrail();
     if ($SmsrId == 'all') {
         if ($Eid == 'all') {
             if ($AuditTrailId == null) {
                 //return all Audit Trails in base
                 $Result = $AuditTrail->all();
             } else {
                 //return Audit Trail with id from all smsr and all eis
                 $Result = $AuditTrail->find($AuditTrailId);
             }
         } else {
             if ($AuditTrailId == null) {
                 //return all Audit Trails with id for a specific EIS on any SMSR
                 $Result = $AuditTrail->where('eid', $Eid)->get();
             } else {
                 //return a specific Audit Trail from a specific EIS on any SMSR
                 $Result = $AuditTrail->where('eid', $Eid)->find($AuditTrailId);
             }
         }
     } else {
         if ($Eid == 'all') {
             if ($AuditTrailId == null) {
                 //return all Audit Trails in base
                 $Result = $AuditTrail->all();
             } else {
                 //return Audit Trail with id from all smsr and all eis
                 $Result = $AuditTrail->find($AuditTrailId);
             }
         } else {
             if ($AuditTrailId == null) {
                 //return all Audit Trails with id for a specific EIS on any SMSR
                 $Result = $AuditTrail->where('eid', $Eid)->get();
             } else {
                 //return a specific Audit Trail from a specific EIS on any SMSR
                 $Result = $AuditTrail->where('eid', $Eid)->find($AuditTrailId);
             }
         }
     }
     return response()->json($Result);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $data = AuditTrail::all();
     return response()->json($data, 200, array(), JSON_PRETTY_PRINT);
 }