public function _processEditAppointment(array $params) { $paramProviders = array(); foreach ($params as $key => $val) { $providerPrefix = 'providerId-'; if (substr($key, 0, strlen($providerPrefix)) == $providerPrefix) { $paramProviders[] = $val; unset($params[$key]); } } if (count($paramProviders) > 0) { // assign the first providerId $params['providerId'] = array_shift($paramProviders); } // extra providers if any, can be retrieved using $paramProviders variable, not sure where to place it $forced = (int) $this->_getParam('forced'); $filter = $this->getCurrentDisplayFilter(); $app = new Appointment(); if (isset($params['appointmentId']) && $params['appointmentId'] > 0) { $app->appointmentId = (int) $params['appointmentId']; $app->populate(); } $app->populateWithArray($params); if ($app->appointmentId > 0) { $app->lastChangeId = (int) Zend_Auth::getInstance()->getIdentity()->personId; $app->lastChangeDate = date('Y-m-d H:i:s'); } else { $app->creatorId = (int) Zend_Auth::getInstance()->getIdentity()->personId; $app->createdDate = date('Y-m-d H:i:s'); } $date = isset($params['date']) ? date('Y-m-d', strtotime($params['date'])) : date('Y-m-d'); $app->walkin = isset($params['walkin']) ? 1 : 0; $app->start = $date . ' ' . date('H:i:s', strtotime($params['start'])); $app->end = $date . ' ' . date('H:i:s', strtotime($params['end'])); $data = array(); if (!$forced && ($error = $app->checkRules())) { // prompt the user if the appointment being made would be a double book or is outside of schedule time. $data['error'] = $error; } else { $app->persist(); //trigger_error(print_r($params,true)); $data['appointmentId'] = $app->appointmentId; } $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct($data); }
public function processAddAppointmentAction() { $appointment = $this->_getParam('appointment'); $paramProviders = array(); foreach ($appointment as $key => $val) { $providerPrefix = 'providerId-'; if (substr($key, 0, strlen($providerPrefix)) == $providerPrefix) { $paramProviders[] = $val; unset($appointment[$key]); } } if (count($paramProviders) > 0) { // assign the first providerId $appointment['providerId'] = array_shift($paramProviders); } // extra providers if any, can be retrieved using $paramProviders variable, not sure where to place it $columnId = $this->_getParam('columnId'); $rowId = $this->_getParam('rowId'); $filter = $this->getCurrentDisplayFilter(); if (strlen($columnId) <= 0) { // look for the column of the input provider if (strlen($appointment['providerId']) > 0) { foreach ($filter->columns as $index => $column) { if ($column['providerId'] == $appointment['providerId']) { $columnId = $index; break; } } } // in the meantime, no room checked, how are we going to check for the room? } if (!isset($filter->columns[$columnId])) { throw new Exception(__("Cannot generate column with that index, there is no filter defined for that column Index: ") . $columnId); } $column = $filter->columns[$columnId]; $app = new Appointment(); $app->populateWithArray($appointment); if ($app->appointmentId > 0) { $app->lastChangeId = (int) Zend_Auth::getInstance()->getIdentity()->personId; $app->lastChangeDate = date('Y-m-d H:i:s'); } else { $app->creatorId = (int) Zend_Auth::getInstance()->getIdentity()->personId; $app->createdDate = date('Y-m-d H:i:s'); } //$app->providerId = $appointment['providerId']; //$app->patientId = substr($appointment['patient'],stripos($appointment['patient'],'PID:') + 4); $app->walkin = isset($appointment['walkin']) ? 1 : 0; $app->start = $filter->date . ' ' . date('H:i:s', strtotime($appointment['start'])); $app->end = $filter->date . ' ' . date('H:i:s', strtotime($appointment['end'])); $app->persist(); $data = array(); $data['columnId'] = $columnId; $data['rowId'] = $rowId; $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct($data); }