<?php



/*



	Module Name: Surface (Area) / Volume Calculator for Prestashop 1.5

	Module URI: Please contact with info@megventure.com

	Description: A utility to calculate quantity in area or volume units

	Version: 1.0

	Author: MEG Venture



	Copyright 2013, MEG Venture (info@megventure.com)



	This program is not a free software: you can't redistribute it and/or modify

	it. All rights reserved to MEG Venture.





	This copyright notice  and licence should be retained in all modules based on this framework.

	This does not affect your rights to assert copyright over your own original work.



*/







class Squaremeter_Admin extends ObjectModel

{

	/** @var string Name */

	public $id_squaremeteradmin;



	/** @var integer */

	public $id_product;



	/** @var string */

	public $displaycalculator;

	public $calculationtype;
	
	public $additionalquantity;		

	public $displayquantity;	
	
	public $displayprice;		

	public $conversion;	

	public $maxwidth;

	public $minwidth;

	public $minheight;	

	public $maxheight;	

	public $mindepth;	

	public $maxdepth;	

	public $conversionunit;			

	public $maxwidthunit;

	public $minwidthunit;

	public $minheightunit;	

	public $maxheightunit;	

	public $mindepthunit;	

	public $maxdepthunit;				



    /**

     * @see ObjectModel::$definition

     */



    public static $definition = array(

        'table' => 'squaremeteradmin',

        'primary' => 'id_squaremeteradmin',

        'multilang' => FALSE,

        'fields' => array(

            'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isInt', 'required' => TRUE),

            'displaycalculator' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),

            'calculationtype' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),			
			
            'additionalquantity' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),	
			
            'displayquantity' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),		
			
            'displayprice' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),												

			'conversion' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),

			'maxwidth' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),

			'minwidth' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),

			'minheight' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),			

			'maxheight' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),

			'mindepth' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),			

			'maxdepth' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),			

			'conversionunit' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),

			'maxwidthunit' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),

			'minwidthunit' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),

			'minheightunit' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),			

			'maxheightunit' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),	

			'mindepthunit' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),			

			'maxdepthunit' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),					

        ),

    );


    public static function loadByIdProduct($id_product){

        $result = Db::getInstance()->getRow('

            SELECT *

            FROM `'._DB_PREFIX_.'squaremeteradmin` sample

            WHERE sample.`id_product` = '.(int)$id_product

        );



        return new Squaremeter_Admin($result['id_squaremeteradmin']);

    }

}

