/** * Add or edit donation * CODE: donation_create */ public function executeUpdate(sfWebRequest $request) { # security if (!$this->getUser()->hasCredential(array('Administrator'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer()); $this->redirect('dashboard/index'); } if ($request->getParameter('id')) { $dona = DonationPeer::retrieveByPK($request->getParameter('id')); $this->forward404Unless($dona); $this->title = 'Edit donation'; $success = 'Donation information has been successfully changed!'; } else { $dona = new Donation(); $this->title = 'Add new donation'; $success = 'Donation information has been successfully created!'; } $this->form = new DonationForm($dona); if ($request->isMethod('post')) { $this->referer = $request->getParameter('referer'); $this->form->bind($request->getParameter('dona')); if ($this->form->isValid() && $this->form->getValue('campain_id') && $this->form->getValue('donor_id') && $this->form->getValue('fund_id') && $this->form->getValue('gift_type')) { $donor = DonorPeer::getByPersonId($this->form->getValue('donor_id')); if ($donor) { $id = $donor->getId(); } $dona->setDonorId($id); $dona->setGiftDate($this->form->getValue('gift_date')); $dona->setGiftAmount($this->form->getValue('gift_amount')); $dona->setDeductibleAmount($this->form->getValue('deductible_amount')); $dona->setGiftType($this->form->getValue('gift_type')); $dona->setCheckNumber($this->form->getValue('check_number')); $dona->setCampainId($this->form->getValue('campain_id')); $dona->setFundId($this->form->getValue('fund_id')); $dona->setGiftNote($this->form->getValue('gift_note')); $dona->setPrintedNote($this->form->getValue('printed_note')); $dona->setReceiptGeneratedDate($this->form->getValue('receipt_generated_date')); if ($this->form->getValue('follow_up') == null) { $dona->setFollowUp(0); } else { $dona->setFollowUp($this->form->getValue('follow_up')); } $dona->setPremiumOrderDate($this->form->getValue('premium_order_date')); $dona->save(); $this->getUser()->setFlash('success', $success); $this->redirect('@donation'); } else { $this->getUser()->setFlash('success', 'Please choice Donor, Gift Type, Campaign or Fund!'); } } else { # Set referer URL $this->referer = $request->getReferer() ? $request->getReferer() : '@danation'; } $this->dona = $dona; }
public function configure() { unset($this['id'], $this['tribute_first_name'], $this['tribute_last_name'], $this['tribute_address1'], $this['tribute_address2'], $this['tribute_city'], $this['tribute_state'], $this['tribute_zipcode'], $this['tribute_email'], $this['tribute_category'], $this['tribute_message'], $this['tribute_deliver_by'], $this['tribute_gift_id'], $this['person_id'], $this['processedDate'], $this['novapointe_id'], $this['ccard_approval_number'], $this['novapointe_fulfillment_id'], $this['novapointe_tracking_number'], $this['novapointe_ship_date'], $this['tribute_letter_sent_date'], $this['send_tribute_card'], $this['tribute_image_id'], $this['ecard_read_date'], $this['ecardEmailSentDate'], $this['ecard_email_sent_result']); $donars = DonorPeer::getForSelectParent(); $campains = CampaignPeer::getForSelectParent(); $funds = FundPeer::getForSelectParent(); $gift_types = GiftTypePeer::getForSelectParent(); # Fields $this->widgetSchema['donor_id'] = new sfWidgetFormChoice(array('choices' => $donars)); $this->widgetSchema['gift_date'] = new widgetFormDate(array('change_year' => true, 'change_month' => true, 'format_date' => array('js' => 'mm/dd/yy', 'php' => 'm/d/Y')), array('class' => 'text narrow')); $this->widgetSchema['gift_amount'] = new sfWidgetFormInput(array(), array('class' => 'text')); $this->widgetSchema['deductible_amount'] = new sfWidgetFormInput(array(), array('class' => 'text')); $this->widgetSchema['gift_type'] = new sfWidgetFormChoice(array('choices' => $gift_types)); $this->widgetSchema['check_number'] = new sfWidgetFormInput(array(), array('class' => 'text')); $this->widgetSchema['campain_id'] = new sfWidgetFormChoice(array('choices' => $campains)); $this->widgetSchema['fund_id'] = new sfWidgetFormChoice(array('choices' => $funds)); $this->widgetSchema['gift_note'] = new sfWidgetFormTextarea(array(), array('class' => 'text')); $this->widgetSchema['printed_note'] = new sfWidgetFormTextarea(array(), array('class' => 'text')); $this->widgetSchema['receipt_generated_date'] = new widgetFormDate(array('change_year' => true, 'change_month' => true, 'format_date' => array('js' => 'mm/dd/yy', 'php' => 'm/d/Y')), array('class' => 'text narrow')); $this->widgetSchema['follow_up'] = new sfWidgetFormInputCheckbox(array(), array('value' => 1)); $this->widgetSchema['premium_order_date'] = new widgetFormDate(array('change_year' => true, 'change_month' => true, 'format_date' => array('js' => 'mm/dd/yy', 'php' => 'm/d/Y')), array('class' => 'text narrow')); $this->widgetSchema->setLabels(array('donor_id' => 'Donor')); $this->widgetSchema->setLabels(array('gift_date' => 'Gift Date')); $this->widgetSchema->setLabels(array('gift_amount' => 'Gift Ammount')); $this->widgetSchema->setLabels(array('deductible_amount' => 'Deductible Amount')); $this->widgetSchema->setLabels(array('gift_type' => 'Gift Type')); $this->widgetSchema->setLabels(array('check_number' => 'Check Number')); $this->widgetSchema->setLabels(array('campain_id' => 'Campaign')); $this->widgetSchema->setLabels(array('fund_id' => 'Fund')); $this->widgetSchema->setLabels(array('gift_note' => 'Gift Note')); $this->widgetSchema->setLabels(array('printed_note' => 'Printed Note')); $this->widgetSchema->setLabels(array('receipt_generated_date' => 'Receipt Generated Date')); $this->widgetSchema->setLabels(array('follow_up' => 'Follow Up')); $this->widgetSchema->setLabels(array('premium_order_date' => 'Premium Order Date')); $this->validatorSchema['donor_id'] = new sfValidatorInteger(array('required' => true)); $this->validatorSchema['gift_date'] = new sfValidatorDate(array('max' => time(), 'required' => false)); $this->validatorSchema['gift_amount'] = new sfValidatorInteger(array('required' => false), array('invalid' => 'Gift ammount must ne in number format !')); $this->validatorSchema['deductible_amount'] = new sfValidatorInteger(array('required' => false)); $this->validatorSchema['gift_type'] = new sfValidatorInteger(array('required' => true)); $this->validatorSchema['check_number'] = new sfValidatorString(array('required' => false)); $this->validatorSchema['campain_id'] = new sfValidatorInteger(array('required' => true)); $this->validatorSchema['fund_id'] = new sfValidatorInteger(array('required' => true)); $this->validatorSchema['gift_note'] = new sfValidatorString(array('required' => false)); $this->validatorSchema['printed_note'] = new sfValidatorString(array('required' => false)); $this->validatorSchema['receipt_generated_date'] = new sfValidatorDate(array('max' => time(), 'required' => false), array('invalid' => 'Receipt Generated Date in invalid !.')); $this->validatorSchema['follow_up'] = new sfValidatorInteger(array('required' => false)); $this->validatorSchema['premium_order_date'] = new sfValidatorDate(array('max' => time(), 'required' => false), array('invalid' => 'Premium Order Date in invalid !.')); $this->widgetSchema->setNameFormat('dona[%s]'); }
/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this Person is new, it will return * an empty collection; or if this Person has previously * been saved, it will retrieve related Donors from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you * actually need in Person. */ public function getDonorsJoinCompany($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) { if ($criteria === null) { $criteria = new Criteria(PersonPeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collDonors === null) { if ($this->isNew()) { $this->collDonors = array(); } else { $criteria->add(DonorPeer::PERSON_ID, $this->id); $this->collDonors = DonorPeer::doSelectJoinCompany($criteria, $con, $join_behavior); } } else { // 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 the collection. $criteria->add(DonorPeer::PERSON_ID, $this->id); if (!isset($this->lastDonorCriteria) || !$this->lastDonorCriteria->equals($criteria)) { $this->collDonors = DonorPeer::doSelectJoinCompany($criteria, $con, $join_behavior); } } $this->lastDonorCriteria = $criteria; return $this->collDonors; }
/** * Get the associated Donor object * * @param PropelPDO Optional Connection object. * @return Donor The associated Donor object. * @throws PropelException */ public function getDonor(PropelPDO $con = null) { if ($this->aDonor === null && $this->donor_id !== null) { $c = new Criteria(DonorPeer::DATABASE_NAME); $c->add(DonorPeer::ID, $this->donor_id); $this->aDonor = DonorPeer::doSelectOne($c, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aDonor->addDonations($this); */ } return $this->aDonor; }
/** * 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 = DonorPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setCoDonorId($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setAffiliationId($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setBlockMailings($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setProspectComment($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setSalutation($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setCompanyId($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setPosition($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setDonorPotential($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setPersonId($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { $this->setDateAdded($arr[$keys[10]]); } if (array_key_exists($keys[11], $arr)) { $this->setDateUpdated($arr[$keys[11]]); } }
/** * Selects a collection of Donation objects pre-filled with all related objects except Fund. * * @param Criteria $c * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return array Array of Donation objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptFund(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $c = clone $c; // Set the correct dbName if it has not been overridden // $c->getDbName() will return the same object if not set to another value // so == check is okay and faster if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } DonationPeer::addSelectColumns($c); $startcol2 = DonationPeer::NUM_COLUMNS - DonationPeer::NUM_LAZY_LOAD_COLUMNS; DonorPeer::addSelectColumns($c); $startcol3 = $startcol2 + (DonorPeer::NUM_COLUMNS - DonorPeer::NUM_LAZY_LOAD_COLUMNS); GiftTypePeer::addSelectColumns($c); $startcol4 = $startcol3 + (GiftTypePeer::NUM_COLUMNS - GiftTypePeer::NUM_LAZY_LOAD_COLUMNS); CampaignPeer::addSelectColumns($c); $startcol5 = $startcol4 + (CampaignPeer::NUM_COLUMNS - CampaignPeer::NUM_LAZY_LOAD_COLUMNS); $c->addJoin(array(DonationPeer::DONOR_ID), array(DonorPeer::ID), $join_behavior); $c->addJoin(array(DonationPeer::GIFT_TYPE), array(GiftTypePeer::ID), $join_behavior); $c->addJoin(array(DonationPeer::CAMPAIN_ID), array(CampaignPeer::ID), $join_behavior); $stmt = BasePeer::doSelect($c, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = DonationPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = DonationPeer::getInstanceFromPool($key1))) { // We no longer rehydrate the object, since this can cause data loss. // See http://propel.phpdb.org/trac/ticket/509 // $obj1->hydrate($row, 0, true); // rehydrate } else { $omClass = DonationPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj1 = new $cls(); $obj1->hydrate($row); DonationPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined Donor rows $key2 = DonorPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = DonorPeer::getInstanceFromPool($key2); if (!$obj2) { $omClass = DonorPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); DonorPeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (Donation) to the collection in $obj2 (Donor) $obj2->addDonation($obj1); } // if joined row is not null // Add objects for joined GiftType rows $key3 = GiftTypePeer::getPrimaryKeyHashFromRow($row, $startcol3); if ($key3 !== null) { $obj3 = GiftTypePeer::getInstanceFromPool($key3); if (!$obj3) { $omClass = GiftTypePeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj3 = new $cls(); $obj3->hydrate($row, $startcol3); GiftTypePeer::addInstanceToPool($obj3, $key3); } // if $obj3 already loaded // Add the $obj1 (Donation) to the collection in $obj3 (GiftType) $obj3->addDonation($obj1); } // if joined row is not null // Add objects for joined Campaign rows $key4 = CampaignPeer::getPrimaryKeyHashFromRow($row, $startcol4); if ($key4 !== null) { $obj4 = CampaignPeer::getInstanceFromPool($key4); if (!$obj4) { $omClass = CampaignPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj4 = new $cls(); $obj4->hydrate($row, $startcol4); CampaignPeer::addInstanceToPool($obj4, $key4); } // if $obj4 already loaded // Add the $obj1 (Donation) to the collection in $obj4 (Campaign) $obj4->addDonation($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
/** * TODO: Check related records. * CODE:donor_delete */ public function executeDelete(sfWebRequest $request) { # security if (!$this->getUser()->hasCredential(array('Administrator'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer()); $this->redirect('dashboard/index'); } if ($request->isMethod('post')) { $donor = DonorPeer::retrieveByPK($request->getParameter('id')); $this->forward404Unless($donor); $this->getUser()->setFlash('success', 'Donor information has been successfully deleted!'); $donor->delete(); } return $this->redirect('@donor'); }
/** * 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(DonorPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(DonorPeer::DATABASE_NAME); $criteria->add(DonorPeer::ID, $pks, Criteria::IN); $objs = DonorPeer::doSelect($criteria, $con); } return $objs; }