예제 #1
0
 public function executeDeleteFacility()
 {
     $locate = LocationPeer::retrieveByPk($this->getRequestParameter('location_id'));
     $this->forward404Unless($locate);
     $c = new Criteria();
     $c->add(FacilityLocationPeer::ID, $this->getRequestParameter('id'));
     $facility = FacilityLocationPeer::doSelectOne($c);
     $facility->delete();
     return $this->forward('locate', 'listFacility?id=' . $locate->getId());
 }
예제 #2
0
 public function executeDeleteFacilityEdit()
 {
     $c = new Criteria();
     $c->add(FacilityLocationPeer::ID, $this->getRequestParameter('facility_id'));
     $facility_location = FacilityLocationPeer::doSelectOne($c);
     $ref_error = 0;
     foreach ($facility_location->getRefCountMethods() as $ref) {
         $method = "count" . $ref['affix'];
         $count = $facility_location->{$method}();
         if ($count > 0) {
             ++$ref_error;
             $this->getRequest()->setError('location/deleteFacilityEdit/' . sfInflector::camelize($ref['table']), $count);
         }
     }
     if ($ref_error > 0) {
         $this->getRequest()->setError('location/deleteFacilityEdit', '_ERR_DELETE_ (' . $facility_location->getFacility()->getName() . ' - id:' . $facility_location->getId() . ')');
     } else {
         $facility_location->delete();
     }
     #return $this->forward('location', 'list');
     return $this->redirect('location/edit?id=' . $this->getRequestParameter('id'));
 }