public function get_id_adjust_view() { $dbc = FannieDB::get($this->config->get('OP_DB')); $order = new PurchaseOrderModel($dbc); $order->orderID($this->adjust); $order->load(); $orderJSON = $order->toJSON(); $items = new PurchaseOrderItemsModel($dbc); $items->orderID($this->adjust); $itemsJSON = '['; foreach ($items->find() as $item) { $itemsJSON .= $item->toJSON() . ','; } if (strlen($itemsJSON) > 1) { $itemsJSON = substr($itemsJSON, 0, strlen($itemsJSON) - 1); } $itemsJSON .= ']'; $orderJSON = str_replace('\\', '\\\\', $orderJSON); $itemsJSON = str_replace('\\', '\\\\', $itemsJSON); $this->addOnloadCommand("existingOrder('{$orderJSON}', '{$itemsJSON}');\n"); return $this->get_id_view(); }