public function __construct(Student $student, RoomDamage $damage)
 {
     $this->banner_id = $student->getBannerId();
     $this->damage_id = $damage->getId();
     $this->state = 'new';
     $this->amount = null;
 }
 public static function getResponsibilitiesByDmg(RoomDamage $damage)
 {
     $query = "select * from hms_room_damage_responsibility where damage_id = :damageId";
     $db = PdoFactory::getPdoInstance();
     $stmt = $db->prepare($query);
     $params = array('damageId' => $damage->getId());
     $stmt->execute($params);
     return $stmt->fetchAll(PDO::FETCH_CLASS, 'RoomDamageResponsibilityRestored');
 }
Esempio n. 3
0
 public static function save(RoomDamage $dmg)
 {
     $db = PdoFactory::getPdoInstance();
     $id = $dmg->getId();
     if (isset($id)) {
         // Update
         // TODO
         throw new Exception('Not yet implemented.');
         $query = "";
         $params = array();
     } else {
         // Insert
         $query = "INSERT INTO hms_room_damage (id, room_persistent_id, term, damage_type, note, repaired, reported_by, reported_on, side) VALUES (nextval('hms_room_damage_seq'), :persistentId, :term, :damageType, :note, :repaired, :reportedBy, :reportedOn, :side)";
         $params = array('persistentId' => $dmg->getRoomPersistentId(), 'term' => $dmg->getTerm(), 'damageType' => $dmg->getDamageType(), 'note' => $dmg->getNote(), 'repaired' => $dmg->isRepaired() ? 1 : 0, 'reportedBy' => $dmg->getReportedBy(), 'reportedOn' => $dmg->getReportedOn(), 'side' => $dmg->getSide());
     }
     $stmt = $db->prepare($query);
     $stmt->execute($params);
     // Update ID for a new object
     if (!isset($id)) {
         $dmg->setId($db->lastInsertId('hms_room_damage_seq'));
     }
 }
Esempio n. 4
0
 public function getRowTags()
 {
     // Get the damage types, if we don't already have them
     if (!isset(self::$damageTypes)) {
         self::$damageTypes = DamageTypeFactory::getDamageTypeAssoc();
     }
     $row = array();
     $row['CATEGORY'] = $row['DAMAGE_TYPE'] = self::$damageTypes[$this->getDamageType()]['category'];
     $row['DESCRIPTION'] = self::$damageTypes[$this->getDamageType()]['description'];
     $row['SIDE'] = $this->getSide();
     $row['TERM'] = Term::toString($this->getTerm());
     $row['REPORTED_ON'] = HMS_Util::get_long_date($this->getReportedOn());
     return $row;
 }