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

class modAddonForm  {

  public function __construct($lo_id, $su_id) {

    $this->lo_id = isset($lo_id) ? $lo_id : 0;
    $this->su_id = isset($su_id) ? $su_id : 0;

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

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

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

    $sql = "SELECT 1 AS id, 'Add' AS text, 0 AS type " .
           "UNION ALL " .
           "SELECT 0 AS id, 'Select' AS text, 1 AS type " .
           "UNION ALL " .
           "SELECT 2 AS id, 'Update' AS text, 1 AS type " .
           "UNION ALL " .
           "SELECT -1 AS id, 'Delete' AS text, 1 AS type " ;
    $this->ctrl_functions = $dal->query($sql);

$cnt =  count($this->ctrl_functions);
print_r ("mcnt:$cnt");

  }

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

?>