<?php
 
require_once($_SERVER['DOCUMENT_ROOT'] . '/sys/db.php');

class modImageCapture  {

  public function __construct($lo_id, $ic_id) {

    $this->lo_id = isset($lo_id) ? $lo_id : 0;
    $this->ic_id = isset($ic_id) ? $ic_id : 0;  
//print_r ("lo: $this->lo_id mm:$this->mm_id cf:$this->cf_id");      

    $dal = new DAL();
    
    $sql = "SELECT name FROM login WHERE id = $this->lo_id LIMIT 1 ";
    $this->login_name = $dal->query($sql)->name;

    $blank = array('1' => array("p_id"=>0, "bound_id"=>0, "descr"=>""));
    $this->image_blank = $this->toObject ($blank);

    $sql = "SELECT 0 AS id, 'Select' AS text " .
           "UNION ALL " .
           "SELECT id, name AS text " .
           "FROM space " ;
     $this->spaces = $dal->query($sql);

    $sql = "SELECT 0 AS id, 'Direction' AS text " .
           "UNION ALL " .
           "SELECT id, direction AS text " .
           "FROM cardinal " ;
     $this->cardinals = $dal->query($sql);

     $this->refcode = "Cust1234";
  }
  
  private function toObject($array) {
    $object = new stdClass();
    foreach ($array as $key => $value) {
      if (is_array($value)) {
        $value = $this->toObject($value);
      }
      $object->$key = $value;
    }
    return $object;
  }

  public function get($prop) {
    return $this->$prop;
  }
  
}

?>