public function beforeUpdate($tableHistory) { $entity_sequence = $this->_entity->getSequence(); if (count($entity_sequence) && isset($entity_sequence['dependence'])) { $dependence_field_itens = $entity_sequence['dependence']; if (!is_array($dependence_field_itens)) { $dependence_field_itens = array(0 => $dependence_field_itens); } foreach ($dependence_field_itens as $dependence_field) { $dependence_value = $this->_table->{$dependence_field}; if ($tableHistory[$dependence_field] != $dependence_value) { $seq = new SequenceModel(); $seq->changeSequence(array('tbl' => $this->getTableName(), 'id' => $this->getId(), 'sequence' => 0)); $f = new TableFilter($this->_table, array()); $f->sequence($this->_dao, $this->_entity)->filter('sequence'); } } } }
public function delete($itens) { foreach ($itens as $item) { $entity = $this->_entities->getEntity($item['name']); $entity_id = $entity->getId(); $entity_title = $entity->getTitle(); $entity_tbl = $entity->getTbl(); $entity_sequence = $entity->getSequence(); $model = $entity->getModel(); //_# Se ele não possui lixeira, ignora if (!$entity->hasTrash()) { //ignore } else { if (count($entity_sequence)) { $seq = new SequenceModel(); $seq->changeSequence(array('tbl' => $entity_tbl, 'id' => $item['id'], 'sequence' => 0)); } $tableHistory = $model->getById($item['id']); $this->deleteChildrens($entity, $item['id'], $tableHistory); $table = new Table($entity_tbl); $f = new TableFilter($table, array('is_del' => '1')); $f->timestamp()->filter('del_date'); $f->intval()->filter('is_del'); $this->_dao->update($table, array($entity_id . ' = ?' => $item['id'])); $this->log('T', $tableHistory[$entity_title], $table, $tableHistory); } } }