public function executePurchaseHistory(sfWebRequest $request) { $part_no = rawurldecode($request->getParameter('part_no')); $agent = new CCSearchAgent($part_no); if ($data = $agent->fetchPurchaseHistory()) { $json = json_encode($data); } else { $json = NULL; } //TODO: ajax helper for this block? $response = $this->getResponse(); $response->setContentType('application/json'); $response->sendHttpHeaders(); return $this->renderText($json); }
public function executeSearch(sfWebRequest $request) { $sa = new CCSearchAgent($request->getParameter('q')); // currently both searches use the same normalize strategy since SQL is similar $sa->normalizeQuery($this->_comp_suffix); $is_ajax = $request->isXmlHttpRequest(); if ($request->getParameter('for') == 'customer') { $this->serps = $sa->searchCustomers($is_ajax); $partial = 'quickCustSearchBox'; $data_type = 'customers'; } else { $this->serps = $sa->searchTickets($request->getParameter('category'), $is_ajax); $partial = 'quickTicketSearchBox'; $data_type = 'tickets'; } if ($is_ajax) { sfProjectConfiguration::getActive()->loadHelpers('Partial'); $this->setLayout(false); $html = get_partial($partial, array($data_type => $this->serps)); $response = $this->getResponse(); $response->addCacheControlHttpHeader('no-cache'); $response->setContentType('text/html'); $response->sendHttpHeaders(); return $this->renderText($html); } else { return sfView::SUCCESS; } }