public function executeOrphans(sfWebRequest $request) { $c = new Criteria(); $cton1 = $c->getNewCriterion(ClientServicePeer::CLIENT_ID, null, Criteria::ISNULL); #$cton2 = $c->getNewCriterion(ClientServicePeer::EMPLOYEE_ID, null, Criteria::ISNULL); #$cton1->addOr($cton2); $c->add($cton1); $this->services = ClientServicePeer::doSelect($c); }
public function executeBatchClassroomTimesheet(sfWebRequest $request) { // using the filters and the selected ID's get the set of provider ID's $ids = $request->getParameter('ids'); // apply filter $this->filters = new ClientFormFilter($this->getUser()->getAttribute('client.filters', array(), 'admin_module')); $c = $this->filters->buildCriteria($this->getFilters(), true); // limit to only the selected clients (save for later use in loop) $filter_crit = $c->add(ClientServicePeer::CLIENT_ID, $ids, Criteria::IN); // only get the set of employees $c->addGroupByColumn(ClientServicePeer::EMPLOYEE_ID); // get employees for all services $c->addJoin(ClientServicePeer::EMPLOYEE_ID, EmployeePeer::ID); $employees = EmployeePeer::doSelect($c); // for each provider, use the filter criteria to get just their timesheets $this->filters = new ClientFormFilter($this->getUser()->getAttribute('client.filters', array(), 'admin_module')); $filter_crit = $this->filters->buildCriteria($this->getFilters()); $filter_crit->add(ClientPeer::ID, $ids, Criteria::IN); $timesheet = array(); $i = 0; foreach ($employees as $employee) { $temp = clone $filter_crit; $timesheet[$i]['employee'] = $employee->getFullName(); $temp->add(ClientServicePeer::EMPLOYEE_ID, $employee->getId()); $client_servs = ClientServicePeer::doSelect($temp); $timesheet[$i]['clients_right'] = ''; $timesheet[$i]['clients_left'] = ''; $num = 0; foreach ($client_servs as $acs) { if ($num++ % 2) { $timesheet[$i]['clients_right'] .= $acs->getClient()->getFullName() . " - " . $acs->getFrequency() . "\n"; } else { $timesheet[$i]['clients_left'] .= $acs->getClient()->getFullName() . " - " . $acs->getFrequency() . "\n"; } } $timesheet[$i]['office'] = $acs->getOffice(); $timesheet[$i]['service'] = $acs->getService(); $timesheet[$i]['date'] = $acs->getStartDate('Y') . ' - ' . $acs->getEndDate('Y'); $i++; } /* foreach($timesheet as $asheet){ echo $asheet['employee'].'<br />'; foreach($asheet['clients'] as $kid){ echo $kid->getClient().'<br />'; } echo '<br />'; } die(); */ // create the document $doc = new sfTinyDoc(); $doc->createFrom(array('basename' => 'batchClassroomTimesheet')); $doc->loadXml('content.xml'); $doc->mergeXmlBlock('timesheet', $timesheet); $doc->saveXml(); $doc->close(); // send and remove the document $doc->sendResponse(); $doc->remove(); throw new sfStopException(); }
public function executeIndex(sfWebRequest $request) { $this->client_service_list = ClientServicePeer::doSelect(new Criteria()); }