<?php
// DfmItem.php
// Copyright P.Kassel, M.Seliger, G.Trietsch, all Rights Reserved
namespace Docuform\Api\Server;use Docuform\Api\TableMapper;use Docuform\Database\DbSQL;use Docuform\Lib\ValidateParam;class DfmItem extends TableMapper{public const supply_key_automatic=1;public const supply_key_partno=2;public const supply_key_xml=3;public const supply_key_userdef=4;public $articleNo;public $colorant;public $id;public $name;public $partNo;public function getColumnMappings():array{return[['name'=>'Id','type'=>DbSQL::cst_intornull,'alias'=>['item'=>'id']],['name'=>'Name','type'=>DbSQL::cst_text,'alias'=>['item'=>'name']],['name'=>'Description','type'=>DbSQL::cst_text,'alias'=>['item'=>'description']],['name'=>'Colorant','type'=>DbSQL::cst_text,'alias'=>['item'=>'colorant']],['name'=>'SnmpType','type'=>DbSQL::cst_intornull,'alias'=>['item'=>'supplyType']],['name'=>'Manufacturer','type'=>DbSQL::cst_text,'alias'=>['item'=>'manufacturer']],['name'=>'PartNo','type'=>DbSQL::cst_text,'alias'=>['item'=>'partNo']],['name'=>'OriginalPartNo','type'=>DbSQL::cst_text,'alias'=>['item'=>'originalPartNo']],['name'=>'ArticleNo','type'=>DbSQL::cst_text,'alias'=>['item'=>'articleNo']],['name'=>'IsColorMarker','type'=>DbSQL::cst_bool,'alias'=>['item'=>'isColorMarker']],['name'=>'IsKit','type'=>DbSQL::cst_bool,'alias'=>['item'=>'isKit']],['name'=>'Pages','type'=>DbSQL::cst_intornull,'alias'=>['item'=>'pages']],['name'=>'Percentage','type'=>DbSQL::cst_numeric,'alias'=>['item'=>'percentage']],['name'=>'Price','type'=>DbSQL::cst_numeric,'precision'=>2,'alias'=>['item'=>'price']],['name'=>'sCurrency','type'=>DbSQL::cst_text,'alias'=>['item'=>'currency']],['name'=>'OrderUnit','type'=>DbSQL::cst_text,'alias'=>['item'=>'unit']],['name'=>'DeviceManagerId','type'=>DbSQL::cst_intornull,'alias'=>['item'=>'dealerId'],'visible'=>false],['name'=>'Created','type'=>DbSQL::cst_date,'alias'=>['item'=>'created'],'visible'=>false],['name'=>'CreatedBy','type'=>DbSQL::cst_text,'alias'=>['item'=>'createdBy'],'visible'=>false],['name'=>'Modified','type'=>DbSQL::cst_date,'alias'=>['item'=>'modified'],'visible'=>false],['name'=>'ModifiedBy','type'=>DbSQL::cst_text,'alias'=>['item'=>'modifiedBy'],'visible'=>false],['name'=>'VendorId','type'=>DbSQL::cst_intornull,'alias'=>['item'=>'vendorId'],'visible'=>false],['name'=>'pmdFile','type'=>DbSQL::cst_text,'alias'=>['item'=>'pmdFile'],'visible'=>false],['name'=>'pmdTitle','type'=>DbSQL::cst_text,'alias'=>['item'=>'pmdTitle'],'visible'=>false],['name'=>'KeyType','type'=>DbSQL::cst_intornull,'alias'=>['item'=>'keyType'],'visible'=>false],['name'=>'XmlName','type'=>DbSQL::cst_text,'alias'=>['item'=>'xmlName'],'visible'=>false],['name'=>'XmlDescription','type'=>DbSQL::cst_text,'alias'=>['item'=>'xmlDescription'],'visible'=>false]];}public function getParameterConstraints(string $method):array{if($method==='POST')return[['name'=>'name','maxLength'=>255,'required'=>true],['name'=>'description','maxLength'=>255],['name'=>'manufacturer','maxLength'=>64],['name'=>'articleNo','maxLength'=>32,'required'=>true,'type'=>ValidateParam::STRING_ASCII],['name'=>'partNo','maxLength'=>32,'required'=>true,'type'=>ValidateParam::STRING_ASCII],['name'=>'originalPartNo','maxLength'=>32,'required'=>true,'type'=>ValidateParam::STRING_ASCII],['name'=>'isKit','type'=>ValidateParam::BOOL_STRICT],['name'=>'pages','min'=>1,'max'=>PHP_INT_MAX],['name'=>'percentage'],['name'=>'price'],['name'=>'currency','maxLength'=>8],['name'=>'unit','maxLength'=>32]];return[];}public function read(int $id):void{$object=self::readAll($this->getContainer(),$id);if(!empty($object)){foreach($object as $key=>$value){$this->__set($key,$value);}}}public function __isset($name){return parent::__isset($name);}public function __set(string $name,mixed $value){if($name==='Pages'){if((int)$value===0)$value=null;}elseif($name==='sCurrency'){$value=$value==='&euro;'?'€':$value;}parent::__set($name,$value);}}