Example #1
0
 public function configure()
 {
     unset($this['id'], $this['person_id'], $this['date_added'], $this['date_updated']);
     $sources = RefSourcePeer::getForSelectParent();
     $types = ContactTypePeer::getForSelectParent();
     $companies = CompanyPeer::getForSelectParent();
     # Fields
     $this->widgetSchema['ref_source_id'] = new sfWidgetFormChoice(array('choices' => $sources), array('class' => 'text narrow'));
     $this->widgetSchema['send_app_format'] = new sfWidgetFormInput(array(), array('class' => 'text'));
     $this->widgetSchema['comment'] = new sfWidgetFormInput(array(), array('class' => 'text'));
     $this->widgetSchema['letter_sent'] = 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['contact_type_id'] = new sfWidgetFormChoice(array('choices' => $types), array('class' => 'text narrow'));
     $this->widgetSchema['company_name'] = new sfWidgetFormChoice(array('choices' => $companies), array('class' => 'text narrow'));
     $this->widgetSchema->setLabels(array('person_id' => 'Person'));
     $this->widgetSchema->setLabels(array('ref_source_id' => 'Ref Source'));
     $this->widgetSchema->setLabels(array('send_app_format' => 'Send Application Format'));
     $this->widgetSchema->setLabels(array('comment' => 'Comment'));
     $this->widgetSchema->setLabels(array('letter_sent' => 'Letter Sent'));
     $this->widgetSchema->setLabels(array('contact_type_id' => 'Contact Type'));
     $this->widgetSchema->setLabels(array('company_name' => 'Company Name'));
     $this->validatorSchema['ref_source_id'] = new sfValidatorInteger(array('required' => false));
     $this->validatorSchema['send_app_format'] = new sfValidatorString(array('required' => false));
     $this->validatorSchema['comment'] = new sfValidatorString(array('required' => false));
     $this->validatorSchema['letter_sent'] = new sfValidatorDate(array('max' => time(), 'required' => false), array('invalid' => 'Letter sent is invalid !.'));
     $this->validatorSchema['contact_type_id'] = new sfValidatorInteger(array('required' => false));
     $this->validatorSchema['company_name'] = new sfValidatorInteger(array('required' => false));
     $this->widgetSchema->setNameFormat('contact[%s]');
 }
 public function configure()
 {
     $ref_sources = RefSourcePeer::getForSelectParent();
     $contact_types = ContactTypePeer::getForSelectParent();
     $this->setWidgets(array('id' => new sfWidgetFormInputHidden(), 'ref_source_id' => new sfWidgetFormSelect(array('choices' => $ref_sources)), 'send_app_format' => new sfWidgetFormInput(array(), array('class' => 'text')), 'comment' => new sfWidgetFormInput(array(), array('class' => 'text')), 'contact_type_id' => new sfWidgetFormSelect(array('choices' => $contact_types)), 'letter_sent_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('ref_source_id' => 'Ref Source*', 'send_app_format' => 'Send Application Format', 'comment' => 'Comment', 'contact_type_id' => 'Contact Type*', 'letter_sent_date' => 'Letter Sent Date'));
     $this->setValidators(array('id' => new sfValidatorPropelChoice(array('model' => 'ContactRequest', 'column' => 'id', 'required' => false)), 'ref_source_id' => new sfValidatorChoice(array('choices' => array_keys($ref_sources), 'required' => false)), 'send_app_format' => new sfValidatorString(array('max_length' => 40)), 'comment' => new sfValidatorString(array('max_length' => 40, 'required' => false)), 'contact_type_id' => new sfValidatorChoice(array('choices' => array_keys($contact_types), 'required' => false)), 'letter_sent_date' => new sfValidatorString(array('max_length' => 25, 'required' => false))));
     $this->widgetSchema->setNameFormat('contact_request[%s]');
 }
Example #3
0
 /**
  * Get the associated ContactType object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     ContactType The associated ContactType object.
  * @throws     PropelException
  */
 public function getContactType(PropelPDO $con = null)
 {
     if ($this->aContactType === null && $this->contact_type_id !== null) {
         $c = new Criteria(ContactTypePeer::DATABASE_NAME);
         $c->add(ContactTypePeer::ID, $this->contact_type_id);
         $this->aContactType = ContactTypePeer::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->aContactType->addContacts($this);
         		 */
     }
     return $this->aContactType;
 }
Example #4
0
echo $contact_request->getRefSourceId() ? RefSourcePeer::retrieveByPK($contact_request->getRefSourceId()) : '--';
?>
</dd>
      <dt class="dt1">Send Application Format:</dt>
              <dd><?php 
echo $contact_request->getSendAppFormat() ? $contact_request->getSendAppFormat() : '--';
?>
</dd>
      <dt class="dt1">Comment:</dt>
              <dd><?php 
echo $contact_request->getComment() ? $contact_request->getComment() : '--';
?>
</dd>
      <dt class="dt1">Contact Type:</dt>
      <dd><?php 
echo $contact_request->getContactTypeId() ? ContactTypePeer::retrieveByPK($contact_request->getContactTypeId()) : '--';
?>
</dd>
      <dt class="dt1">Letter to Send:</dt>
              <dd><?php 
echo $contact_request->getLetterToSend() ? $contact_request->getLetterToSend() : '--';
?>
</dd>
      <dt class="dt1">Letter Sent:</dt>
              <dd><?php 
echo $contact_request->getLetterSentDate('m/d/Y') ? $contact_request->getLetterSentDate('m/d/Y') : '--';
?>
</dd>
      <dt class="dt1">Request Date:</dt>
                <dd><?php 
echo $contact_request->getRequestDate() ? $contact_request->getRequestDate('m/d/Y') : '--';
Example #5
0
 /**
  * Selects a collection of Contact objects pre-filled with all related objects except RefSource.
  *
  * @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 Contact objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptRefSource(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);
     }
     ContactPeer::addSelectColumns($c);
     $startcol2 = ContactPeer::NUM_COLUMNS - ContactPeer::NUM_LAZY_LOAD_COLUMNS;
     PersonPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + (PersonPeer::NUM_COLUMNS - PersonPeer::NUM_LAZY_LOAD_COLUMNS);
     ContactTypePeer::addSelectColumns($c);
     $startcol4 = $startcol3 + (ContactTypePeer::NUM_COLUMNS - ContactTypePeer::NUM_LAZY_LOAD_COLUMNS);
     $c->addJoin(array(ContactPeer::PERSON_ID), array(PersonPeer::ID), $join_behavior);
     $c->addJoin(array(ContactPeer::CONTACT_TYPE_ID), array(ContactTypePeer::ID), $join_behavior);
     $stmt = BasePeer::doSelect($c, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = ContactPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = ContactPeer::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 = ContactPeer::getOMClass();
             $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             ContactPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined Person rows
         $key2 = PersonPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = PersonPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $omClass = PersonPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 PersonPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (Contact) to the collection in $obj2 (Person)
             $obj2->addContact($obj1);
         }
         // if joined row is not null
         // Add objects for joined ContactType rows
         $key3 = ContactTypePeer::getPrimaryKeyHashFromRow($row, $startcol3);
         if ($key3 !== null) {
             $obj3 = ContactTypePeer::getInstanceFromPool($key3);
             if (!$obj3) {
                 $omClass = ContactTypePeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj3 = new $cls();
                 $obj3->hydrate($row, $startcol3);
                 ContactTypePeer::addInstanceToPool($obj3, $key3);
             }
             // if $obj3 already loaded
             // Add the $obj1 (Contact) to the collection in $obj3 (ContactType)
             $obj3->addContact($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
Example #6
0
 /**
  * Add or edit contact type
  * CODE:contact_type_create
  */
 public function executeUpdateType(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')) {
         $contact_type = ContactTypePeer::retrieveByPK($request->getParameter('id'));
         $this->title = 'Edit Contact Type';
         $success = 'Contact Type Information has successfully created!';
     } else {
         $contact_type = new ContactType();
         $this->title = 'Edit Contact Type';
         $success = 'Contact Type Information has successfully created!';
     }
     $this->form = new ContactTypeForm($contact_type);
     if ($request->isMethod('post')) {
         $this->referer = $request->getReferer();
         $this->form->bind($request->getParameter('con_type'));
         if ($this->form->isValid()) {
             $contact_type->setContactTypeDesc($this->form->getValue('contact_type_desc'));
             $contact_type->save();
             $this->getUser()->setFlash('success', $success);
             $this->redirect('ctype');
         }
     } else {
         $this->referer = $request->getReferer() ? $request->getReferer() : '@ctype';
     }
     $this->contact_type = $contact_type;
 }
Example #7
0
 /**
  * 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(ContactTypePeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(ContactTypePeer::DATABASE_NAME);
         $criteria->add(ContactTypePeer::ID, $pks, Criteria::IN);
         $objs = ContactTypePeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Example #8
0
 /**
  * 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 = ContactTypePeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setContactTypeDesc($arr[$keys[1]]);
     }
 }