'That document no longer exists.'])); } $client_id = intval($doc['client_id']); enforceClientAccess(); if (!billingCanEditItems($type, $doc)) { exit(json_encode(['error' => billingNumber($type, $doc) . " can't be changed now - " . ($type === 'quote' ? 'it has been answered or invoiced.' : 'it is paid, cancelled or non-billable.')])); } $item = null; foreach (billingItems($type, $doc_id) as $line) { if (intval($line['item_id']) === $item_id) { $item = $line; } } if (!$item) { exit(json_encode(['error' => 'That line no longer exists.'])); } $t = billingType($type); $currency = (string) $doc["{$t['col']}_currency_code"]; $taxes = billingTaxes($item['item_created_at']); $line_product = intval($item['item_product_id']) ? productRow($item['item_product_id']) : null; $product_name = $line_product ? $line_product['product_name'] : ''; $product_type = $line_product ? $line_product['product_type'] : ''; $quantity = billingQuantity($item['item_quantity']); $price = number_format(floatval($item['item_price']), 2, '.', ''); ob_start(); ?>