예제 #1
0
 /**
  * Get the status of the class members, including number in database, scrapped quantity, stored quantity, etc
  * @since Version 3.8.7
  * @return array
  */
 public function getFleetStatus()
 {
     $query = "SELECT u.loco_id AS id, u.loco_num AS number, u.loco_name AS name, u.loco_status_id AS status_id, s.name AS status, u.photo_id, g.* FROM loco_unit AS u LEFT JOIN loco_status AS s ON u.loco_status_id = s.id LEFT JOIN loco_gauge AS g ON g.gauge_id = u.loco_gauge_id WHERE u.class_id = ? ORDER BY s.name";
     $return = array("num" => 0, "status" => array());
     foreach ($this->db->fetchAll($query, $this->id) as $row) {
         $return['num']++;
         if (!isset($return['status'][$row['status_id']])) {
             $return['status'][$row['status_id']] = array("id" => $row['status_id'], "name" => $row['status'], "num" => 0, "units" => array());
         }
         $row['url'] = Utility\LocosUtility::CreateUrl("loco", array($this->slug, $row['number']));
         $return['status'][$row['status_id']]['num']++;
         $return['status'][$row['status_id']]['units'][] = $row;
     }
     foreach ($return['status'] as $id => $row) {
         usort($return['status'][$id]['units'], function ($a, $b) {
             return strnatcmp($a['number'], $b['number']);
         });
     }
     return $return;
 }
예제 #2
0
 /**
  * Add an asset to this locomotive
  * @since Version 3.8
  * @param array $data
  * @return boolean
  */
 public function addAsset($data = false)
 {
     return Utility\LocosUtility::addAsset($this->namespace, $this->id, $data);
 }
예제 #3
0
 /**
  * List loco status types
  * Ported from \Railpage\Locos\Locos
  * @since Version 3.10.0
  * @return array
  */
 public static function getStatus()
 {
     $query = "SELECT * FROM loco_status ORDER BY name";
     return Utility\LocosUtility::getLocosComponents($query, "status");
 }