<?php
namespace Entity; class BspSettlementRecord extends \App\Entity\GeneralAbstract { protected $saveInsideTransaction = false; const cacheTtl=7200; protected $dataTableName; protected $tablePrimaryKey = 'key'; protected $primaryKeyType = 'string'; protected function setTableName(): void { global $DBTBspSettlementRecords; $this->tableName = $DBTBspSettlementRecords; } static public function delete($idService) { throw new \Exception('Not developed.'); } static public function updateOperationalStatus($idEntity) { return new self('updateOperationalStatus', $idEntity); } protected function getAttribute($var) { switch ($var) { case 'status': { if (!is_array($this->fields[$var])) { $this->fields[$var] = explode(",", $this->fields[$var]); } return $this->fields[$var]; } default: { return parent::getAttribute($var); } } } protected function setAttribute($var, $value) { switch ($var) { case 'key': case 'bspRecordId': case 'importedServiceId': case 'importedServiceIsRefund': case 'status': case 'ticketStatus': case 'ticketNumber': case 'ticketDate': case 'idOffice': case 'comparisonInProgress': { $this->fields[$var] = $value; break; } case 'operationalStatus': case 'operationalDateTime': case 'operationalUser': { if ($this->operation != 'updateOperationalStatus') { throw new \Exception("The field '$var' can only be set when the operation is 'updateOperationalStatus'."); } $this->fields[$var] = $value; break; } default: { throw new \Exception("The field '$var' is not valid for the `".__CLASS__."` entity."); } } } protected function save_filterSaveData(Array $saveData) { if ($saveData['status']) { $saveData['status'] = implode(",", $saveData['status']); } return $saveData; } protected function save_finalSaveData(Array $saveData) { if ($this->operation == 'insert') { $saveData['addTime'] = DATETIME; } if ($this->operation == 'updateOperationalStatus') { $saveData['operationalDateTime'] = DATETIME; $saveData['operationalUser'] = CURRENT_ID_USER; } return $saveData; } } 