<?php

//
class scale {

    public $is_debug = false;
    private $scale_row = array();

    //
    public function __construct($scale_row) {
        $this->set_scale_row($scale_row);
    }

    public static function scale_obj($scale_row) {
        $scale_library = CommonFunctions::get_scale_types(true, $scale_row['scale_type']);
        $scale = new $scale_library($scale_row);
        return $scale;
    }

    public function set_is_debug($is_debug = true) {
        $this->is_debug = $is_debug;
    }

    public function set_scale_row($scale_row) {
        $scale_row['scale_properties'] = json_decode($scale_row['scale_properties'], true);
        $this->scale_row = $scale_row;
    }

    public function get_scale_row($scale_key = null) {
        if (empty($scale_key))
            return $this->scale_row;
        return $this->scale_row[$scale_key];
    }

    public function get_scale_property($scale_prop = null) {
        if (empty($scale_prop))
            return $this->scale_row['scale_properties'];
        return $this->scale_row['scale_properties'][$scale_prop];
    }

    //to submit one or more products to the scale, even if it is submitted before
    public function register_products($products_arr) {
        return false;
    }

    //to assign specific key with specific product [$key_no is a value from 1 to 54], [$product_plu is of 6 numbers]
    public function assign_product_key($key_no, $product_plu) {
        return false;
    }

    //to reset all keys on the scale
    public function reset_all_keys() {
        return false;
    }

    //to remove products from the scale
    public function unregister_products($products_plu_arr) {
        return false;
    }

    //full register data [products & keys]
    public function full_register_products($data_arr) {
        return false;
    }

}
