API Documentation: Warehouses Controller
General Controller Information
- Controller Name:
Warehouses - PHP Class:
Warehouses extends Controller - Purpose: This controller is responsible for managing a wide range of warehouse and inventory-related operations. This includes product lifecycle management (CRUD), Bill of Materials (BOM) creation and updates, inventory tracking (warehouse, bar, steward), digital product sales and loading, various request and approval workflows (purchase orders, bar stock requests, steward requests), financial operations like bank account lookups, and reporting.
- Authentication: Almost all endpoints require authentication. This is handled by a
RouteProtection()method called at the beginning of most public functions. It's assumed this method validates a user token and makes user data available to the controller methods. -
Input Handling:
- For
POSTrequests expecting structured data, the controller primarily uses an internal$this->getData()method. This method is presumed to parse an incoming JSON payload from the request body into a PHP associative array. - Several endpoints directly access
$_POSTvariables, indicating they expectapplication/x-www-form-urlencodedormultipart/form-datarequest bodies.
- For
-
Output Handling:
- Responses are exclusively in JSON format.
- This is achieved either by direct calls to
echo json_encode(...)or through a helper methodjsonResponse(...).
-
Common Response Structure:
- Success: Typically includes a status field (
"status": "success","status": true, or"status": "true") and amessagefield. Adatafield contains the requested information or results. - Error: Typically includes a status field (
"status": "error","status": false, or"status": "false") and a descriptivemessagefield.
- Success: Typically includes a status field (
-
Key Models Utilized:
Warehouse,User,Wallet,Appmessage,Settings,Ledgercreate,Ledger,Vendor.
- Error Reporting & Debugging: Commented-out
ini_setanderror_reportingdirectives suggest debugging during development. -
Potential Areas for Review/Refinement:
- HTTP Method Consistency (many POSTs for GET-like actions).
- Typos in messages.
- Detailed validation error propagation.
- Consistency in
jsonResponse()vs directjson_encodestatus types. - External/undefined method dependencies.
- Variable scope issues.
- Specific logic issues (e.g.,
buyDigitalProductsloop, uninitialized/misnamed models, hardcoded values).
Base Path & Authentication
Base Path: /warehouses
RouteProtection() method. A valid token must be provided with each request.
1. Update Product POST /warehouses/updateProduct
Description: Updates an existing product's details in the warehouse.
Request Body:
{
"name": "Updated Product Name",
"price": 120.50,
"category": "Electronics",
"stockType": "FIFO",
"instocks": 150,
"qty": 150,
"minSalePrice": 110.00,
"purchasePrice": 90.00,
"grade_letter": "A",
"category_id": 1,
"productCategory": "Gadgets",
"product_id": "prod_existing123"
}
Response (Success):
{
"status": "success",
"message": "Product updated successfully"
}
Response (Error):
{
"status": "error",
"message": "Failed to update product"
}
{
"status": "error",
"message": "Invalid request method"
}
Models Used:
warehouseModel->updateProductById()
2. Get All Products GET /warehouses/getAllProducts
Description: Retrieves a list of all products from the warehouse.
getData(), typically GETs don't have bodies; this might accept optional filter parameters via JSON body if getData() is flexible.
Request Body (Optional/If supported for filtering):
{}
Response (Success):
[
{
"product_id": "prod_123",
"name": "Sample Product",
"price": 100.00,
"category": "General",
"instocks": 50,
"qty": 50,
"purchasePrice": 70.00,
"minSalePrice": 90.00,
"grade_letter": "B",
"category_id": 2,
"productCategory": "Merchandise",
"last_updated": "2023-10-26 10:00:00"
// ... other product fields
}
// ... more products
]
Response (Error): Implicitly, if warehouseModel->getAllProducts() returns empty or error, the response might be an empty array or a generic error if the controller adds further checks, though not shown in the snippet.
Models Used:
warehouseModel->getAllProducts()
3. Get One Product POST /warehouses/getOneProduct
Description: Retrieves details for a specific product by its ID.
getData() for product_id. A GET request like /warehouses/getOneProduct/{product_id} would be more RESTful.
Request Body:
{
"product_id": "prod_123"
}
Response (Success):
{
"status": "success",
"data": {
"product_id": "prod_123",
"name": "Sample Product",
"price": 100.00
// ... other product fields
}
}
Response (Error):
{
"status": "error",
"message": "Product not found"
}
{
"status": "error",
"message": "Invalid product ID"
}
Models Used:
warehouseModel->getProductById()
4. Add Product (POS) POST /warehouses/addProduct_pos
Description: Adds a new product to the system (Point of Sale context).
Request Body:
{
"name": "New Product",
"price": 25.99,
"category": "Stationery",
"type": "Physical",
"instocks": 200,
"stockType": "LIFO",
"qty": 200,
"minSalePrice": 20.00,
"purchasePrice": 15.00,
"totalQtyPosted": 0,
"grade_letter": "C",
"totalQtySold": 0,
"category_id": 3,
"productCategory": "Office Supplies",
"stockControlled": "yes"
}
Response (Success):
{
"status": "success",
"message": "Product added successfully"
}
Response (Error):
{
"status": "error",
"message": "Failed to add product"
}
{
"status": "error",
"message": "Failed to add product end"
}
Models Used:
warehouseModel->addProduct_pos()
5. Purchase Report POST /warehouses/purchaseReport
Description: Retrieves a purchase report, optionally filtered by a date range.
getData() for parameters. start_date and end_date are optional. If not provided, the report might fetch all purchases.
Request Body:
{
"start_date": "2023-01-01",
"end_date": "2023-01-31"
}
Response (Success):
{
"status": "success",
"data": [
{
"purchase_id": "pur_abc",
"product_name": "Bought Item",
"quantity": 10,
"purchase_price": 50.00,
"total_cost": 500.00,
"purchase_date": "2023-01-15"
// ... other purchase report fields
}
// ... more purchase records
]
}
Response (Error):
{
"status": "error",
"message": "Failed to get purchases items"
}
Models Used:
warehouseModel->getPurchaseReport()
6. Add Bill of Materials (BOM) POST /warehouses/addBOM
Description: Creates a new Bill of Materials for a finished product, including its constituent raw materials.
Request Body:
{
"finished_product_id": "prod_finished_good_1",
"quantity_to_produce": 10,
"price": 150.00,
"created_by": "user_xyz",
"items": [
{
"raw_material_id": "prod_raw_material_A",
"quantity_required": 2,
"unit_cost": 25.00
},
{
"raw_material_id": "prod_raw_material_B",
"quantity_required": 5,
"unit_cost": 10.00
}
]
}
Note: price in request is price of the finished product. created_by is User ID or identifier.
Response (Success):
{
"status": "success",
"bom_id": "bom_new_123"
}
Response (Error):
{
"status": "error",
"message": "Failed to create BOM header"
}
{
"status": "error",
"message": "Failed to insert one or more BOM items"
}
Models Used:
warehouseModel->addBOMHeader()warehouseModel->addBOMDetail()
7. Update Bill of Materials (BOM) POST /warehouses/updateBOM
Description: Updates an existing Bill of Materials header and its details. The current implementation seems to update the header and then tries to update/add details based on the items provided. It also uses jsonResponse.
PUT to /warehouses/updateBOM/{bom_id}. The logic for updating/adding/deleting BOM detail items within updateBOM needs careful review in the model. The controller snippet provided calls updateBOMDetail for all items in the input array. It fetches existing details but doesn't explicitly show deletion logic for items not present in the incoming items array, though deleteBomDetailById exists as a separate endpoint.
Request Body:
{
"bom_id": "bom_existing_456",
"finished_product_product_id": "prod_finished_good_1",
"quantity_to_produce": 12,
"price": 155.00,
"items": [
{
"id": "detail_id_1",
"raw_material_id": "prod_raw_material_A",
"quantity_required": 3,
"unit_cost": 26.00
},
{
"raw_material_id": "prod_raw_material_C",
"quantity_required": 1,
"unit_cost": 30.00
}
]
}
Note: id in items is optional (ID of the existing BOM detail item if updating).
Response (Success - using jsonResponse):
{
"status": true,
"message": "updated successfully",
"data": null
}
Response (Error - Header Update Failed):
{
"status": "error",
"message": "Failed to update BOM header"
}
Note: Error status might be false if using jsonResponse consistently.
Models Used:
warehouseModel->updateBOMHeader()warehouseModel->getBOMDetailsByBOMId()warehouseModel->updateBOMDetail()
8. Delete BOM Detail by ID POST /warehouses/deleteBomDetailById
Description: Deletes a specific raw material item from a Bill of Materials.
DELETE to /warehouses/deleteBomDetail.
Request Body:
{
"finished_product_product_id": "prod_finished_good_1",
"raw_material_product_id": "prod_raw_material_A"
}
Response (Success - using jsonResponse):
{
"status": "true",
"message": "deleted successfully",
"data": {}
}
Note: status is string "true". data might contain confirmation or be null.
Response (Error - using jsonResponse):
{
"status": "false",
"message": "failed to delete bom detail",
"data": null
}
Note: status is string "false".
Models Used:
warehouseModel->deleteBOMDetail()
9. Get BOMs by Product ID POST /warehouses/getBOMsByProduct
Description: Retrieves all Bills of Materials associated with a specific finished product ID.
GET /warehouses/boms/product/{product_id}.
Request Body:
{
"finished_product_product_id": "prod_finished_good_1"
}
Response (Success):
{
"status": "success",
"data": [
{
"bom_id": "bom_123",
"finished_product_product_id": "prod_finished_good_1",
"quantity_to_produce": 10,
"price": 150.00,
"amount": 1500.00,
"created_by": "user_xyz",
"created_at": "2023-10-26 12:00:00",
"details": [
{
"raw_material_product_id": "prod_raw_material_A",
"quantity_required": 2,
"unit_cost": 25.00,
"total_cost": 50.00
}
]
}
]
}
Note: details array assumes the model joins or fetches these details.
Response (Error):
{
"status": "error",
"message": "No BOM found for this product"
}
{
"status": "error",
"message": "finished_product_product_id is required"
}
Models Used:
warehouseModel->getBOMsByProductId()
10. Get All BOMs POST /warehouses/getAllBOM
Description: Retrieves all Bill of Materials from the system.
GET /warehouses/getAllBOM.
Request Body:
{}
Response (Success - using jsonResponse):
{
"status": true,
"message": "success",
"data": [
{
"bom_id": "bom_123",
"finished_product_product_id": "prod_finished_good_1",
// ... other BOM header fields
"details": [
// ... BOM detail items
]
},
{
"bom_id": "bom_456",
"finished_product_product_id": "prod_finished_good_2",
// ... other BOM header fields
"details": [
// ... BOM detail items
]
}
]
}
Response (Error): If jsonResponse is used, it would likely follow its standard error format if getAllBOM() fails (e.g. {"status": false, "message": "Error fetching BOMs", "data": []}).
Models Used:
warehouseModel->getAllBOM()
11. Get All Customer Product Grades POST /warehouses/getAll_customer_product_grade
Description: Retrieves all defined customer product grades.
GET /warehouses/grades/all or similar.
Request Body:
{}
Response (Success):
{
"status": "success",
"message": "Grades loaded successfully",
"data": [
{
"grade_id": 1,
"grade_letter": "A",
"grade_value": 100.00
},
{
"grade_id": 2,
"grade_letter": "B",
"grade_value": 90.00
}
]
}
Response (Error):
{
"status": "false",
"message": "No grades found"
}
Note: status is string "false".
Models Used:
warehouseModel->getAllGrades()
12. Create Customer Product Grade POST /warehouses/create_customer_product_grade
Description: Creates a new customer product grade.
$jsonData but it's not explicitly initialized via $this->getData() within the function scope shown in the original code. It's assumed $jsonData is populated from the request by a preceding action or inherited scope. For robust API, explicit $jsonData = $this->getData(); is recommended. Assuming getData() is intended.
Request Body:
{
"grade_letter": "A+",
"grade_value": 110.00
}
Response (Success):
{
"status": "success",
"message": "Grade created successfully"
}
Response (Error):
{
"status": "false",
"message": "Missing grade letter or value"
}
Note: status is string "false".
Models Used:
warehouseModel->createGrade()
13. Update Customer Product Grade POST /warehouses/update_customer_product_grade
Description: Updates an existing customer product grade.
PUT /warehouses/grades/{grade_id}.
Request Body:
{
"grade_id": 1,
"grade_letter": "A_MODIFIED",
"grade_value": 105.00
}
Note: grade_id is the ID of the grade to update.
Response (Success):
{
"status": "success",
"message": "Grade updated successfully"
}
Response (Error):
{
"status": "false",
"message": "Missing grade letter or value"
}
Note: status is string "false".
Models Used:
warehouseModel->updateGrade()
14. Delete Customer Product Grade POST /warehouses/delete_customer_product_grade
Description: Deletes a customer product grade by its letter.
$_POST['grade_letter'] directly, indicating it expects form data (application/x-www-form-urlencoded) rather than a JSON payload. Typically would be DELETE /warehouses/grades.
Request Body (Form Data):
grade_letter=A_MODIFIED
Response (Success):
{
"status": "success",
"message": "Grade deleted successfully"
}
Response (Error):
{
"status": "false",
"message": "Missing grade letter"
}
Note: status is string "false".
Models Used:
warehouseModel->deleteGrade()
15. Load Digital Product POST /warehouses/loadDigitalProduct
Description: Processes the loading of a digital product using a product code. It marks the product as used, updates the user's wallet, and performs ledger postings.
$_POST['productCode'] directly (expects form data).
Request Body (Form Data):
productCode=CODE123XYZ
Response (Success):
{
"status": true,
"message": "Product loaded successfully and wallet funded"
}
Response (Error):
{
"status": false,
"message": "Invalid or already used product code"
}
{
"status": false,
"message": "Failed to update product status"
}
{
"status": false,
"message": "Wallet ledger update failed"
}
{
"status": false,
"message": "Invalid request method"
}
Latter error if not POST.
Models Used:
warehouseModel->getProductByCode()warehouseModel->markProductUsed()userModel->getUserDetailsById()- Calls internal method:
processPayment_checkBalance_walletTransfer_ledgerPosting_loaddp()
16. Process Payment (Digital Product Load) Internal
Description: An internal helper function to handle wallet debiting, ledger postings, and notifications for digital product loading. Not directly accessible as an API endpoint.
Parameters (passed internally): $data (array containing user_id, amount, postCode, memberData, etc.)
Response (Internal): JSON string indicating success or failure.
Models Used:
walletModel->getWalletBalance()userModel->getUserDetailsById(),userModel->getBra_Bus2()settingsModel->getBranchDetailsByID()ledgerModel->getLedgerBy_user_id(),ledgerModel->insertLedgerEntry_local_member()ledgercreateModel->getLedgerByUserid(),ledgercreateModel->ledgerBalance()- External helpers:
walletToWalletTransferMember_Rmf_general_local_oneLeg_dr(),getOTPExt_x3(),sendMail_x3()
17. Process Payment (General) Internal
Description: An internal helper function for general payments (wallet checks, transfers, ledger postings, notifications). Similar to the Digital Product Load payment processor but may focus on 'cr' (credit) transactions. Potentially callable, but structure suggests internal use.
$data parameter. The original code ends with // exit; after preparing $res, so it might not send a response if called as a standalone endpoint.
Parameters (passed internally or via request if public): $data (array with user_id, amount, postCode, memberData, total etc.)
Response (Internal or API): JSON string/object indicating success or failure.
Models Used:
walletModel->getWalletBalance()userModel->getUserDetailsById(),userModel->getBra_Bus2()settingsModel->getBranchDetailsByID()ledgerModel->getLedgerBy_user_id(),ledgerModel->insertLedgerEntry_local_member()ledgercreateModel->getLedgerByUserid(),ledgercreateModel->ledgerBalance()- External helpers:
walletToWalletTransferMember_Rmf_general_local_oneLeg_cr(),sendMail_x3(),getOTPExt_x3(),sendPush_x3()
18. Generate Code Internal
Description: Generates a unique 7-digit code, checking for its existence in the database. Called by buyDigitalProducts. Not directly accessible as an API endpoint.
Response (Internal): The new code (string) or 'null' (string) on failure.
Models Used:
warehouseModel->codeExists()warehouseModel->saveCode()
19. Buy Digital Products POST /warehouses/buyDigitalProducts
Description: Allows a user to purchase one or more digital products. It generates a unique code for the transaction, processes payment, saves the digital product entries, and returns the user's list of owned digital products.
$_POST['purchaseArray']. Only the *last* item's details from the loop within purchaseArray are used for payment processing (processPayment_checkBalance_walletTransfer_ledgerPosting) and for addDigitalProduct. If purchaseArray contains multiple distinct products, this is likely not the intended behavior.
Request Body (Form Data):
purchaseArray: A JSON string representing an array of products to purchase.
purchaseArray=[{"product_id":"dp_001","productName":"Digital Voucher A","unit_price":10,"quantity":2,"total":20},{"product_id":"dp_002","productName":"Digital Service B","unit_price":25,"quantity":1,"total":25}]
Response (Success):
{
"status": 1,
"message": "Product added successfully",
"data": [
{
"id": 1,
"product_code": "CODE123",
"product_id": "dp_002",
"price": 25,
"qty": 1,
"total": 25,
"status": "active",
"member_id": "user_abc",
"date_created": "2023-10-27 10:00:00"
}
// ... other digital products owned by the user
]
}
Note: status: 1 for success. product_id in data is from the last item in purchaseArray.
Response (Error):
{
"status": 0,
"message": "Failed to add product"
}
{
"status": 0,
"message": "Invalid request method"
}
Latter error if not POST. status: 0 for failure.
Models Used:
userModel->findByUser_id()- Internal method:
generateCode() - Internal method:
processPayment_checkBalance_walletTransfer_ledgerPosting() warehouseModel->addDigitalProduct()warehouseModel->getMyDigitalProduct()
20. Get My Loaded Digital Products POST /warehouses/getMyLoadedDigitalProducts
Description: Retrieves a list of digital products that the authenticated user has loaded (marked as used).
GET /warehouses/digitalProducts/loaded.
Request Body:
{}
Response (Success):
{
"status": 1,
"data": [
{
"id": 1,
"product_code": "USEDCODE123",
"product_id": "dp_001",
"productName": "Digital Voucher A",
"price": 10,
"status": "used",
"loaded_by_user_id": "user_abc",
"date_loaded": "2023-10-27 11:00:00"
// ... other relevant fields
}
]
}
Response (Error): No explicit error handling shown in original code; if model returns empty, data would be an empty array. If it throws an error, a generic server error might occur.
Models Used:
warehouseModel->getMyLoadedDigitalProducts()
21. Get My Digital Products POST /warehouses/getMyDigitalProducts
Description: Retrieves a list of all digital products owned by the authenticated user (active/not yet loaded).
GET /warehouses/digitalProducts/my.
Request Body:
{}
Response (Success):
{
"status": 1,
"data": [
{
"id": 2,
"product_code": "ACTIVECODE456",
"product_id": "dp_002",
"productName": "Digital Service B",
"price": 25,
"status": "active",
"member_id": "user_abc",
"date_created": "2023-10-27 10:05:00"
// ... other relevant fields
}
]
}
Response (Error): No explicit error handling shown; if model returns empty, data would be an empty array.
Models Used:
warehouseModel->getMyDigitalProduct()
22. Mark Digital Product Used POST /warehouses/markDigitalUsedBy
Description: Updates the status of a specific digital product, typically to mark it as 'inactive' or 'used' by the authenticated user.
$_POST variables directly (expects form data).
Request Body (Form Data):
id: (integer) The ID of the digital product record to update.status: (string) The new status (e.g., "inactive", "used").
id=2&status=inactive
Response (Success):
{
"status": 1,
"message": "Status updated"
}
Response (Error):
{
"status": 0,
"message": "Failed to update status"
}
Models Used:
warehouseModel->updateStatus()
23. Get All Products (for Bar) POST /warehouses/getAllProduct_bar
Description: Retrieves all products, possibly with a focus on items relevant to a bar inventory.
GET /warehouses/products/bar.
Request Body:
{}
Response (Success):
{
"status": "true",
"message": "successful",
"data": [
{
"product_id": "prod_bar_soda",
"productName": "Soda Can",
"price": 2.50,
"category": "Beverage"
// ... other product fields
}
]
}
Note: status is string "true".
Response (Empty/Error):
{
"status": "true",
"message": "successful",
"data": []
}
{
"status": false,
"message": "wrong method used",
"data": []
}
Latter error if not POST.
Models Used:
warehouseModel->getAllProduct_bar()
24. Get Products (General) POST /warehouses/getProducts
Description: Retrieves all products from the warehouse (similar to getAllProducts but with a different response structure).
GET /warehouses/products.
Request Body:
{}
Response (Success):
{
"status": "true",
"message": "successful",
"data": [
{
"product_id": "prod_gen_abc",
"productName": "General Item",
"price": 15.75
// ... other product fields
}
]
}
Response (Empty/Error):
{
"status": "true",
"message": "successful",
"data": []
}
{
"status": false,
"message": "wrong method used",
"data": []
}
Latter error if not POST.
Models Used:
warehouseModel->getAllProduct()
25. Warehouse Inventory Usage POST /warehouses/warehouse_inventory_usage
Description: Retrieves data related to warehouse inventory usage. The exact nature of the data is determined by the warehouseModel->warehouse_inventory_usage() method.
GET /warehouses/inventory/usage.
Request Body:
{}
Response (Success):
{
"status": "true",
"message": "successful",
"data": [
{
"product_id": "prod_xyz",
"productName": "High Usage Item",
"usage_metric": 1500
// ... other usage data fields
}
]
}
Response (Error):
{
"status": "false",
"message": "failed",
"data": []
}
Note: status is string "false".
Models Used:
warehouseModel->warehouse_inventory_usage()
26. Get Categories POST /warehouses/getCategories
Description: Retrieves a list of product categories.
GET /warehouses/categories.
Request Body:
{}
Response (Success):
{
"status": "true",
"message": "successful",
"data": [
{
"category_id": 1,
"category_name": "Electronics"
// ... other category fields
}
]
}
Response (Empty):
{
"status": "true",
"message": "successful",
"data": []
}
Models Used:
warehouseModel->getCategories()
27. Get Bar Inventory POST /warehouses/getBarInventory
Description: Retrieves the current inventory status for the bar.
GET /warehouses/inventory/bar.
Request Body:
{}
Response (Success):
{
"status": "true",
"message": "successful",
"data": [
{
"product_id": "prod_bar_soda",
"productName": "Soda Can",
"current_stock": 75,
"reorder_level": 20
// ... other inventory fields
}
]
}
Response (Error):
{
"status": "false",
"message": "failed",
"data": []
}
Note: status is string "false".
Models Used:
warehouseModel->getBarInventory()
28. Get All Stewards POST /warehouses/getAllSteward
Description: Retrieves a list of all stewards.
GET /warehouses/stewards.
Request Body:
{}
Response (Success):
{
"status": "true",
"message": "successful",
"data": [
{
"user_id": "steward_001",
"firstName": "John",
"lastName": "Doe",
"role": "Steward"
// ... other steward user fields
}
]
}
Response (Error):
{
"status": "false",
"message": "getAllSteward failed",
"data": []
}
Note: status is string "false".
Models Used:
warehouseModel->getAllSteward()
29. Delete Bar Request POST /warehouses/deleteBarRequest
Description: Deletes a specific bar request.
DELETE /warehouses/barRequests/{request_id}.
Request Body:
{
"request_id": "BAR-REQ-123"
}
Response (Success):
{
"status": "true",
"message": "bar request successful",
"data": {}
}
Note: Message seems to indicate success of deletion. data might contain confirmation from model.
Response (Error):
{
"status": "false",
"message": "delete failed",
"data": []
}
Note: status is string "false".
Models Used:
warehouseModel->deleteBarRequest()
30. Delete Request Order (Steward Request) POST /warehouses/deleteRequestOrder
Description: Deletes a specific steward request order.
DELETE /warehouses/stewardRequests/{request_id}.
Request Body:
{
"request_id": "STW-REQ-456"
}
Response (Success):
{
"status": "true",
"message": "successful",
"data": {}
}
Note: Message implies success of deletion. data might contain confirmation from model.
Response (Error):
{
"status": "false",
"message": "delete failed",
"data": []
}
Note: status is string "false".
Models Used:
warehouseModel->deleteStewardRequest()
31. Get Steward Inventory by User ID POST /warehouses/getStewardInventoryBy_user_id
Description: Retrieves the inventory held by a specific steward, identified by user ID, and their total stock count.
GET /warehouses/inventory/steward/{user_id}.
Request Body:
{
"user_id": "steward_001"
}
Response (Success):
{
"status": "true",
"message": "successful",
"data": [
{
"product_id": "prod_item_x",
"productName": "Item X",
"quantity_held": 15
// ... other steward inventory item fields
}
],
"totalStockCount": {
"total_items": 5,
"total_quantity": 150
}
}
Note: Structure of totalStockCount depends on what getTotalStockCount returns.
Response (Error):
{
"status": "false",
"message": "failed",
"data": []
}
Note: totalStockCount might be missing or null in case of an error. status is string "false".
Models Used:
warehouseModel->getStewardInventory()warehouseModel->getTotalStockCount()
32. Get Steward Inventory (All) POST /warehouses/getStewardInventoryAll
Description: Retrieves inventory data for all stewards.
GET /warehouses/inventory/stewards/all.
Request Body:
{}
Response (Success):
{
"status": "true",
"message": "successful",
"data": [
{
"steward_id": "steward_001",
"product_id": "prod_item_x",
"productName": "Item X",
"quantity_held": 15
// ... other fields, potentially grouped by steward
}
]
}
Response (Error):
{
"status": "false",
"message": "failed",
"data": []
}
Note: status is string "false".
Models Used:
warehouseModel->getStewardInventoryAll()
33. Get Steward Inventory (Auth User) POST /warehouses/getStewardInventory
Description: Retrieves the inventory for the currently authenticated steward and their total stock count.
GET /warehouses/inventory/steward/my.
Request Body:
{}
Response (Success):
{
"status": "true",
"message": "successful",
"data": [
{
"product_id": "prod_item_y",
"productName": "Item Y",
"quantity_held": 20
// ... other inventory item fields for the authenticated steward
}
],
"totalStockCount": {
"total_items": 3,
"total_quantity": 80
}
}
Response (Error):
{
"status": "false",
"message": "failed",
"data": []
}
Note: status is string "false".
Models Used:
warehouseModel->getStewardInventory()(with authenticated user's ID)warehouseModel->getTotalStockCount()(with authenticated user's ID)
34. Get Bar Inventory Sales POST /warehouses/getBarInventory_sales
Description: Retrieves sales data related to bar inventory.
getBarInventory_sales('2025-05-01', '2025-05-17'). This should be parameterized for real-world use. Typically GET /warehouses/inventory/bar/sales.
Request Body (if dates were parameterized):
{
"start_date": "2023-05-01",
"end_date": "2023-05-17"
}
Current Behavior Request Body (as dates are hardcoded):
{}
Response (Success):
{
"status": "true",
"message": "successful",
"data": [
{
"product_id": "prod_bar_juice",
"productName": "Juice Bottle",
"quantity_sold": 50,
"total_sales_value": 250.00
// ... other sales data fields
}
]
}
Response (Error):
{
"status": "false",
"message": "failed",
"data": []
}
Note: status is string "false".
Models Used:
warehouseModel->getBarInventory_sales()
35. Create Purchase Order POST /warehouses/createPurchaseOrder
Description: Creates a new purchase order request with multiple items.
Request Body:
{
"amount": 550.75,
"items": [
{
"product_id": "prod_supply_A",
"vendor_id": "vendor_001",
"quantity": 10,
"unit_price": 25.50
},
{
"product_id": "prod_supply_B",
"vendor_id": "vendor_002",
"quantity": 5,
"unit_price": 59.15
}
]
}
Note: amount is total amount of the purchase order.
Response (Success):
{
"status": true,
"message": "order sent successfully",
"data": []
}
Response (Validation Error / General Error):
{
"status": "false",
"message": "method not allowed",
"data": []
}
Note: Validation errors are prepared in $data['validation_errors'] in code, but not explicitly returned with details; falls to this generic error. status is string "false".
Models Used:
warehouseModel->insertPurchaseRequestOrder()
36. Approve Audit Order Item POST /warehouses/approveAuditOrder
Description: Approves or rejects an item within an audit order.
$_POST variables directly (expects form data).
Request Body (Form Data):
request_id: (string) The ID of the audit request.product_id: (string) The ID of the product being audited.status: (string) Action to take (e.g., "approved", "rejected").quantity: (integer) The audited quantity.
request_id=AUDIT-001&product_id=prod_audit_X&status=approved&quantity=98
Response (Success):
{
"status": true,
"message": "product approved successfully",
"data": []
}
Note: Message "approved" changes based on action.
Response (Error):
{
"status": "false",
"message": "failed to approved/reject product approval ",
"data": []
}
Note: status is string "false".
Models Used:
warehouseModel->approveAuditOrder()
37. Approve Purchase Request Item POST /warehouses/approvePurchaseRequest
Description: Approves or rejects an item within a purchase request by a general approver.
$_POST variables directly (expects form data).
Request Body (Form Data):
request_id: (string) The ID of the purchase request.product_id: (string) The ID of the product in the request.status: (string) Action to take (e.g., "approved", "rejected").quantity: (integer) The quantity being approved.
request_id=PO-REQ-100&product_id=prod_supply_A&status=approved&quantity=10
Response (Success):
{
"status": true,
"message": "product approved successfully",
"data": []
}
Note: Message "approved" changes based on action.
Response (Error):
{
"status": "false",
"message": "failed to approved/reject product approval ",
"data": []
}
Note: status is string "false".
Models Used:
warehouseModel->approvePurchaseOrder()
38. Purchasing Officer Approve Purchase Request POST /warehouses/purchasingOfficerApprovePurchaseRequest
Description: Specific approval step for a purchase request item by a purchasing officer.
$_POST variables directly (expects form data).
Request Body (Form Data):
request_id: (string) The ID of the purchase request.product_id: (string) The ID of the product.status: (string) Action (e.g., "approved", "rejected").quantity: (integer) Quantity approved by purchasing officer.officer_id: (string) ID of the purchasing officer.
request_id=PO-REQ-101&product_id=prod_supply_B&status=approved&quantity=5&officer_id=purch_officer_123
Note: user_id from RouteProtection is also passed to model.
Response (Success):
{
"status": true,
"message": "product approved successfully",
"data": []
}
Note: Message "approved" changes based on action.
Response (Error):
{
"status": "false",
"message": "failed to approved/reject product approval ",
"data": []
}
Note: status is string "false".
Models Used:
warehouseModel->purchasingOfficerApprovePurchaseRequest()
39. Vetting Officer Approve Purchase Request POST /warehouses/vettingOfficerApprovePurchaseRequest
Description: Specific approval step for a purchase request item by a vetting officer.
$_POST variables directly (expects form data).
Request Body (Form Data):
request_id: (string) The ID of the purchase request.product_id: (string) The ID of the product.status: (string) Action (e.g., "approved", "rejected").quantity: (integer) Quantity approved by vetting officer.officer_id: (string) ID of the vetting officer.
request_id=PO-REQ-102&product_id=prod_supply_C&status=approved&quantity=20&officer_id=vet_officer_456
Response (Success):
{
"status": true,
"message": "product approved successfully",
"data": []
}
Note: Message "approved" changes based on action.
Response (Error):
{
"status": "false",
"message": "failed to approved/reject product approval ",
"data": []
}
Note: status is string "false".
Models Used:
warehouseModel->vettingOfficerApprovePurchaseRequest()
40. President Officer Approve Purchase Request POST /warehouses/presidentOfficerApprovePurchaseRequest
Description: Final approval step for a purchase request item by a president/top-level approver.
$_POST variables directly (expects form data).
Request Body (Form Data):
request_id: (string) The ID of the purchase request.product_id: (string) The ID of the product.status: (string) Action (e.g., "approved", "rejected").quantity: (integer) Quantity approved by the president.
request_id=PO-REQ-103&product_id=prod_supply_D&status=approved&quantity=12
Response (Success):
{
"status": true,
"message": "product approved successfully",
"data": []
}
Note: Message "approved" changes based on action.
Response (Error):
{
"status": "false",
"message": "failed to approved/reject product approval ",
"data": []
}
Note: status is string "false".
Models Used:
warehouseModel->presidentOfficerApprovePurchaseRequest()
41. Get Account Name POST /warehouses/getAccountName
Description: Looks up a bank account name using an account number and bank code, likely via an external service (lookupAccountName).
Request Body:
{
"accountNumber": "1234567890",
"bankCode": "058"
}
Response (Success):
{
"status": true,
"message": "Account name fetched successfully",
"data": "JOHN DOE"
}
Response (Error - Missing Parameters):
{
"status": false,
"message": "accountNumber and bankCode are required."
}
Response (Error - Lookup Failed/Not Found):
{
"status": true,
"message": "Account name fetched successfully",
"data": null
}
Note: Controller logic sets status to true even if accountName is null.
External Calls:
lookupAccountName()(dependency not in this controller)
42. Get Bank List POST /warehouses/getbanklist
Description: Retrieves a list of banks, likely from an external service (getNombaBanks).
GET /warehouses/banks or /utils/banks.
Request Body:
{}
Note: jsonData is fetched in code but not used for getNombaBanks call in snippet.
Response (Success):
{
"status": true,
"message": "Successfully loaded bank list",
"data": [
{
"bankCode": "058",
"bankName": "Guaranty Trust Bank"
},
{
"bankCode": "011",
"bankName": "First Bank of Nigeria"
}
// ... more banks
]
}
Note: Structure of data depends on getNombaBanks() output.
Response (Error from Service):
{
"status": false,
"message": "Failed to retrieve bank list from provider",
"data": []
}
Example error message.
External Calls:
getNombaBanks()(dependency not in this controller)
43. Get My Transfer Logs POST /warehouses/getMyTransferLogs
Description: Retrieves transfer logs specific to the authenticated user.
GET /warehouses/transfers/logs/my.
Request Body:
{}
Response (Success):
{
"status": "success",
"data": [
{
"log_id": 1,
"transfer_type": "WALLET_TO_BANK",
"amount": 5000.00,
"status": "completed",
"timestamp": "2023-10-27 15:00:00",
"user_id": "user_abc"
// ... other log fields
}
]
}
Response (Error / No Logs):
{
"status": "error",
"message": "No logs found"
}
Models Used:
warehouseModel->getMyTransferLogs()
44. Get All Transfer Logs POST /warehouses/getTransferLogs
Description: Retrieves all transfer logs from the system (admin/privileged access likely).
GET /warehouses/transfers/logs/all.
Request Body:
{}
Response (Success):
{
"status": "success",
"data": [
{
"log_id": 1,
"user_id": "user_abc",
"transfer_type": "WALLET_TO_BANK",
"amount": 5000.00,
"status": "completed",
"timestamp": "2023-10-27 15:00:00"
},
{
"log_id": 2,
"user_id": "user_xyz",
"transfer_type": "INTERNAL",
"amount": 200.00,
"status": "pending",
"timestamp": "2023-10-27 16:00:00"
}
]
}
Response (Error / No Logs):
{
"status": "error",
"message": "No logs found"
}
Models Used:
warehouseModel->fetchTransferLogs()
45. Zero Out Steward Stock POST /warehouses/zeroStewardStock
Description: Sets the stock quantity of a specific steward to zero. This is an administrative action.
Request Body:
{
"user_id": "steward_002"
}
Note: user_id is the ID of the steward whose stock is to be zeroed.
Response (Success):
{
"status": true,
"message": "zeroStewardStock successfully",
"data": []
}
Response (Error):
{
"status": "false",
"message": "failed to zeroStewardStock ",
"data": []
}
Note: status is string "false".
Models Used:
warehouseModel->zeroStewardStock()
46. Assign Officer to Purchase Request POST /warehouses/assignOfficerToPurchaseRequest
Description: Assigns a specific officer (e.g., for vetting or approval) to a purchase request.
$_POST variables directly (expects form data).
Request Body (Form Data):
request_id: (string) The ID of the purchase request.officer_id: (string) The user ID of the officer being assigned.
request_id=PO-REQ-200&officer_id=officer_vet_789
Response (Success):
{
"status": true,
"message": "request has been assigned successfully",
"data": []
}
Response (Error):
{
"status": "false",
"message": "failed to assign request approval ",
"data": []
}
Note: status is string "false".
Models Used:
warehouseModel->assignOfficerToPurchaseRequest()
47. Get Approved Purchase Requests POST /warehouses/getApprovedPurchaseRequest
Description: Retrieves a list of all purchase requests that have been fully approved.
GET /warehouses/purchaseRequests/approved.
Request Body:
{}
Response (Success):
{
"status": true,
"message": "fetched approved requests successfully",
"data": [
{
"request_id": "PO-APPROVED-001",
"created_by": "user_initiate_abc",
"approved_date": "2023-10-26",
"total_amount": 1200.00
// ... other fields of an approved purchase request
}
]
}
Response (Empty):
{
"status": true,
"message": "fetched approved requests successfully",
"data": []
}
Models Used:
warehouseModel->getApprovedPurchaseRequest()
48. Get Unapproved Purchase Requests POST /warehouses/getUnapprovePurchaseRequest
Description: Retrieves a list of purchase requests that are not yet fully approved.
GET /warehouses/purchaseRequests/unapproved.
Request Body:
{}
Response (Success):
{
"status": true,
"message": "fetched unapproved requests successfully",
"data": [
{
"request_id": "PO-PENDING-002",
"created_by": "user_initiate_xyz",
"request_date": "2023-10-27",
"status": "pending_vetting"
// ... other fields
}
]
}
Response (Empty):
{
"status": true,
"message": "fetched unapproved requests successfully",
"data": []
}
Models Used:
warehouseModel->getUnapprovePurchaseRequest()
49. Get All Purchase Requests POST /warehouses/getPurchaseRequests
Description: Retrieves all purchase requests, regardless of their approval status.
GET /warehouses/purchaseRequests.
Request Body:
{}
Response (Success):
{
"status": true,
"message": "fetched purchase requests successfully",
"data": [
// ... list of all purchase requests (approved, pending, rejected etc.)
]
}
Response (Empty):
{
"status": true,
"message": "fetched purchase requests successfully",
"data": []
}
Models Used:
warehouseModel->getPurchaseRequests()
50. Get Vetting Purchase Requests (My) POST /warehouses/getVettingPurchaseRequests
Description: Retrieves purchase requests assigned to the authenticated user (presumably a vetting officer) for vetting.
GET /warehouses/purchaseRequests/vetting/my.
Request Body:
{}
Response (Success):
{
"status": true,
"message": "fetched vetting requests successfully",
"data": [
{
"request_id": "PO-VET-003",
"assigned_officer_id": "user_vet_me",
"status": "pending_vetting_approval"
// ... other fields
}
]
}
Note: assigned_officer_id would be the authenticated user.
Response (Empty):
{
"status": true,
"message": "fetched vetting requests successfully",
"data": []
}
Models Used:
warehouseModel->getVettingPurchaseRequests()(called with$user->user_id)
51. Get Vetting Purchase Requests (All) POST /warehouses/getVettingPurchaseRequests2
Description: Retrieves all purchase requests that are currently awaiting vetting, not specific to any single officer.
GET /warehouses/purchaseRequests/vetting/all.
Request Body:
{}
Response (Success):
{
"status": true,
"message": "fetched vetting requests successfully",
"data": [
{
"request_id": "PO-VET-004",
"status": "pending_vetting",
"assigned_officer_id": null
// ... other fields
}
]
}
Note: assigned_officer_id could be null or assigned but still pending.
Response (Empty):
{
"status": true,
"message": "fetched vetting requests successfully",
"data": []
}
Models Used:
warehouseModel->getVettingPurchaseRequests2()
52. Get Approval Purchase Requests (All) POST /warehouses/getApprovalPurchaseRequests
Description: Retrieves all purchase requests that are awaiting final approval (e.g., by president or top-level authority).
GET /warehouses/purchaseRequests/approval/all.
Request Body:
{}
Response (Success):
{
"status": true,
"message": "fetched approval requests successfully",
"data": [
{
"request_id": "PO-FINALAPP-005",
"status": "pending_president_approval"
// ... other fields
}
]
}
Response (Empty):
{
"status": true,
"message": "fetched approval requests successfully",
"data": []
}
Models Used:
warehouseModel->getApprovalPurchaseRequests()
53. Get Approved Audit Orders POST /warehouses/getApprovedAuditOrder
Description: Retrieves a list of audit orders that have been approved.
GET /warehouses/auditOrders/approved.
Request Body:
{}
Response (Success):
{
"status": true,
"message": "fetched approved requests successfully",
"data": [
{
"request_id": "AUDIT-APPROVED-001",
"audited_by": "auditor_user_id",
"status": "approved",
"approval_date": "2023-10-28"
// ... other audit order fields
}
]
}
Response (Empty):
{
"status": true,
"message": "fetched approved requests successfully",
"data": []
}
Models Used:
warehouseModel->getApprovedAuditOrder()
54. Get Unapproved Audit Orders POST /warehouses/getUnapprovedAuditOrder
Description: Retrieves a list of audit orders that are pending approval or action.
GET /warehouses/auditOrders/unapproved.
Request Body:
{}
Response (Success):
{
"status": true,
"message": "fetched unapproved requests successfully",
"data": [
{
"request_id": "AUDIT-PENDING-002",
"created_by": "user_requesting_audit",
"status": "pending_audit_review"
// ... other fields
}
]
}
Response (Empty):
{
"status": true,
"message": "fetched unapproved requests successfully",
"data": []
}
Models Used:
warehouseModel->getUnapprovedAuditOrder()
55. Get Stock Alerts POST /warehouses/getStockAlert
Description: Checks for products with low stock levels based on predefined thresholds and logs these alerts. Optionally sends an email notification.
GET /warehouses/stock/alerts. The mail() function is used, which might have server configuration dependencies. The response data uses $restockData in the original code, which is not defined in the snippet; it should likely be $lowStockItems. inventoryModel is also used but not initialized in constructor (potential typo, might refer to warehouseModel or a missing model).
Request Body:
{}
Response (Success with Alerts):
{
"status": "true",
"message": "successful",
"data": [
{
"product_id": "prod_low_A",
"productName": "Product A Low Stock",
"total_quantity_left": 5
}
]
}
Note: Assuming $restockData in original code was meant to be $lowStockItems.
Response (Success with No Alerts):
{
"status": "true",
"message": "successful",
"data": []
}
Models Used:
warehouseModel->checkStockAlerts()inventoryModel->logStockAlert()(Potential issue:inventoryModelnot initialized)
Side Effects: Logs stock alerts, sends an email.
56. Check Reorder Alerts (Cron) GET/POST /warehouses/checkReorderAlerts
Description: Checks products against stock alerts and creates a reorder alert if one doesn't already exist for a product that needs reordering. Designed to be run as a cron job.
echoes plain text, not JSON.
Request Body (Not typically applicable for cron, but if POST):
{}
Response (Plain Text):
Reorder check complete.
Models Used:
warehouseModel->checkStockAlerts()warehouseModel->hasPendingAlert()warehouseModel->createReorderAlert()
Side Effects: Creates reorder alert records in the database.
57. Get Reorder Alerts POST /warehouses/getReorderAlerts
Description: Retrieves a list of all active reorder alerts.
GET /warehouses/reorderAlerts.
Request Body:
{}
Response (Success):
{
"status": true,
"message": "fetched reorder alert successfully",
"data": [
{
"alert_id": 1,
"product_id": "prod_reorder_B",
"productName": "Product B Needs Reorder",
"alert_date": "2023-10-28",
"status": "pending"
}
]
}
Note: productName likely joined from products table.
Response (Empty):
{
"status": true,
"message": "fetched reorder alert successfully",
"data": []
}
Models Used:
warehouseModel->getReorderAlerts()
58. Get My Stock Transfers POST /warehouses/getStocksTransfer
Description: Retrieves stock transfer records associated with the authenticated user.
GET /warehouses/stockTransfers/my.
Request Body:
{}
Response (Success):
{
"status": true,
"message": "fetched Stock transfers successfully",
"data": [
{
"transfer_id": "tf_my_001",
"product_id": "prod_xyz",
"quantity": 10,
"from_location": "Warehouse A",
"to_location": "Bar Section 1",
"transfer_date": "2023-10-25",
"user_id": "user_abc"
}
]
}
Note: user_id would be the authenticated user.
Response (Empty):
{
"status": true,
"message": "fetched Stock transfers successfully",
"data": []
}
Models Used:
warehouseModel->getStocksTransfer()
59. Get All Stock Transfers POST /warehouses/getAllStocksTransfer
Description: Retrieves all stock transfer records in the system.
GET /warehouses/stockTransfers/all.
Request Body:
{}
Response (Success):
{
"status": true,
"message": "fetched Stock transfers successfully",
"data": [
{
"transfer_id": "tf_all_002",
"product_id": "prod_abc",
"quantity": 5,
"from_location": "Main Warehouse",
"to_location": "Steward John",
"transfer_date": "2023-10-26",
"user_id": "admin_user"
}
// ... more transfer records
]
}
Response (Empty):
{
"status": true,
"message": "fetched Stock transfers successfully",
"data": []
}
Models Used:
warehouseModel->getAllStocksTransfer()
60. Get Total Stock Per Product POST /warehouses/getTotalStockPerProduct
Description: Retrieves a summary of total stock for each product, broken down by quantity in the main warehouse and quantity in the bar.
GET /warehouses/stock/summary.
Request Body:
{}
Response (Success):
{
"status": true,
"message": "fetched stock summary successfully",
"data": [
{
"productName": "Soda Can",
"warehouse_qty": 100,
"bar_qty": 20,
"total_qty": 120
},
{
"productName": "Juice Bottle",
"warehouse_qty": 50,
"bar_qty": 50,
"total_qty": 100
}
]
}
Response (Empty):
{
"status": true,
"message": "fetched stock summary successfully",
"data": []
}
Models Used:
warehouseModel->getTotalStockPerProduct()
61. Transfer Stock POST /warehouses/transferStock
Description: Records a stock movement (transfer) between locations (e.g., Warehouse to Bar, Bar to Warehouse, Warehouse to Vendor). The exact logic for fromLocation and toLocation and stock update method depends on the authenticated user's role.
$_POST['payload'] which is expected to be a JSON string that needs decoding, or the actual structure of $_POST['payload'] should be an array if PHP handles it automatically. The code $data['item']['itemId'] suggests payload becomes an associative array after $_POST['payload'] is likely JSON decoded.
Request Body (Form Data with JSON payload):
payload: A JSON string representing the item to transfer.
payload={"itemId":"prod_transfer_123","quantity":5,"toLocation":"steward_user_id_or_bar_id","notes":"Transfer for event"}
Alternatively, if $_POST['payload'] is treated as an array directly by PHP's form parsing for complex names, it might look like payload[itemId]=prod_transfer_123&payload[quantity]=5... but the code $_POST['payload'] suggests it's a single string value that's then decoded.
Response (Success):
{
"status": true,
"message": "product transferred successfully",
"data": []
}
Response (Error): No explicit error path shown in the controller snippet, but if model calls fail, it might result in an incomplete operation or PHP error if not caught.
Models Used:
userModel->getUserBy_Init_user_id()warehouseModel->updateBarStockBalance()(conditional)warehouseModel->updateWarehouseStockBalance()(conditional)warehouseModel->logMovement()
62. Get My Messages POST /warehouses/getMessage
Description: Retrieves messages for the authenticated user from the application messaging system.
GET /warehouses/messages/my or /user/messages.
Request Body:
{}
Response (Success):
{
"status": "true",
"message": "fetch messages successfully",
"data": [
{
"message_id": 101,
"subject": "Your order has shipped",
"content": "Details of your recent order...",
"date_received": "2023-10-28 10:00:00",
"is_read": false
}
]
}
Response (Empty):
{
"status": "true",
"message": "fetch messages successfully",
"data": []
}
Models Used:
appMessageModel->getMessage()(singular, might be intended to begetMessagesfor a list)
63. Get All Messages POST /warehouses/getMessages
Description: Retrieves all messages from the application messaging system (likely for admin users).
GET /warehouses/messages/all or /admin/messages.
Request Body:
{}
Response (Success):
{
"status": "true",
"message": "fetch messages successfully",
"data": [
{
"message_id": 101,
"user_id": "user_abc",
"subject": "User order shipped",
"content": "...",
"date_sent": "2023-10-28 10:00:00"
},
{
"message_id": 102,
"user_id": "user_xyz",
"subject": "Account update",
"content": "...",
"date_sent": "2023-10-28 11:00:00"
}
]
}
Response (Empty):
{
"status": "true",
"message": "fetch messages successfully",
"data": []
}
Models Used:
appMessageModel->getMessages()
64. Get Steward Bar Requests (My) POST /warehouses/getStewardBarRequestsWithItems
Description: Retrieves bar requests made by the authenticated steward, along with the items in each request.
GET /warehouses/barRequests/steward/my/detailed.
Request Body:
{}
Response (Success):
{
"status": true,
"message": "fetched orders successfully",
"data": [
{
"request_id": "BAR-STW-001",
"requested_by": "StewardFirstName StewardLastName",
"approved_by": "ManagerName",
"status": "pending",
"created_at": "2023-10-27 09:00:00",
"items": [
{
"id": "item_detail_1",
"product_id": "prod_soda_can",
"name": "Soda Can",
"quantity": 24,
"quantity_approved": 0,
"status": "pending"
}
]
}
]
}
Note: requested_by is name of authenticated steward, approved_by can be null.
Response (Empty):
{
"status": true,
"message": "fetched orders successfully",
"data": []
}
Models Used:
warehouseModel->getStewardBarRequestsWithItems()userModel->getUserBy_Init_user_id()
65. Get My Bar Requests POST /warehouses/getMyBarRequestsWithItems
Description: Retrieves bar requests made by the authenticated user (could be a bar manager or other role making requests), including items.
GET /warehouses/barRequests/my/detailed.
Request Body:
{}
Response (Success):
{
"status": true,
"message": "fetched orders successfully",
"data": [
{
"request_id": "BAR-REQ-005",
"requested_by": "UserFirstName UserLastName",
"approved_by": null,
"status": "approved",
"created_at": "2023-10-26 14:00:00",
"items": [
{
"id": "item_detail_req_5_1",
"product_id": "prod_juice_box",
"name": "Juice Box",
"quantity": 50,
"quantity_approved": 50,
"status": "approved"
}
]
}
]
}
Note: requested_by is authenticated user's name.
Response (Empty):
{
"status": true,
"message": "fetched orders successfully",
"data": []
}
Models Used:
warehouseModel->getMyBarRequestsWithItems()userModel->getUserBy_Init_user_id()(Used for formattingrequested_byname)
66. Get Pending Bar Requests (All) POST /warehouses/getPendingBarRequestsWithItems
Description: Retrieves all bar requests that are currently pending approval, along with their items and stock availability information.
GET /warehouses/barRequests/pending/detailed.
Request Body:
{}
Response (Success):
{
"status": true,
"message": "fetched orders successfully",
"data": [
{
"request_id": "BAR-PEND-002",
"requested_by": "Requester FullName",
"requested_by_id": "user_requester_id",
"approved_by": null,
"status": "pending",
"created_at": "2023-10-28 11:00:00",
"items": [
{
"id": "item_detail_pend_2_1",
"product_id": "prod_water_bottle",
"name": "Water Bottle",
"quantity": 100,
"quantity_approved": 0,
"available": 500,
"bar_qty": 50
}
]
}
]
}
Note: available is warehouse quantity, bar_qty is current bar quantity.
Response (Empty):
{
"status": true,
"message": "fetched orders successfully",
"data": []
}
Models Used:
warehouseModel->getPendingBarRequestsWithItems()userModel->findByUser_id()(to get requester's name)
67. Get Pending Steward Requests (All) POST /warehouses/getPendingStewardRequestsWithItems
Description: Retrieves all pending requests made by stewards for stock, including item details and current stock levels.
GET /warehouses/stewardRequests/pending/detailed. In response, available is bar stock, bar_qty is steward's current stock.
Request Body:
{}
Response (Success):
{
"status": true,
"message": "fetched orders successfully",
"data": [
{
"request_id": "STW-PEND-003",
"requested_by": "Steward FullName",
"requested_by_id": "steward_user_id_abc",
"approved_by": null,
"status": "pending_bar_approval",
"created_at": "2023-10-28 12:00:00",
"items": [
{
"id": "item_detail_stwp_3_1",
"product_id": "prod_snack_bar",
"name": "Snack Bar",
"quantity": 30,
"quantity_approved": 0,
"available": 100,
"bar_qty": 5
}
]
}
]
}
Response (Empty):
{
"status": true,
"message": "fetched orders successfully",
"data": []
}
Models Used:
warehouseModel->getPendingStewardRequestsWithItems()userModel->findByUser_id()(to get steward's name)
68. Get All Purchase Orders (Detailed) POST /warehouses/getPurchaseOrders
Description: Retrieves all purchase orders with their associated items and some stock information.
GET /warehouses/purchaseOrders/detailed.
Request Body:
{}
Response (Success):
{
"status": true,
"message": "fetched orders successfully",
"data": [
{
"request_id": "PO-DETAIL-001",
"requested_by": "Creator FullName",
"requested_by_id": "user_creator_id",
"status": "approved",
"request_date": "2023-10-25 10:00:00",
"items": [
{
"product_id": "prod_bulk_A",
"product_name": "Bulk Item A",
"quantity": 50,
"vendor_id": "vendor_001",
"quantity_approved": 50,
"available": 200,
"bar_qty": 30
}
]
}
]
}
Note: available is warehouse qty, bar_qty is bar qty.
Response (Empty):
{
"status": true,
"message": "fetched orders successfully",
"data": []
}
Models Used:
warehouseModel->getAllPurchaseOrders()userModel->findByUser_id()
69. Get All Bar Requests (Detailed) POST /warehouses/getAllBarRequestsWithItems
Description: Retrieves all bar requests (regardless of status) with their items.
$data is passed to getAllBarRequestsWithItems($data) in original code, but $data is not defined within this method's scope from $this->getData(). It might be implicitly available or this is a bug. Assumes it should be $this->warehouseModel->getAllBarRequestsWithItems() or similar if no specific filter from $data is intended. Typically GET /warehouses/barRequests/all/detailed.
Request Body:
{}
Note: Assuming no specific filter data is used based on the issue noted above.
Response (Success):
{
"status": true,
"message": "fetched orders successfully",
"data": [
{
"request_id": "BAR-ALL-007",
"requested_by": "User FullName",
"requested_by_id": "user_id_of_requester",
"approved_by": "Approver FullName",
"status": "completed",
"created_at": "2023-10-24 16:00:00",
"items": [
{
"id": "item_detail_all_7_1",
"product_id": "prod_bev_X",
"name": "Beverage X",
"quantity": 10,
"quantity_approved": 10,
"available": 150,
"bar_qty": 25
}
]
}
]
}
Note: requested_by is name of user who made request. approved_by can be null. available is warehouse qty, bar_qty is bar qty.
Response (Empty):
{
"status": true,
"message": "fetched orders successfully",
"data": []
}
Models Used:
warehouseModel->getAllBarRequestsWithItems()userModel->findByUser_id()(Used for formattingrequested_byname)
70. Add Bar Request POST /warehouses/addBarRequest
Description: Allows a user (e.g., bar manager) to create a new request for items from the warehouse for the bar.
Request Body:
{
"data": [
{
"product_id": "prod_soda_can",
"quantity": 48,
"product_name": "Soda Can"
},
{
"product_id": "prod_juice_bottle",
"quantity": 24,
"product_name": "Juice Bottle"
}
],
"narration": "Weekly restock for main bar"
}
Note: product_name might be redundant if product_id is sufficient. narration is optional.
Response (Success):
{
"status": true,
"message": "order sent successfully",
"data": []
}
Response (Error / Validation):
{
"status": "false",
"message": "method not allowed",
"data": []
}
Note: This message is generic; validation errors are prepared in code but not explicitly returned with details. status is string "false".
Models Used:
userModel->getBra_Bus2()warehouseModel->addBarRequest()
71. Add Steward Request POST /warehouses/addStewardRequest
Description: Allows a bar manager or authorized user to create a stock request on behalf of a steward, or for a steward to request from the bar.
Request Body:
{
"steward_id": "steward_user_003",
"data": [
{
"product_id": "prod_chips_small",
"quantity": 20,
"product_name": "Small Chips"
},
{
"product_id": "prod_water_500ml",
"quantity": 12,
"product_name": "Water 500ml"
}
]
}
Response (Success):
{
"status": true,
"message": "order sent successfully",
"data": []
}
Response (Error / Validation):
{
"status": "false",
"message": "method not allowed",
"data": []
}
Note: Generic message. status is string "false".
Models Used:
warehouseModel->addStewardRequest()
72. Approve Bar Request POST /warehouses/approveBarRequest
Description: Approves items in a bar request. This is typically done by a warehouse manager or someone with approval rights.
Request Body:
{
"data": {
"bar_request_id": "BAR-REQ-005",
"requested_by": "user_id_who_requested",
"items": [
{
"product_id": "prod_soda_can",
"quantity": 40
},
{
"product_id": "prod_juice_bottle",
"quantity": 20
}
]
}
}
Note: requested_by is ID of user who made request. quantity in items is approved quantity.
Response (Success):
{
"status": true,
"message": "order updated successfully",
"data": []
}
Response (Error / Validation):
{
"status": "false",
"message": "method not allowed",
"data": []
}
Note: Generic message. status is string "false".
Models Used:
warehouseModel->approveBarRequest()
73. Approve Steward Request POST /warehouses/approveStewardRequest
Description: Approves items in a steward's stock request. This is typically done by a bar manager from bar stock.
Request Body:
{
"data": {
"bar_request_id": "STW-REQ-003",
"requested_by": "steward_user_id_abc",
"items": [
{
"product_id": "prod_chips_small",
"quantity": 18
},
{
"product_id": "prod_water_500ml",
"quantity": 12
}
]
}
}
Note: bar_request_id is ID of steward's request. requested_by is ID of steward. quantity is approved quantity.
Response (Success):
{
"status": true,
"message": "order updated successfully",
"data": []
}
Response (Error / Validation):
{
"status": "false",
"message": "method not allowed",
"data": []
}
Note: Generic message. status is string "false".
Models Used:
warehouseModel->approveStewardRequest()
74. Get Stock Report POST /warehouses/getStockReport
Description: Retrieves a stock report for a given date range. The actual structure of the response depends on the model method getStockReport.
GET /warehouses/reports/stock.
Request Body:
{
"start_date": "2023-01-01",
"end_date": "2023-01-31"
}
Response (Success Example):
{
"status": true,
"message": "Stock report generated successfully.",
"data": {
"report_period": "2023-01-01 to 2023-01-31",
"items": [
{
"product_id": "prod_alpha",
"productName": "Product Alpha",
"opening_stock": 100,
"stock_in": 50,
"stock_out": 75,
"closing_stock": 75
}
],
"summary": {
"total_value_change": -500.00
}
}
}
Note: Controller doesn't explicitly echo JSON for success in snippet; this is an example of what a successful response *might* look like.
Response (Error - Method Not Allowed if not POST):
{
"status": false,
"message": "method not allowed",
"data": null
}
Note: This response occurs if request method is not POST, assuming jsonResponse structure.
Models Used:
warehouseModel->getStockReport()