Exemplo n.º 1
0
 public function getActiveClientServices(Criteria $c = null)
 {
     if (!$c) {
         $c = new Criteria();
     }
     return $this->getClientServicesJoinClient(ClientServicePeer::addActive($c));
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 public function configure()
 {
     $this->setWidgets(array('client_service_type' => new sfWidgetFormChoice(array('choices' => ClientServicePeer::getClassKeys())), 'employee_id' => new sfWidgetFormInputHidden(), 'date' => new sfWidgetFormJQueryDate(array('image' => '/images/calendar.png', 'config' => '{}', 'days' => nckTools::generateTwoCharsRange(1, 31), 'months' => nckTools::generateTwoCharsRange(1, 12)), array('class' => 'date'))));
     $this->widgetSchema->setLabels(array('client_service_type' => 'Voucher Type', 'employee_id' => 'Employee', 'date' => 'Vouchers as of Date'));
     $this->setValidators(array('client_service_type' => new sfValidatorPass(), 'employee_id' => new sfValidatorPass(), 'date' => new sfValidatorPass()));
     $this->widgetSchema->setNameFormat('voucher[%s]');
     $this->widgetSchema->setFormFormatterName('list');
 }
 public function configure()
 {
     $this->setWidgets(array('service_type' => new sfWidgetFormSelect(array('choices' => ClientServicePeer::getClassKeys(false))), 'date_month' => new sfWidgetFormSelect(array('choices' => array_combine(range(1, 12), range(1, 12)))), 'date_year' => new sfWidgetFormSelect(array('choices' => array_combine(range(date('Y') - 1, date('Y') + 2), range(date('Y') - 1, date('Y') + 2)))), 'client_id' => new sfWidgetFormInputHidden()));
     $this->widgetSchema->setLabels(array('service_type' => 'Service Type', 'date_month' => 'Month', 'date_year' => 'Year'));
     $this->setValidators(array('service_type' => new sfValidatorPass(), 'date_month' => new sfValidatorPass(), 'date_year' => new sfValidatorPass(), 'client_id' => new sfValidatorPass()));
     $this->setDefaults(array('service_type' => ClientServicePeer::CLASSKEY_CLASSROOM, 'date_month' => date('n'), 'date_year' => date('Y')));
     $this->widgetSchema->setNameFormat('monthlynotes[%s]');
     $this->widgetSchema->setFormFormatterName('list');
 }
Exemplo n.º 5
0
 public function configure()
 {
     $this->setWidgets(array('date_month' => new sfWidgetFormSelect(array('choices' => array_combine(range(1, 12), range(1, 12)))), 'date_year' => new sfWidgetFormSelect(array('choices' => array_combine(range(date('Y') - 1, date('Y') + 2), range(date('Y') - 1, date('Y') + 2)))), 'employee_id' => new sfWidgetFormPropelChoice(array('model' => 'Employee', 'add_empty' => 'All', 'order_by' => array('LastName', 'asc'))), 'service_type' => new sfWidgetFormSelect(array('choices' => ClientServicePeer::getClassKeys(false)))));
     $this->widgetSchema->setLabels(array('service_type' => 'Service Type', 'date_month' => 'Month', 'date_year' => 'Year', 'employee_id' => 'Employee'));
     $this->setValidators(array('service_type' => new sfValidatorPass(), 'date_month' => new sfValidatorPass(), 'date_year' => new sfValidatorPass(), 'employee_id' => new sfValidatorPropelChoice(array('model' => 'Employee', 'column' => 'id', 'required' => false))));
     $this->widgetSchema->setNameFormat('dailylog[%s]');
     $this->widgetSchema->setFormFormatterName('list');
     $this->setDefault('date_year', date('Y'));
     $this->setDefault('date_month', date('n'));
 }
Exemplo n.º 6
0
 public function configure()
 {
     unset($this['client_id'], $this['created_at'], $this['updated_at'], $this['employee_id'], $this['time_in'], $this['time_out']);
     $this->setOption('employee_id', $this->getObject()->getEmployeeId());
     //Embedding at least a form
     $entry_concerns = $this->getObject()->getEntryConcerns();
     //An empty form will act as a container for all the contacts
     $entry_concerns_form = new SfForm();
     $count = 0;
     foreach ($entry_concerns as $entry_concern) {
         $entry_concern_form = new EntryConcernForm($entry_concern, array('employee_id' => $this->getOption('employee_id')));
         //Embedding each form in the container
         $entry_concerns_form->embedForm($count, $entry_concern_form);
         $count++;
     }
     //Embedding the container in the main form
     $this->embedForm('entry_concerns', $entry_concerns_form);
     // this makes it so client service list only shows active services for this employee
     $c = new Criteria();
     ClientServicePeer::addActive($c);
     $c->add(ClientServicePeer::EMPLOYEE_ID, $this->getOption('employee_id'));
     // only classroom services
     $c->add(ClientServicePeer::OBJECT_TYPE, array(ClientServicePeer::CLASSKEY_CLASSROOM, ClientServicePeer::CLASSKEY_SEIT, ClientServicePeer::CLASSKEY_PRESCHOOL, ClientServicePeer::CLASSKEY_EI), Criteria::IN);
     $c->addJoin(ClientPeer::ID, ClientServicePeer::CLIENT_ID);
     $c->addAscendingOrderByColumn(ClientPeer::FIRST_NAME);
     $this->widgetSchema['client_service_id'] = new sfWidgetFormPropelChoiceGrouped(array('model' => 'ClientService', 'add_empty' => true, 'group_by_method' => 'getObjectType'));
     $this->widgetSchema['client_service_id']->setOption('criteria', $c);
     // this makes it so the group list only shows other kids this person is activley servicing
     $this->widgetSchema['note_entry_kids_list'] = new sfWidgetFormPropelChoiceGrouped(array('model' => 'ClientService', 'add_empty' => false, 'group_by_method' => 'getObjectType'));
     $this->widgetSchema['note_entry_kids_list']->setOption('criteria', $c);
     $this->widgetSchema['note_entry_kids_list']->setOption('expanded', true);
     $this->widgetSchema['note_entry_kids_list']->setOption('multiple', true);
     $this->widgetSchema['note_entry_kids_list']->setOption('key_method', 'getClientId');
     $this->widgetSchema['note_entry_kids_list']->setOption('method', 'getClient');
     $this->widgetSchema['note_entry_kids_list']->setOption('renderer_options', array('template' => '<div class="groupType"><strong>%group%</strong> %options%<br style="clear:both" /></div>'));
     $this->widgetSchema->setLabels(array('client_service_id' => 'Client Service', 'office_id' => 'Service Location', 'frequency_id' => 'IEP Frequency', 'note_entry_kids_list' => 'Group'));
     $this->widgetSchema['service_date'] = new sfWidgetFormInput();
     $this->widgetSchema['time_in'] = new sfWidgetFormInput();
     $this->widgetSchema['time_out'] = new sfWidgetFormInput();
     $this->widgetSchema['units'] = new sfWidgetFormChoice(array('choices' => NoteEntryPeer::getUnitChoices()));
     $this->validatorSchema['units'] = new sfValidatorChoice(array('choices' => NoteEntryPeer::getUnitChoices(true)));
     $this->widgetSchema['absent'] = new sfWidgetFormChoice(array('choices' => NoteEntryPeer::getAbsentChoices()));
     $this->validatorSchema['absent'] = new sfValidatorChoice(array('choices' => NoteEntryPeer::getAbsentChoices(true)));
     $this->validatorSchema['time_in'] = new sfValidatorPass();
     $this->validatorSchema['time_out'] = new sfValidatorPass();
     /*
      * add a post validator for dates and times
      * needs to convert 12-hour to 24-hour time, anything less than 7 is afternoon
      * needs to use service date to set the times
      */
     $this->validatorSchema->setPostValidator(new sfValidatorCallback(array('callback' => array($this, 'validateDates'))));
 }
Exemplo n.º 7
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;
 }
Exemplo n.º 8
0
 public function configure()
 {
     unset($this['first_name'], $this['last_name'], $this['parent2_first'], $this['parent2_last'], $this['dob'], $this['parent_first'], $this['parent_last'], $this['address'], $this['address_2'], $this['city'], $this['state'], $this['zip'], $this['county_id'], $this['district_id'], $this['home_phone'], $this['work_phone'], $this['cell_phone'], $this['blue_card'], $this['immunizations'], $this['waiting_list'], $this['is_iep'], $this['physical_exp'], $this['notes'], $this['created_at'], $this['updated_at'], $this['service_coordinator_id'], $this['note_entry_kids_list'], $this['pediatrician']);
     $this->widgetSchema['employee_id'] = new sfWidgetFormPropelChoiceMany(array('model' => 'Employee', 'add_empty' => true, 'order_by' => array('LastName', 'asc')));
     $this->widgetSchema['service_id'] = new sfWidgetFormPropelChoiceMany(array('model' => 'Service', 'add_empty' => true, 'order_by' => array('Name', 'asc')));
     #$this->widgetSchema['frequency_id']     = new sfWidgetFormPropelChoice(array('model' => 'Frequency', 'add_empty' => true));
     $this->widgetSchema['start_date'] = new sfWidgetFormFilterDate(array('template' => 'between  - 
                     <a href="#" title="Summer" onclick="javascript:prefillDate(\'client_filters_start_date_from\', \'7\', \'1\', \'' . (date('m') < '7' ? date('Y') : date('Y')) . '\');prefillDate(\'client_filters_start_date_to\', \'7\', \'15\', \'' . (date('m') < '7' ? date('Y') : date('Y')) . '\');return false;">(S)</a>&nbsp;
                     <a href="#" title="Fall" onclick="javascript:prefillDate(\'client_filters_start_date_from\', \'9\', \'1\', \'' . (date('m') < '9' ? date('Y') : date('Y')) . '\');prefillDate(\'client_filters_start_date_to\', \'9\', \'30\', \'' . (date('m') < '9' ? date('Y') : date('Y')) . '\');return false;">(F)</a><br />%from_date%<br />and <br />%to_date%', 'from_date' => new sfWidgetFormJQueryDate(array('image' => '/images/calendar.png', 'config' => '{}'), array('class' => 'filter_date')), 'to_date' => new sfWidgetFormJQueryDate(array('image' => '/images/calendar.png', 'config' => '{}'), array('class' => 'filter_date')), 'with_empty' => false));
     $this->widgetSchema['end_date'] = new sfWidgetFormFilterDate(array('template' => 'between  -
                   <a href="#" title="Summer" onclick="javascript:prefillDate(\'client_filters_end_date_from\', \'8\', \'1\', \'' . (date('m') < '8' ? date('Y') + 1 : date('Y')) . '\');prefillDate(\'client_filters_end_date_to\', \'8\', \'30\', \'' . (date('m') < '8' ? date('Y') + 1 : date('Y')) . '\');return false;">(S)</a>&nbsp;
                   <a href="#" title="Fall" onclick="javascript:prefillDate(\'client_filters_end_date_from\', \'6\', \'1\', \'' . (date('m') < '6' ? date('Y') + 1 : date('Y')) . '\');prefillDate(\'client_filters_end_date_to\', \'6\', \'30\', \'' . (date('m') < '6' ? date('Y') + 1 : date('Y')) . '\');return false;">(F)</a><br />%from_date%<br />and <br />%to_date%', 'from_date' => new sfWidgetFormJQueryDate(array('image' => '/images/calendar.png', 'config' => '{}'), array('class' => 'filter_date')), 'to_date' => new sfWidgetFormJQueryDate(array('image' => '/images/calendar.png', 'config' => '{}'), array('class' => 'filter_date')), 'with_empty' => false));
     #$this->widgetSchema['change_date']      = new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormJQueryDate(array('config' => '{}')), 'to_date' => new sfWidgetFormJQueryDate(array('config' => '{}')), 'with_empty' => true));
     #$this->widgetSchema['icd9_id']          = new sfWidgetFormPropelChoice(array('model' => 'Icd9', 'add_empty' => true));
     #$this->widgetSchema['authorization']    = new sfWidgetFormFilterInput();
     #$this->widgetSchema['physicians_order'] = new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no')));
     $this->widgetSchema['office_id'] = new sfWidgetFormPropelChoiceMany(array('model' => 'Office', 'add_empty' => true));
     $this->widgetSchema['object_type'] = new sfWidgetFormChoice(array('choices' => ClientServicePeer::getClassKeys(), 'multiple' => true));
     $this->validatorSchema['employee_id'] = new sfValidatorPass(array('required' => false));
     $this->validatorSchema['service_id'] = new sfValidatorPass(array('required' => false));
     #$this->validatorSchema['frequency_id']     = new sfValidatorPropelChoice(array('required' => false, 'model' => 'Frequency', 'column' => 'id'));
     $this->validatorSchema['start_date'] = new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false))));
     $this->validatorSchema['end_date'] = new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false))));
     #$this->validatorSchema['change_date']      = new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false))));
     #$this->validatorSchema['icd9_id']          = new sfValidatorPropelChoice(array('required' => false, 'model' => 'Icd9', 'column' => 'id'));
     #$this->validatorSchema['authorization']    = new sfValidatorPass(array('required' => false));
     #$this->validatorSchema['physicians_order'] = new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0)));
     $this->validatorSchema['office_id'] = new sfValidatorPass(array('required' => false));
     $this->validatorSchema['object_type'] = new sfValidatorPass(array('required' => false));
     #$this->widgetSchema['district_id']->setOption('expanded', false);
     $this->widgetSchema['employee_id']->setLabel('Provider');
     $this->widgetSchema['start_date']->setLabel('Start Date Range:');
     $this->widgetSchema['end_date']->setLabel('End Date Range:');
     $this->widgetSchema['service_id']->setLabel('Service Type');
     $this->widgetSchema['office_id']->setLabel('Office');
     $this->widgetSchema['object_type']->setLabel('Client Service');
     if (!sfContext::getInstance()->getUser()->hasCredential('admin')) {
         unset($this['end_date']);
     }
 }
Exemplo n.º 9
0
 public function executeAjaxFillClient(sfWebRequest $request)
 {
     $client_service = ClientServicePeer::retrieveByPK($request->getParameter('id'));
     $fields = array();
     $fields[] = array('id' => 'entry_location', 'value' => $client_service->getOffice() ? $client_service->getOffice()->getName() : '');
     $fields[] = array('id' => 'entry_frequency', 'value' => $client_service->getFrequency()->getName());
     return $this->jsonify($fields);
 }
Exemplo n.º 10
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();
         }
     }
 }
Exemplo n.º 11
0
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
     // create connection to import database
     $this->logSection('connection', 'creating connection to import source');
     $source = Propel::getConnection($options['source'] ? $options['source'] : null);
     // create static counties and offices
     $this->logSection('static', 'creating static counties and offices');
     $connection->beginTransaction();
     try {
         OfficePeer::doDeleteAll($connection);
         $o1 = new Office();
         $o1->setName('Plattsburgh');
         $o1->save($connection);
         $o1 = new Office();
         $o1->setName('Rouses Point');
         $o1->save($connection);
         CountyPeer::doDeleteAll($connection);
         $c1 = new County();
         $c1->setName('Clinton');
         $c1->save($connection);
         $c1 = new County();
         $c1->setName('Essex');
         $c1->save($connection);
         $connection->commit();
     } catch (PropelException $e) {
         $connection->rollBack();
         throw $e;
     }
     // read in and create objects for district, frequency, icd9, job, services tables
     // DISTRICT
     $query = 'SELECT * FROM %s';
     $query = sprintf($query, 'tbl_district');
     $statement = $source->prepare($query);
     $statement->execute();
     $districts = $statement->fetchAll();
     $connection->beginTransaction();
     try {
         DistrictPeer::doDeleteAll($connection);
         foreach ($districts as $district) {
             $this->logSection('district', 'creating district ' . $district['district_name']);
             $d1 = new District();
             $d1->setName($district['district_name']);
             $d1->save($connection);
         }
         $connection->commit();
     } catch (PropelException $e) {
         $connection->rollBack();
         throw $e;
     }
     // FREQUENCY
     $query = 'SELECT * FROM %s';
     $query = sprintf($query, 'tbl_frequency');
     $statement = $source->prepare($query);
     $statement->execute();
     $frequencies = $statement->fetchAll();
     $connection->beginTransaction();
     try {
         FrequencyPeer::doDeleteAll($connection);
         foreach ($frequencies as $freq) {
             $this->logSection('freq', 'reading frequency ' . $freq['freq_title']);
             $f1 = new Frequency();
             $f1->setName($freq['freq_title']);
             $f1->setDescription($freq['freq_description']);
             $f1->save($connection);
         }
         $connection->commit();
     } catch (PropelException $e) {
         $connection->rollBack();
         throw $e;
     }
     // ICD9
     $query = 'SELECT * FROM %s';
     $query = sprintf($query, 'tbl_icd9');
     $statement = $source->prepare($query);
     $statement->execute();
     $icd9s = $statement->fetchAll();
     $connection->beginTransaction();
     try {
         Icd9Peer::doDeleteAll($connection);
         foreach ($icd9s as $icd9) {
             $this->logSection('icd9', 'reading icd9 ' . $icd9['icd9_value']);
             $i1 = new Icd9();
             $i1->setName($icd9['icd9_value']);
             $i1->save($connection);
         }
         $connection->commit();
     } catch (PropelException $e) {
         $connection->rollBack();
         throw $e;
     }
     // JOB
     $query = 'SELECT * FROM %s';
     $query = sprintf($query, 'tbl_job');
     $statement = $source->prepare($query);
     $statement->execute();
     $jobs = $statement->fetchAll();
     $connection->beginTransaction();
     try {
         JobPeer::doDeleteAll($connection);
         foreach ($jobs as $job) {
             $this->logSection('job', 'reading job ' . $job['job_title']);
             $j1 = new Job();
             $j1->setName($job['job_title']);
             $j1->save($connection);
         }
         $connection->commit();
     } catch (PropelException $e) {
         $connection->rollBack();
         throw $e;
     }
     // SERVICES
     $query = 'SELECT * FROM %s';
     $query = sprintf($query, 'tbl_services');
     $statement = $source->prepare($query);
     $statement->execute();
     $services = $statement->fetchAll();
     $connection->beginTransaction();
     try {
         ServicePeer::doDeleteAll($connection);
         foreach ($services as $service) {
             $this->logSection('service', 'reading service ' . $service['service_title']);
             $s1 = new Service();
             $s1->setName($service['service_title']);
             $s1->save($connection);
         }
         $connection->commit();
     } catch (PropelException $e) {
         $connection->rollBack();
         throw $e;
     }
     // EMPLOYEES
     $query = 'SELECT * FROM %s LEFT JOIN (%s) ON (%s.emp_job_title = %s.job_id)';
     $query = sprintf($query, 'tbl_employee', 'tbl_job', 'tbl_employee', 'tbl_job');
     $statement = $source->prepare($query);
     $statement->execute();
     $employees = $statement->fetchAll();
     $connection->beginTransaction();
     try {
         EmployeePeer::doDeleteAll($connection);
         foreach ($employees as $employee) {
             $this->logSection('employee', 'reading employee ' . $employee['emp_id']);
             $emp = new Employee();
             $emp_fields = array('clearance' => $employee['emp_scr_clearance'], 'first_name' => $employee['emp_fn'], 'middle' => $employee['emp_mi'], 'last_name' => $employee['emp_ln'], 'address' => $employee['emp_address'], 'address_2' => $employee['emp_address2'], 'city' => $employee['emp_city'], 'state' => $employee['emp_state'], 'zip' => $employee['emp_zip'], 'home_phone' => $employee['emp_phone'], 'cell_phone' => $employee['emp_cell'], 'company_email' => $employee['emp_email'], 'personal_email' => $employee['emp_p_email'], 'license_number' => $employee['emp_license_number'], 'license_expiration' => $employee['emp_license_exp'], 'dob' => $employee['emp_dob'], 'doh' => $employee['emp_hire_date'], 'dof' => $employee['emp_end_date'], 'ssn' => $employee['emp_ssn'], 'health_insurance' => $employee['emp_health'], 'retirement_plan' => $employee['emp_401k'], 'suplimental_health' => $employee['emp_health_sup'], 'health_type' => $employee['emp_health_type'], 'tb_date' => $employee['emp_tb'], 'osha_date' => $employee['emp_osha'], 'cpr_date' => $employee['emp_cpr'], 'finger_prints' => $employee['emp_fp'], 'finger_print_notes' => $employee['emp_fp_n'], 'notes' => $employee['emp_notes']);
             $emp->fromArray($emp_fields, BasePeer::TYPE_FIELDNAME);
             // find the job - check for errors
             $emp->setJob(JobPeer::getByName($employee['job_title']));
             // if physical has a date then create a new physical object for employee
             if ($employee['emp_physical']) {
                 $this->logSection('physical', 'employee ' . $employee['emp_fn'] . ' had a physical on ' . $employee['emp_physical']);
                 $ph1 = new Physical();
                 $ph1->setEmployee($emp);
                 $ph1->setDateGiven($employee['emp_physical']);
                 $ph1->save($connection);
             }
             $emp->save($connection);
         }
         $connection->commit();
     } catch (PropelException $e) {
         $connection->rollBack();
         throw $e;
     }
     // read in and create client objects - linking to employee
     // CLIENTS
     $query = 'SELECT * FROM %s LEFT JOIN (%s) ON (%s.client_district = %s.district_id)';
     $query = sprintf($query, 'tbl_client', 'tbl_district', 'tbl_client', 'tbl_district');
     $statement = $source->prepare($query);
     $statement->execute();
     $clients = $statement->fetchAll();
     $connection->beginTransaction();
     try {
         ClientPeer::doDeleteAll($connection);
         foreach ($clients as $client) {
             $this->logSection('client', 'reading client ' . $client['client_ln']);
             $cl = new Client();
             $client_fields = array('first_name' => $client['client_fn'], 'last_name' => $client['client_ln'], 'dob' => $client['client_dob'], 'parent_first' => $client['client_parent_fn'], 'parent_last' => $client['client_parent_ln'], 'address' => $client['client_address'], 'address_2' => $client['client_address2'], 'city' => $client['client_city'], 'state' => $client['client_state'], 'zip' => $client['client_zip'], 'home_phone' => $client['home_phone'], 'work_phone' => $client['work_phone'], 'cell_phone' => $client['cell_phone'], 'blue_card' => $client['blue_card'], 'physical_exp' => $client['physical_exp_date'], 'immunizations' => $client['immunizations'], 'waiting_list' => $client['waiting_list']);
             // county
             $cl->setCounty(CountyPeer::getByName($client['client_county']));
             // district
             $cl->setDistrict(DistrictPeer::getByName($client['district_name']));
             $cl->fromArray($client_fields, BasePeer::TYPE_FIELDNAME);
             $cl->save($connection);
         }
         $connection->commit();
     } catch (PropelException $e) {
         $connection->rollBack();
         throw $e;
     }
     // CLIENT SERVICES
     // CLASSROOM
     $query = 'SELECT * FROM tbl_classroom LEFT JOIN (tbl_client) ON (tbl_classroom.class_client_id = tbl_client.client_id)
 LEFT JOIN (tbl_employee) ON (tbl_classroom.class_provider_id = tbl_employee.emp_id)
 LEFT JOIN (tbl_services) ON (tbl_classroom.class_service_id = tbl_services.service_id)
 LEFT JOIN (tbl_frequency) ON (tbl_classroom.class_freq_id = tbl_frequency.freq_id)';
     $statement = $source->prepare($query);
     $statement->execute();
     $classrooms = $statement->fetchAll();
     $connection->beginTransaction();
     $c = new Criteria();
     $c->add(ClientServicePeer::OBJECT_TYPE, ClientServicePeer::CLASSKEY_CLASSROOM);
     try {
         ClientServicePeer::doDelete($c, $connection);
         foreach ($classrooms as $classroom) {
             $this->logSection('classroom', 'reading service ' . $classroom['class_id']);
             $cr_cl = new Classroom();
             $cr_cl->setStartDate($classroom['class_start_date']);
             $cr_cl->setEndDate($classroom['class_exp_date']);
             $cr_cl->setChangeDate($classroom['class_chng_date']);
             $cr_cl->setNotes($classroom['class_notes']);
             // client
             $cr_cl->setClient(ClientPeer::getByFullName($classroom['client_fn'], $classroom['client_ln']));
             // employee
             $cr_cl->setEmployee(EmployeePeer::getByFullName($classroom['emp_fn'], $classroom['emp_ln']));
             // service
             $cr_cl->setService(ServicePeer::getByName($classroom['service_title']));
             // frequency
             $cr_cl->setFrequency(FrequencyPeer::getByName($classroom['freq_title']));
             // office
             $cr_cl->setOffice(OfficePeer::getByName($classroom['class_location']));
             $cr_cl->save($connection);
         }
         $connection->commit();
     } catch (PropelException $e) {
         $connection->rollBack();
         throw $e;
     }
     // EI
     $query = 'SELECT * FROM tbl_ei LEFT JOIN (tbl_client) ON (tbl_ei.ei_client_id = tbl_client.client_id)
 LEFT JOIN (tbl_employee) ON (tbl_ei.ei_provider_id = tbl_employee.emp_id)
 LEFT JOIN (tbl_services) ON (tbl_ei.ei_service_id = tbl_services.service_id)
 LEFT JOIN (tbl_frequency) ON (tbl_ei.ei_freq_id = tbl_frequency.freq_id)
 LEFT JOIN (tbl_icd9) ON (tbl_ei.ei_icd9_id = tbl_icd9.icd9_id)';
     $statement = $source->prepare($query);
     $statement->execute();
     $eis = $statement->fetchAll();
     $connection->beginTransaction();
     $c = new Criteria();
     $c->add(ClientServicePeer::OBJECT_TYPE, ClientServicePeer::CLASSKEY_EI);
     try {
         ClientServicePeer::doDelete($c, $connection);
         foreach ($eis as $ei) {
             $this->logSection('ei', 'reading service ' . $ei['ei_id']);
             $ei_cl = new Ei();
             $ei_cl->setStartDate($ei['ei_start_date']);
             $ei_cl->setEndDate($ei['ei_exp_date']);
             $ei_cl->setChangeDate($ei['ei_chng_date']);
             $ei_cl->setNotes($ei['ei_serv_notes']);
             $ei_cl->setAuthorization($ei['ei_auth']);
             $ei_cl->setPhysiciansOrder($ei['ei_p_order']);
             // client
             $ei_cl->setClient(ClientPeer::getByFullName($ei['client_fn'], $ei['client_ln']));
             // employee
             $ei_cl->setEmployee(EmployeePeer::getByFullName($ei['emp_fn'], $ei['emp_ln']));
             // service
             $ei_cl->setService(ServicePeer::getByName($ei['service_title']));
             // frequency
             $ei_cl->setFrequency(FrequencyPeer::getByName($ei['freq_title']));
             // office
             $ei_cl->setIcd9(Icd9Peer::getByName($ei['icd9_value']));
             $ei_cl->save($connection);
         }
         $connection->commit();
     } catch (PropelException $e) {
         $connection->rollBack();
         throw $e;
     }
     // PRESCHOOL
     $query = 'SELECT * FROM tbl_preschool LEFT JOIN (tbl_client) ON (tbl_preschool.pre_client_id = tbl_client.client_id)
 LEFT JOIN (tbl_employee) ON (tbl_preschool.pre_provider_id = tbl_employee.emp_id)
 LEFT JOIN (tbl_services) ON (tbl_preschool.pre_service_id = tbl_services.service_id)
 LEFT JOIN (tbl_frequency) ON (tbl_preschool.pre_freq_id = tbl_frequency.freq_id)';
     $statement = $source->prepare($query);
     $statement->execute();
     $preschools = $statement->fetchAll();
     $connection->beginTransaction();
     $c = new Criteria();
     $c->add(ClientServicePeer::OBJECT_TYPE, ClientServicePeer::CLASSKEY_PRESCHOOL);
     try {
         ClientServicePeer::doDelete($c, $connection);
         foreach ($preschools as $preschool) {
             $this->logSection('preschool', 'reading service ' . $preschool['pre_id']);
             $pr_cl = new Preschool();
             $pr_cl->setStartDate($preschool['pre_start_date']);
             $pr_cl->setEndDate($preschool['pre_exp_date']);
             $pr_cl->setChangeDate($preschool['pre_chng_date']);
             // client
             $pr_cl->setClient(ClientPeer::getByFullName($preschool['client_fn'], $preschool['client_ln']));
             // employee
             $pr_cl->setEmployee(EmployeePeer::getByFullName($preschool['emp_fn'], $preschool['emp_ln']));
             // service
             $pr_cl->setService(ServicePeer::getByName($preschool['service_title']));
             // frequency
             $pr_cl->setFrequency(FrequencyPeer::getByName($preschool['freq_title']));
             $pr_cl->save($connection);
         }
         $connection->commit();
     } catch (PropelException $e) {
         $connection->rollBack();
         throw $e;
     }
     // SEIT
     $query = 'SELECT * FROM tbl_seit LEFT JOIN (tbl_client) ON (tbl_seit.seit_client_id = tbl_client.client_id)
 LEFT JOIN (tbl_employee) ON (tbl_seit.seit_provider_id = tbl_employee.emp_id)
 LEFT JOIN (tbl_services) ON (tbl_seit.seit_service_id = tbl_services.service_id)
 LEFT JOIN (tbl_frequency) ON (tbl_seit.seit_freq_id = tbl_frequency.freq_id)';
     $statement = $source->prepare($query);
     $statement->execute();
     $seits = $statement->fetchAll();
     $connection->beginTransaction();
     $c = new Criteria();
     $c->add(ClientServicePeer::OBJECT_TYPE, ClientServicePeer::CLASSKEY_SEIT);
     try {
         ClientServicePeer::doDelete($c, $connection);
         foreach ($seits as $seit) {
             $this->logSection('seit', 'reading service ' . $seit['seit_id']);
             $seit_cl = new Seit();
             $seit_cl->setStartDate($seit['seit_start_date']);
             $seit_cl->setEndDate($seit['seit_exp_date']);
             $seit_cl->setChangeDate($seit['seit_chng_date']);
             $seit_cl->setNotes($seit['seit_notes']);
             // client
             $seit_cl->setClient(ClientPeer::getByFullName($seit['client_fn'], $seit['client_ln']));
             // employee
             $seit_cl->setEmployee(EmployeePeer::getByFullName($seit['emp_fn'], $seit['emp_ln']));
             // service
             $seit_cl->setService(ServicePeer::getByName($seit['service_title']));
             // frequency
             $seit_cl->setFrequency(FrequencyPeer::getByName($seit['freq_title']));
             $seit_cl->save($connection);
         }
         $connection->commit();
     } catch (PropelException $e) {
         $connection->rollBack();
         throw $e;
     }
 }
Exemplo n.º 12
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();
 }
Exemplo n.º 13
0
 public function executeDelete(sfWebRequest $request)
 {
     $request->checkCSRFProtection();
     $this->forward404Unless($client_service = ClientServicePeer::retrieveByPk($request->getParameter('id')), sprintf('Object client_service does not exist (%s).', $request->getParameter('id')));
     $client_service->delete();
     $this->redirect('report/invalidServices');
 }