id = $tableData->id; $this->comment = $tableData->comment; $this->categoryId = $tableData->category_id; $this->subAmount = $tableData->subamount; } public function setFormdata( $id, $comment, $categoryId, $amountIn, $amountOut ) { $this->id = $id; $this->comment = $comment; $this->categoryId = $categoryId; $this->subAmount = str2num( $amountIn ) - str2num( $amountOut ); } function getId() { return $this->id; } function getComment() { return $this->comment; } function getAmountIn() { return (0.0 < $this->subAmount) ? abs( $this->subAmount ): 0; } function getAmountOut() { return (0.0 > $this->subAmount) ? abs( $this->subAmount ) : 0; } function getCategoryName() { return $this->ci->mCategory->getFullCategoryName( $this->categoryId )->titel; } function getCategoryId() { return $this->categoryId; } function getFunction() { if ( ($this->id == 0) && ($this->subAmount != 0.0) ) return 'insert'; elseif ( ($this->id != 0) && ($this->subAmount == 0.0) ) return 'delete'; elseif ( $this->id != 0 ) return 'update'; return FALSE; } function getData( $adds ) { return array_merge( $adds, array('id' => $this->id, 'comment' => $this->comment, 'category_id' => $this->categoryId, 'subamount' => $this->subAmount) ); } function setAmount( $amount ) { $this->subAmount = $amount; } } class Booking { private $id = 0; private $billNumber = NULL; private $date = ''; private $receiver = ''; private $sourceId = NULL; private $targetId = NULL; private $amount = NULL; private $comment = ''; private $validate = FALSE; private $authorId = 0; private $type = 'bill'; private $subs = NULL; private $ci; public function __construct() { $this->date = date( "Y-m-d" ); } public function __sleep() { return array('id', 'billNumber', 'date', 'receiver', 'sourceId', 'targetId', 'amount', 'comment', 'validate', 'authorId', 'type', 'subs'); } public function __wakeup() { } public function getData() { return array( 'id' => $this->id, 'renummer' => $this->billNumber, 'datum' => $this->date, 'receiver' => $this->receiver, 'source_id' => $this->sourceId, 'target_id' => $this->targetId, 'amount' => $this->amount, 'comment' => $this->comment, 'type' => $this->type, 'author_id' => $this->authorId, 'validate' => $this->validate ); } public function getBillNumber() { return $this->billNumber; } public function setBillNumber( $billNumber ) { $this->billNumber = $billNumber; } public function setReceiver( $receiver ) { $this->receiver = $receiver; } public function getReceiver() { return $this->receiver; } public function setId( $id ) { $this->id = $id; } public function getId() { return $this->id; } public function getComment() { return $this->comment; } public function setComment( $comment ) { $this->comment = $comment; } public function setDate( $date ) { $this->date = date( "Y-m-d", strtotime( $date ) ); } public function getDate( $format = 'd.m.Y' ) { return date( $format, strtotime( $this->date ) ); } public function setSourceId( $sourceId ) { $this->sourceId = $sourceId; } public function getSourceId() { return $this->sourceId; } public function setTargetId( $targetId ) { $this->targetId = $targetId; } public function getTargetId() { return $this->targetId; } public function setAmount( $amount ) { $this->amount = $amount; } public function getAmount() { if ( $this->amount === NULL ) return NULL; return number_format( abs( $this->amount ), 2, ',', '.' ); } public function setValidate( $validate ) { $this->validate = $validate; } public function getValidate() { return $this->validate; } public function getInput() { return (0.0 <= $this->amount) ? number_format( abs( $this->amount ), 2, ',', '.' ) : NULL; } public function isInput() { return ((!is_null( $this->amount )) && (0.0 <= $this->amount)); } public function getOutput() { return (0.0 > $this->amount) ? number_format( abs( $this->amount ), 2, ',', '.' ) : NULL; } public function isOutput() { return (is_null( $this->amount ) || 0.0 > $this->amount); } public function getSourceName() { return $this->ci->mCategory->getFullCategoryName( $this->sourceId )->titel; } public function getTargetName() { return $this->ci->mCategory->getFullCategoryName( $this->targetId )->titel; } public function areDetailsAvail() { return (count( $this->subs ) > 0); } public function getBookingDetails() { return $this->subs; } public function setAuthorId( $authorId ) { $this->authorId = $authorId; } public function setType( $type ) { $this->type = $type; } public function getType() { return $this->type; } // public function __set($key, $value) // { // $this->$key = $value; // } // public function __get($key) // { // return $this->{$key}; // } } ?>