function deleteData($id) { $action = new Appointment($this->dbcon, $id); $result = parent::deleteData($id); if (!$action->getData('action_id')) { return $result; } $item = new ScheduleItem($this->dbcon, $action->getData('action_id')); return $result && $item->updateStatus(); }
function save($data) { $options = $this->getOptions(); $data['owner_id'] = $this->udm->uid; $data['schedule_id'] = $options['schedule_id']; if (!isset($data['status'])) { $data['status'] = AMP_SCHEDULE_STATUS_DRAFT; } $item = new ScheduleItem($this->dbcon); $itemdata = $this->schedule_form->translate($data, 'get'); $item->setData($itemdata); return $item->save(); }
public function afterSave($created) { parent::afterSave($created); if (isset($this->data['ScheduleItem'])) { // delete App::uses("ScheduleItem", "ScheduleManager.Model"); $scheduleItemModel = new ScheduleItem(); //debug($this->id); //debug($this->data['ServiceEntry']['type']);exit; $scheduleItemModel->deleteAll(array('ScheduleItem.schedule_id' => $this->id, 'ScheduleItem.type' => $this->data['ServiceEntry']['type'])); if (is_array($this->data['ScheduleItem'])) { // save $scheduleItems = array(); $index = -1; foreach ($this->data['ScheduleItem'] as $scheduleItem) { if (trim($scheduleItem['quantity']) == '' || $scheduleItem['quantity'] == 0 || trim($scheduleItem['code']) == '') { continue; // skip if no data } $index++; $scheduleItems[$index]['schedule_id'] = $this->id; $scheduleItems[$index]['purchase_order_id'] = $scheduleItem['purchase_order_id']; $scheduleItems[$index]['code'] = trim($scheduleItem['code']); $scheduleItems[$index]['quantity'] = trim($scheduleItem['quantity']); $scheduleItems[$index]['reason'] = trim($scheduleItem['reason']); $scheduleItems[$index]['type'] = trim($this->data['ServiceEntry']['type']); $itemType = explode('|', $scheduleItems[$index]['code']); if ($itemType[1] == 'item') { $scheduleItems[$index]['item_id'] = trim($itemType[0]); } elseif ($itemType[1] == 'cabinet') { $scheduleItems[$index]['cabinet_id'] = trim($itemType[0]); } elseif ($itemType[1] == 'door' || $itemType[1] == 'wall_door' || $itemType[1] == 'drawer') { $scheduleItems[$index]['door_id'] = trim($itemType[0]); } } if ($index >= 0) { $flag = $scheduleItemModel->saveAll($scheduleItems); } else { return false; } } } elseif (isset($this->data['ScheduleStatus'])) { $scheduleItems['schedule_id'] = $this->id; $scheduleItems['user_id'] = trim($this->data['ScheduleStatus']['user_id']); $scheduleItems['status'] = trim($this->data['ScheduleStatus']['status']); $scheduleItems['status_date'] = trim($this->data['ScheduleStatus']['status_date']); $scheduleItems['comments'] = trim($this->data['ScheduleStatus']['comment']); $scheduleItems['type'] = trim($this->data['ScheduleStatus']['type']); $this->ScheduleStatus->save($scheduleItems); } }
function setValues($data) { $result = parent::setValues($data); if (!isset($data['action_id'])) { return $result; } $action = new ScheduleItem(AMP_Registry::getDbcon(), $data['action_id']); if ($action->isOpen()) { return $result; } if (!($schedule_id = $this->_locateActionSchedule($data, 'schedule_id'))) { return $result; } $form_field = 'action_id_' . $schedule_id; $current_set = $this->_getValueSet($form_field); $this->addToFieldValueSet($form_field, array($data['action_id'] => $action->describeSlot())); return $result; }
function setStatusOptionValues() { $scheduleItem = new ScheduleItem(AMP_Registry::getDbcon()); $statums = $scheduleItem->getStatusOptions(); $this->setFieldValueSet('status', $statums); }