/**
  * Returns all award receipts for the given user
  * @param User $user
  * @return InternalAwardReceipts
  */
 private static function getByUser(User $user)
 {
     global $db;
     $query = "SELECT a.`id` as `award_receipt_id`, c.`id` as award_id, a.`user_id` , c.title, c.award_terms, c.disabled, a.year \n\t\t\t\tFROM `" . DATABASE_NAME . "`.`student_awards_internal` a \n\t\t\t\tleft join `" . DATABASE_NAME . "`.`student_awards_internal_types` c on c.id = a.award_id \n\t\t\t\tWHERE a.`user_id` = " . $db->qstr($user->getID()) . " \n\t\t\t\torder by a.year desc";
     $results = $db->GetAll($query);
     $receipts = array();
     if ($results) {
         foreach ($results as $result) {
             $award = InternalAward::fromArray($result);
             //for caching purposes
             $receipt = InternalAwardReceipt::fromArray($result);
             $receipts[] = $receipt;
         }
     }
     return new self($receipts);
 }
 /**
  * 
  * @param int $award_receipt_id
  * @return AwardRecipient
  */
 public static function get($award_receipt_id)
 {
     global $db;
     $query = "SELECT a.id as award_receipt_id, user_id, award_id, c.title, c.award_terms, c.disabled, a.year \n\t\t\t\tFROM `" . DATABASE_NAME . "`.`student_awards_internal` a \n\t\t\t\tleft join `" . DATABASE_NAME . "`.`student_awards_internal_types` c on c.id = a.award_id \n\t\t\t\tWHERE a.id = " . $db->qstr($award_receipt_id);
     $result = $db->GetRow($query);
     if ($result) {
         $award = InternalAward::fromArray($result);
         return InternalAwardReceipt::fromArray($result);
     } else {
         add_error("Failed to retreive award receipt from database.");
         application_log("error", "Unable to retrieve a student_awards_internal record. Database said: " . $db->ErrorMsg());
     }
 }