/**
  * check if values $_REQUEST[''] exist then - get thing by id(existing thing)
  * if values not exist then create a new thing and assigns to the friend whose id is set
  * @return array
  */
 protected function run()
 {
     if (array_key_exists('id', $_REQUEST) and $_REQUEST['id'] > 0) {
         $thing = Things::getThingByID($_REQUEST['id']);
     } else {
         $thing = new Thing();
         $thing->setFriendID($_REQUEST['friendid']);
     }
     /**
      * if $_POST_[""] is not empty then set the values into the template
      * else set error massage if one of the $_POST[""] is empty
      */
     if (!empty($_POST["description"]) and !empty($_POST["statebeforelent"])) {
         $thing->setDescription($_POST["description"]);
         $thing->setStateBeforeLent($_POST["statebeforelent"]);
         $thing->setDateOfLent(date('Y-m-d'));
         /**
          * records can be saved after editing or creating
          * exit the program after a successful storage
          * error massage when one of the $_POST fields is empty
          */
         if ($thing->save()) {
             header('location:index.php?module=lentthingslist&friendid=' . $thing->getFriendId());
             exit;
         } else {
             $var = array('fehler' => "Etwas stimmt mit der Eingabe nicht!");
         }
     } elseif (!empty($_POST["description"]) or !empty($_POST["statebeforelent"])) {
         $var = array('fehler' => "Es sind nicht alle Datenfelder ausgefüllt");
     }
     $var['thing'] = $thing;
     return $var;
 }
 /**
  * check if values $_REQUEST[''] exist then - get thing by id
  * fetches only the data whose ID is queried
  * @return array
  */
 protected function run()
 {
     if (array_key_exists('id', $_REQUEST) and $_REQUEST['id'] > 0) {
         $thing = Things::getThingByID($_REQUEST['id']);
     }
     /**
      * set options when thing is returned
      */
     if (!empty($_POST["stateafterreturn"])) {
         $thing->setStateAfterReturn($_POST["stateafterreturn"]);
         $thing->setDateOfReturn(date('Y-m-d'));
         /**
          * records can be saved after editing
          * exit the program after a successful storage
          * error massage when one of the $_POST field is empty
          */
         if ($thing->save()) {
             header('location:index.php?module=lentthingslist&friendid=' . $thing->getFriendId());
             exit;
         }
     } elseif (!empty($_POST["stateafterreturn"])) {
         $var = array('fehler' => "Bitte das leere Feld ausfüllen");
     }
     $var['thing'] = $thing;
     return $var;
 }