Merge branch 'feature-service-management-ser002' into feature-service-management
This commit is contained in:
+2
-1
@@ -1,4 +1,5 @@
|
||||
#include "Controller.h"
|
||||
#include "InventoryItem.h"
|
||||
|
||||
bool Controller::login(const std::string& username, const std::string& password)
|
||||
{
|
||||
@@ -50,7 +51,6 @@ void Controller::purchaseComboPackage(const std::string& comboPackageID, const s
|
||||
|
||||
util::Map<std::string, const InventoryItem*> Controller::getInventoryItems()
|
||||
{
|
||||
return util::Map<std::string, const InventoryItem*>();
|
||||
}
|
||||
|
||||
const InventoryItem* Controller::getInventoryItem(const std::string& inventoryItemID)
|
||||
@@ -105,6 +105,7 @@ void Controller::createJobCard(const std::string& bookingID, const std::string&
|
||||
|
||||
void Controller::createService(const std::string& name, const util::Vector<std::string>& inventoryItemIDs, double laborCost)
|
||||
{
|
||||
m_serviceManagementService.createService(name, inventoryItemIDs, laborCost);
|
||||
}
|
||||
|
||||
void Controller::removeService(const std::string& serviceID)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "Enums.h"
|
||||
#include "ServiceManagementService.h"
|
||||
#include "UserManagementService.h"
|
||||
#include "InventoryManagementService.h"
|
||||
|
||||
class Service;
|
||||
class ComboPackage;
|
||||
|
||||
+15
@@ -67,4 +67,19 @@ void ServiceManagementService::createJobCard(const std::string& bookingID, const
|
||||
JobCard* jobCard = Factory::getObject<JobCard>(bookingID, currentBooking, currentService, serviceID, technicianID, selectedTechnician, util::ServiceJobStatus::STARTED);
|
||||
currentJobCards.insert(jobCard->getId(), jobCard);
|
||||
sendNotification(selectedTechnician,title, message);
|
||||
}
|
||||
|
||||
void ServiceManagementService::createService(const std::string& name, const util::Vector<std::string>& inventoryItemIDs, double laborCost)
|
||||
{
|
||||
Service* newService = Factory::getObject<Service>(name, inventoryItemIDs, laborCost);
|
||||
if (newService == nullptr)
|
||||
{
|
||||
throw std::runtime_error("Unable to create new service.");
|
||||
}
|
||||
util::Map<std::string, Service*>& currentServices = m_dataStore.getServices();
|
||||
if (currentServices.find(newService->getId()) != -1)
|
||||
{
|
||||
throw std::runtime_error("Service with this ID Already exists.");
|
||||
}
|
||||
currentServices.insert(newService->getId(), newService);
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "ServiceBooking.h"
|
||||
#include "Enums.h"
|
||||
#include "Service.h"
|
||||
#include "InventoryItem.h"
|
||||
|
||||
void AdminMenu::showMenu()
|
||||
{
|
||||
@@ -203,8 +204,85 @@ void AdminMenu::assignJob()
|
||||
|
||||
}
|
||||
|
||||
static void selectInventoryItems(util::Map<std::string, const InventoryItem*>& currentInventoryItems, util::Vector<std::string>& selectedInventoryItems)
|
||||
{
|
||||
bool doRun = true, hasInventoryItems = false;
|
||||
util::Map<int, const InventoryItem*> currentInventoryMap;
|
||||
int currentIndex = 1;
|
||||
int choice;
|
||||
if (currentInventoryItems.getSize() == 0)
|
||||
{
|
||||
std::cout << "Inventory empty.";
|
||||
}
|
||||
while (doRun)
|
||||
{
|
||||
bool hasInventoryItems = false;
|
||||
int currentIndex = 1;
|
||||
currentInventoryMap.clear();
|
||||
std::cout << std::left
|
||||
<< std::setw(6) << "Index"
|
||||
<< std::setw(12) << "Item ID"
|
||||
<< std::setw(20) << "Part Name"
|
||||
<< std::setw(10) << "Price"
|
||||
<< std::setw(10) << "Quantity"
|
||||
<< std::endl;
|
||||
for (int iterator = 0; iterator < currentInventoryItems.getSize(); iterator++)
|
||||
{
|
||||
const InventoryItem* currentInventoryItem = currentInventoryItems.getValueAt(iterator);
|
||||
if (currentInventoryItem->getState() == util::State::INACTIVE)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
std::cout << std::left
|
||||
<< std::setw(6) << currentIndex
|
||||
<< std::setw(12) << currentInventoryItem->getId()
|
||||
<< std::setw(20) << currentInventoryItem->getPartName()
|
||||
<< std::setw(10) << currentInventoryItem->getPrice()
|
||||
<< std::setw(10) << currentInventoryItem->getQuantity()
|
||||
<< std::endl;
|
||||
|
||||
hasInventoryItems = true;
|
||||
currentInventoryMap.insert(currentIndex++, currentInventoryItem);
|
||||
}
|
||||
if (!hasInventoryItems)
|
||||
{
|
||||
std::cout << "No items present in the inventory." << std::endl;
|
||||
doRun = false;
|
||||
break;
|
||||
}
|
||||
std::cout << "Select the item (Index) or enter -1 to exit: ";
|
||||
util::read(choice);
|
||||
|
||||
if (choice == -1)
|
||||
{
|
||||
doRun = false;
|
||||
}
|
||||
else if (currentInventoryMap.find(choice) != -1)
|
||||
{
|
||||
selectedInventoryItems.push_back(currentInventoryMap.getValueAt(choice)->getId());
|
||||
std::cout << "Item added successfully." << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Enter a valid integer." << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AdminMenu::createService()
|
||||
{
|
||||
util::clear();
|
||||
std::string serviceName;
|
||||
double labourCost;
|
||||
std::cout << "Enter the service name: ";
|
||||
util::read(serviceName);
|
||||
util::Map<std::string, const InventoryItem*> currentInventoryItems = m_controller.getInventoryItems();
|
||||
util::Vector<std::string> selectedInventoryItems;
|
||||
selectInventoryItems(currentInventoryItems,selectedInventoryItems);
|
||||
std::cout << "Enter the labour cost: ";
|
||||
util::read(labourCost);
|
||||
m_controller.createService(serviceName, selectedInventoryItems, labourCost);
|
||||
std::cout << "Service created sucessfully.\n";
|
||||
}
|
||||
|
||||
void AdminMenu::removeService()
|
||||
|
||||
Reference in New Issue
Block a user