<?php
$workspace_path = "c:\\Users\\User\\Documents\\Antigravity Projects\\Apperal Managment System -Vanila- PHP";
chdir($workspace_path . "\\api");

// Start mock session
if (session_status() === PHP_SESSION_NONE) {
    session_start();
}
$_SESSION['user_id'] = 1;
$_SESSION['user_role'] = 'owner';
$_SESSION['role'] = 'owner';
$_SESSION['company_id'] = 1;
$_SESSION['company_name'] = 'NexCore Apparel';
$_SESSION['company_currency'] = 'LKR';

// Define inputs for updating invoice 17
$_POST = [
    'action' => 'update',
    'id' => 17,
    'buyer_name' => 'Multi Zara Test Updated',
    'buyer_brand' => 'Zara Kids & Man',
    'buyer_contact' => 'Jane Smith',
    'buyer_email' => 'jane@zaratest.com',
    'buyer_phone' => '+34 699 999 999',
    'buyer_country' => 'Spain',
    'products' => [
        [
            'name' => 'Denim Jacket XL',
            'sku' => 'DJ-XL-001',
            'description' => 'Premium XL Denim Jacket (Updated)',
            'quantity' => 10, // Decreased from 15 to 10
            'unit_price' => 2400.00 // Decreased price from 2500 to 2400
        ],
        [
            'name' => 'Slim Fit Chino L',
            'sku' => 'CH-L-002',
            'description' => 'Beige Slim Fit Chinos',
            'quantity' => 30, // Increased from 20 to 30
            'unit_price' => 1800.00
        ],
        [
            'name' => 'New Cotton Socks', // Added a third product
            'sku' => 'SO-COT-003',
            'description' => 'Black Cotton Socks',
            'quantity' => 50,
            'unit_price' => 200.00
        ]
    ],
    'taxes_vat' => 250.00,
    'discounts' => 150.00,
    'shipping_charges' => 350.00,
    'po_reference' => 'PO-MULTI-001-REV',
    'payment_terms' => 'Advance Payment',
    'payment_term_id' => 1,
    'due_date' => '2026-07-20',
    'status' => 'Pending'
];

// Include the api directly (which outputs json and exits)
require_once 'invoices.php';
?>
