/** * Retrieve a single object by event id. * * @param int $pk the primary key. * @param PropelPDO $con the connection to use * @return EventReservation */ public static function retrieveByEventId($pk) { $criteria = new Criteria(); $criteria->add(EventReservationPeer::EVENT_ID, $pk); $v = EventReservationPeer::doSelect($criteria); return $v; }
public function executeDelete(sfWebRequest $request) { #security if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Volunteer'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer()); $this->redirect('dashboard/index'); } $request->checkCSRFProtection(); $this->forward404Unless($event_reservation = EventReservationPeer::retrieveByPk($request->getParameter('id')), sprintf('Object event_reservation does not exist (%s).', $request->getParameter('id'))); $event_reservation->delete(); $this->redirect('eventReservation/index'); }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(EventReservationPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(EventReservationPeer::DATABASE_NAME); $criteria->add(EventReservationPeer::ID, $pks, Criteria::IN); $objs = EventReservationPeer::doSelect($criteria, $con); } return $objs; }
public function executeDelete(sfWebRequest $request) { if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Volunteer'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer()); $this->redirect('dashboard/index'); } $request->checkCSRFProtection(); $this->forward404Unless($event = EventPeer::retrieveByPk($request->getParameter('id')), sprintf('Object event does not exist (%s).', $request->getParameter('id'))); $event_reservation = EventReservationPeer::retrieveByEventId($event->getId()); if (is_array($event_reservation)) { foreach ($event_reservation as $e_r) { $e_r->delete(); } } $event->delete(); $success = 'Event information has been successfully deleted!'; $this->getUser()->setFlash("success", $success); $this->redirect('event/index'); }
/** * Returns the number of related EventReservation objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related EventReservation objects. * @throws PropelException */ public function countEventReservations(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(EventPeer::DATABASE_NAME); } else { $criteria = clone $criteria; } if ($distinct) { $criteria->setDistinct(); } $count = null; if ($this->collEventReservations === null) { if ($this->isNew()) { $count = 0; } else { $criteria->add(EventReservationPeer::EVENT_ID, $this->id); $count = EventReservationPeer::doCount($criteria, $con); } } else { // criteria has no effect for a new object if (!$this->isNew()) { // the following code is to determine if a new query is // called for. If the criteria is the same as the last // one, just return count of the collection. $criteria->add(EventReservationPeer::EVENT_ID, $this->id); if (!isset($this->lastEventReservationCriteria) || !$this->lastEventReservationCriteria->equals($criteria)) { $count = EventReservationPeer::doCount($criteria, $con); } else { $count = count($this->collEventReservations); } } else { $count = count($this->collEventReservations); } } return $count; }
public function executeInstrumentNotication(sfWebRequest $request) { $c = new Criteria(); $c->add(PersonRolePeer::PERSON_ID, $this->getUser()->getId()); $c->addJoin(PersonRolePeer::ROLE_ID, RoleNotificationPeer::ROLE_ID); $personNotification = RoleNotificationPeer::doSelect($c); $this->mid = 0; foreach ($personNotification as $key => $value) { $this->mid = $value->getMid(); $this->notification = $value->getNotification(); //5. person add if ($this->mid == 5 && ($this->notification == 2 || $this->notification == 3)) { $c = new Criteria(); $c->addDescendingOrderByColumn(PersonPeer::ID); $c->setLimit(5); $this->newperson = PersonPeer::doSelect($c); } } $this->host = $request->getHost(); $this->memberId = $this->getUser()->getMemberId(); //$query = "SELECT COUNT(pilot_request.accepted) FROM pilot_request "; //$query .="WHERE pilot_request.accepted = 1 AND pilot_request.processed = 1 AND pilot_request.member_id = ".$this->memberId; //$con = Propel::getConnection(); //$stmt = $con->prepare($query); //$stmt->execute(); /*if($rs = $stmt->fetch(PDO::FETCH_NUM)) { $count = (int)$rs[0]; }else{ $count = 0; }*/ $c = new Criteria(); $c->add(PilotRequestPeer::ACCEPTED, 1); $c->add(PilotRequestPeer::PROCESSED, 1); $c->add(PilotRequestPeer::MEMBER_ID, $this->memberId); $this->totalAccepted = PilotRequestPeer::doCount($c); /* $this->memberId = $this->getUser()->getMemberId(); $query = "SELECT COUNT(pilot_request.accepted) FROM pilot_request "; $query .="WHERE pilot_request.accepted = 0 AND pilot_request.member_id = $this->memberId"; $con = Propel::getConnection(); $stmt = $con->prepare($query); $stmt->execute(); if($rs = $stmt->fetch(PDO::FETCH_NUM)) { $count = (int)$rs[0]; }else{ $count = 0; }*/ $c = new Criteria(); $c->add(PilotRequestPeer::ACCEPTED, 0); $c->add(PilotRequestPeer::MEMBER_ID, $this->memberId); $this->totaldeclined = PilotRequestPeer::doCount($c); $c = new Criteria(); $c->add(MissionLegPeer::PILOT_ID, $this->getUser()->getPilotId()); $c->add(MissionLegPeer::CANCEL_MISSION_LEG, 0); $this->totalMissionCancellation = MissionLegPeer::doCount($c); //total signup events count $pilot_id = $this->getUser()->getPilotId(); if ($pilot_id) { $pilot = PilotPeer::retrieveByPK($pilot_id); $member_id = $pilot->getMemberId(); $date = date('Y-m-d'); $c = new Criteria(); $c->add(EventReservationPeer::MEMBER_ID, $member_id, Criteria::EQUAL); $c->addJoin(EventPeer::ID, EventReservationPeer::EVENT_ID); $c->add(EventPeer::EVENT_DATE, $date, Criteria::GREATER_EQUAL); $this->totalSignupEvents = EventReservationPeer::doCount($c); } // }
/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. * The default key type is the column's phpname (e.g. 'AuthorId') * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = EventReservationPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setEventId($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setMemberId($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setReservationDate($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setFirstName($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setLastName($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setAddress($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setCity($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setState($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setZipcode($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { $this->setPhone($arr[$keys[10]]); } if (array_key_exists($keys[11], $arr)) { $this->setEmail($arr[$keys[11]]); } if (array_key_exists($keys[12], $arr)) { $this->setAdultGuests($arr[$keys[12]]); } if (array_key_exists($keys[13], $arr)) { $this->setChildGuests($arr[$keys[13]]); } if (array_key_exists($keys[14], $arr)) { $this->setGuestNames($arr[$keys[14]]); } if (array_key_exists($keys[15], $arr)) { $this->setAmtPaid($arr[$keys[15]]); } if (array_key_exists($keys[16], $arr)) { $this->setMethodOfPayment($arr[$keys[16]]); } if (array_key_exists($keys[17], $arr)) { $this->setPaymentDate($arr[$keys[17]]); } if (array_key_exists($keys[18], $arr)) { $this->setAuthNumber($arr[$keys[18]]); } if (array_key_exists($keys[19], $arr)) { $this->setStatus($arr[$keys[19]]); } if (array_key_exists($keys[20], $arr)) { $this->setComments($arr[$keys[20]]); } if (array_key_exists($keys[21], $arr)) { $this->setCollectSecureInfo($arr[$keys[21]]); } if (array_key_exists($keys[22], $arr)) { $this->setAddlInfoFields($arr[$keys[22]]); } if (array_key_exists($keys[23], $arr)) { $this->setNovapointeTransId($arr[$keys[23]]); } }