示例#1
0
文件: Client.php 项目: anvaya/nckids
 public function getClientServices($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(ClientPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collClientServices === null) {
         if ($this->isNew()) {
             $this->collClientServices = array();
         } else {
             $criteria->add(ClientServicePeer::CLIENT_ID, $this->id);
             #ClientServicePeer::addSelectColumns($criteria);
             $this->collClientServices = ClientServicePeer::doSelectJoinAll($criteria, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // 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(ClientServicePeer::CLIENT_ID, $this->id);
             #ClientServicePeer::addSelectColumns($criteria);
             if (!isset($this->lastClientServiceCriteria) || !$this->lastClientServiceCriteria->equals($criteria)) {
                 $this->collClientServices = ClientServicePeer::doSelectJoinAll($criteria, $con);
             }
         }
     }
     $this->lastClientServiceCriteria = $criteria;
     return $this->collClientServices;
 }
示例#2
0
 public static function getWaiting($date = null)
 {
     $date = $date ? $date : time();
     $c = new Criteria();
     #$c->addJoin(ClientServicePeer::CLIENT_ID, ClientPeer::ID, Criteria::LEFT_JOIN);
     $c->add(ClientServicePeer::START_DATE, $date, Criteria::GREATER_EQUAL);
     $c->add(ClientServicePeer::OBJECT_TYPE, ClientServicePeer::CLASSKEY_CLASSROOM);
     $c->add(ClientServicePeer::WAITING_LIST, true);
     $c->addAscendingOrderByColumn(ClientServicePeer::CLIENT_ID);
     $result = ClientServicePeer::doSelectJoinAll($c);
     // select client_id from all classroom services where start date is > today group by client_id
     #return ClientPeer::populateObjects($result);
     return $result;
 }
示例#3
0
 public function executeVoucher(sfWebRequest $request)
 {
     $this->form = new ReportVoucherForm();
     if ($request->getParameter('employee_id')) {
         $this->form->setDefault('employee_id', $request->getParameter('employee_id'));
     }
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
         if ($this->form->isValid()) {
             $date = $this->form->getValue('date');
             $as_of_date = mktime(0, 0, 0, $date['month'], $date['day'], $date['year']);
             $c = new Criteria();
             // only chose client service types of the selected type
             $c->add(ClientServicePeer::OBJECT_TYPE, $this->form->getValue('client_service_type'));
             // make sure client and provider are not null
             $c->add(ClientServicePeer::CLIENT_ID, null, Criteria::ISNOTNULL);
             // if an employee is selected - only show vouchers for that provider
             if ($this->form->getValue('employee_id')) {
                 $c->add(ClientServicePeer::EMPLOYEE_ID, $this->form->getValue('employee_id'));
             } else {
                 $c->add(ClientServicePeer::EMPLOYEE_ID, null, Criteria::ISNOTNULL);
             }
             // check that the service was active at any point during the selected month of the selected year
             $c->add(ClientServicePeer::START_DATE, ClientServicePeer::START_DATE . ' <=\'' . $date['year'] . '-' . $date['month'] . '-31\'', Criteria::CUSTOM);
             // if they have an end date make sure it is in the selected month or later of the selected year
             $cton1 = $c->getNewCriterion(ClientServicePeer::END_DATE, ClientServicePeer::END_DATE . '>=\'' . $date['year'] . '-' . $date['month'] . '-1\'', Criteria::CUSTOM);
             $cton2 = $c->getNewCriterion(ClientServicePeer::END_DATE, null);
             $cton1->addOr($cton2);
             $c->add($cton1);
             // if they have a change date make sure it is in the selected month or later of the selected year
             $cton3 = $c->getNewCriterion(ClientServicePeer::CHANGE_DATE, ClientServicePeer::CHANGE_DATE . '>=\'' . $date['year'] . '-' . $date['month'] . '-1\'', Criteria::CUSTOM);
             $cton4 = $c->getNewCriterion(ClientServicePeer::CHANGE_DATE, null);
             $cton3->addOr($cton4);
             $c->add($cton3);
             // remove any services of irrelevant types
             $c->add(ClientServicePeer::SERVICE_ID, array_keys(sfConfig::get('app_voucher_ignore_services', 0)), Criteria::NOT_IN);
             // dont include waiting list kids
             $c->add(ClientServicePeer::WAITING_LIST, false);
             // sort by provider to group in list
             $c->addAscendingOrderByColumn(ClientServicePeer::EMPLOYEE_ID);
             // then sort by client to group them in provider list
             $c->addAscendingOrderByColumn(ClientServicePeer::CLIENT_ID);
             $this->services = ClientServicePeer::doSelectJoinAll($c);
             // create the document
             $doc = new sfTinyDoc();
             $doc->createFrom(array('basename' => $this->form->getValue('client_service_type') . 'Voucher'));
             $doc->loadXml('content.xml');
             $doc->mergeXmlField('cal_prev', $this->generateCalImage($date['day'], $date['month'] - 1, $date['year']));
             $doc->mergeXmlField('cal_next', $this->generateCalImage($date['day'], $date['month'], $date['year']));
             $doc->mergeXmlField('billing_period', date("M", $as_of_date) . ' 1 - ' . date("M", $as_of_date) . ' ' . date("t", $as_of_date));
             $doc->mergeXmlField('due_date', date("M", mktime(0, 0, 0, $date['month'] + 1, $date['day'], $date['year'])) . ' 3rd');
             $doc->mergeXmlBlock('service', $this->services);
             $doc->saveXml();
             $doc->close();
             // send and remove the document
             $doc->sendResponse();
             $doc->remove();
             throw new sfStopException();
         }
     }
 }
示例#4
0
 public function executeBatchAideVoucher(sfWebRequest $request)
 {
     $ids = $request->getParameter('ids');
     $this->filters = new ClientFormFilter($this->getUser()->getAttribute('client.filters', array(), 'admin_module'));
     $c = $this->filters->buildCriteria($this->getFilters(), true);
     $c->add(ClientPeer::ID, $ids, Criteria::IN);
     $c->add(ClientServicePeer::SERVICE_ID, sfConfig::get('app_service_type_aide_id'));
     // join
     $pages = ClientServicePeer::doSelectJoinAll($c);
     // create the document
     $doc = new sfTinyDoc();
     $doc->createFrom(array('basename' => 'batchAideVoucher'));
     $doc->loadXml('content.xml');
     #$doc->mergeXmlField('client', $client);
     $doc->mergeXmlBlock('service', $pages);
     $doc->saveXml();
     $doc->close();
     // send and remove the document
     $doc->sendResponse();
     $doc->remove();
     throw new sfStopException();
 }