function mark_deleted($id, $timeline = true) { if ($this->is_latest) { $previousVersions = $this->getAllPreviousRevisions(); foreach ($previousVersions as $version) { $version->mark_deleted($version->id, false); //Do not correct timeline since we are deleting everything } if (!$this->load_relationship('oqc_service')) { $GLOBALS['log']->error("Could not load relationship to oqc_service. Cannot return the services related to this offering/contract!"); } else { $services = $this->get_linked_beans('oqc_service', 'oqc_Service'); foreach ($services as $service) { $service->mark_deleted($service->id); } } //Mark deleted also related oqc_services since they do not have UI } else { if (!$this->load_relationship('oqc_service')) { $GLOBALS['log']->error("Could not load relationship to oqc_service. Cannot return the services related to this offering/contract!"); } else { $services = $this->get_linked_beans('oqc_service', 'oqc_Service'); foreach ($services as $service) { $service->mark_deleted($service->id); } } } parent::mark_deleted($id); }
function mark_deleted($id, $timeline = true) { //If it is latest version, we need to mark_deleted also related oqc_additions and oqc_services, since there are no other way to remove them //mark_deleted also earlier versions of contract and reset contractid field of offering if offeringid is not empty. if ($this->is_latest) { $previousVersions = $this->getAllPreviousRevisions(); foreach ($previousVersions as $version) { $version->mark_deleted($version->id, false); //Do not correct timeline since we are deleting everything } /*if (!empty($this->offeringid)) { $offering = new oqc_Offering(); if ($offering->retrieve($this->offeringid)) { $offering->contractid = ''; $offering->update_date_modified = false; $offering->save(); } } */ if (!$this->load_relationship('oqc_service')) { $GLOBALS['log']->error("Could not load relationship to oqc_service. Cannot return the services related to this offering/contract!"); } else { $services = $this->get_linked_beans('oqc_service', 'oqc_Service'); foreach ($services as $service) { $service->mark_deleted($service->id); } } if (!$this->load_relationship('oqc_addition')) { $GLOBALS['log']->error("Could not load relationship to oqc_addition. Cannot return the services related to this offering/contract!"); } else { $additions = $this->get_linked_beans('oqc_addition', 'oqc_Addition'); foreach ($additions as $addition) { $addition->mark_deleted($addition->id, false); } } // $this->is_latest = false; //Sets is_latest fields as for deleted record // $this->save(); //If it is not latest, just make do fix for history panel correct timeline; it will be not accesible in any other way, too; //Mark deleted also related oqc_services and oqc_additions since they do not have UI } else { /* if ($timeline) { if (!empty($this->previousrevision)) { $previousVersion = new $this->object_name(); if ($previousVersion->retrieve($this->previousrevision)) { $previousVersion->nextrevisions = $this->nextrevisions; $previousVersion->update_date_modified = false; //Do not change date_modified field, since we do not modify it $previousVersion->save(); } } if (!empty($this->nextrevisions)) { $nextVersion = new $this->object_name(); if ($nextVersion->retrieve($this->nextrevisions)) { $nextVersion->previousrevision = $this->previousrevision; $nextVersion->update_date_modified = false; //Do not change date_modified field, since we do not modify it $nextVersion->save(); } } } if (!empty($this->offeringid)) { $offering = new oqc_Offering(); if ($offering->retrieve($this->offeringid)) { $offering->contractid = ''; $offering->update_date_modified = false; $offering->save(); } } */ if (!$this->load_relationship('oqc_service')) { $GLOBALS['log']->error("Could not load relationship to oqc_service. Cannot return the services related to this offering/contract!"); } else { $services = $this->get_linked_beans('oqc_service', 'oqc_Service'); foreach ($services as $service) { $service->mark_deleted($service->id); } } if (!$this->load_relationship('oqc_addition')) { $GLOBALS['log']->error("Could not load relationship to oqc_addition. Cannot return the services related to this offering/contract!"); } else { $additions = $this->get_linked_beans('oqc_addition', 'oqc_Addition'); foreach ($additions as $addition) { $addition->mark_deleted($addition->id); } } } parent::mark_deleted($id); }