public function executeContacts() { $filter_form = new FilterContactForm(); $filter_form->bindSelf('tc' . $this->target_list->getId()); $this->form = $filter_form; $page = isset($this->page) ? $this->page : 1; $contact_table = ContactTable::getInstance(); $this->contacts = new policatPager($filter_form->filter($contact_table->queryByTargetList($this->target_list)), $page, 'target_contact_pager', array('id' => $this->target_list->getId()), true, 20); if (isset($this->last_page) && $this->last_page) { $this->contacts = new policatPager($filter_form->filter($contact_table->queryByTargetList($this->target_list)), $this->contacts->getLastPage(), 'target_contact_pager', array('id' => $this->target_list->getId()), true, 20); } }
/** * * @param Doctrine_Query $query * @param FilterContactForm $filter * @return Doctrine_Query */ public function filter(Doctrine_Query $query, $filter) { if (!$filter) { return $query; } $alias = $query->getRootAlias(); $search = trim($filter->getValue(self::FILTER_SEARCH)); if ($search) { $query->andWhere('concat(' . $alias . '.email, " ", ' . $alias . '.firstname, " ", ' . $alias . '.lastname) LIKE ?', '%' . $search . '%'); } return $query; }
public function executeStats(sfWebRequest $request) { $petition = PetitionTable::getInstance()->findById($request->getParameter('id'), $this->userIsAdmin()); /* @var $petition Petition */ if (!$petition) { return $this->notFound(); } if (!$petition->isEditableBy($this->getGuardUser())) { return $this->noAccess(); } if ($petition->getKind() != Petition::KIND_PLEDGE) { return $this->noAccess(); } if ($petition->getMailingListId()) { $mailing_list = $petition->getMailingList(); $filter_form = new FilterContactForm(); $filter_form->bindSelf('p' . $petition->getId()); $page = $request->getUrlParameter('page'); if ($page < 1) { $page = 1; } $contact_table = ContactTable::getInstance(); $contacts = new policatPager($filter_form->filter($contact_table->queryByTargetList($mailing_list, $petition)), $page, 'pledge_stats_pager', array('id' => $petition->getId()), true, 20); $active_pledge_item_ids = $petition->getActivePledgeItemIds(); $pledges = PledgeTable::getInstance()->getPledgesForContacts($contacts->getResults(), $active_pledge_item_ids); $pledge_items = PledgeItemTable::getInstance()->fetchByIds($active_pledge_item_ids); if ($request->getUrlParameter('page')) { return $this->ajax()->replaceWithPartial('#contacts', 'contacts', array('contacts' => $contacts, 'petition_id' => $petition->getId(), 'active_pledge_item_ids' => $active_pledge_item_ids, 'pledges' => $pledges, 'pledge_items' => $pledge_items))->tooltip('#contacts .add_tooltip')->render(); } $this->form = $filter_form; $this->petition = $petition; $this->contacts = $contacts; $this->no_target_list = false; $this->active_pledge_item_ids = $active_pledge_item_ids; $this->pledges = $pledges; $this->pledge_items = $pledge_items; } else { $this->no_target_list = true; } }