public function delete() { $flash = Flash::Instance(); $errors = array(); $data = array('id' => $this->_data['id'], 'end_date' => date(DATE_FORMAT)); $outside_op = MFOutsideOperation::Factory($data, $errors, 'MFOutsideOperation'); if (count($errors) > 0 || !$outside_op->save()) { $errors[] = 'Could not delete outside operation'; } if (count($errors) == 0) { $stitem = new STItem(); if ($stitem->load($outside_op->stitem_id)) { //$stitem->calcLatestCost(); if (!$stitem->rollUp(STItem::ROLL_UP_MAX_LEVEL)) { $errors[] = 'Could not roll-up latest costs'; $db->FailTrans(); } } else { $errors[] = 'Could not roll-up latest costs'; $db->FailTrans(); } } if (count($errors) == 0) { $flash->addMessage('Outside operation deleted'); sendTo('STItems', 'viewoutside_operations', $this->_modules, array('id' => $this->_data['stitem_id'])); } else { $flash->addErrors($errors); sendBack(); } }