diff --git a/documentation/apiObjects/contracts.md b/documentation/apiObjects/contracts.md new file mode 100644 index 0000000..d8aa347 --- /dev/null +++ b/documentation/apiObjects/contracts.md @@ -0,0 +1,63 @@ +#Object - contract + +Represents an agreement between user and patron for a specific event + +| Fields | Type | Description +| ------------- | ------- | ------------| +| title | String | Title of the contract | +| description | String | Description of the contract | +| customer | customer | Primary customer to associated with contract | +| event | event | Event object describing the contracts event (see below)| +| rentalItems | [rentalItem] | collection of rentalItem Objects needed for the contract event| +| menuItems | [menuItem] | collection of menuItems served at the event | +| commLog | [commItem] | collection of communications about the event | +| status | enum | A contract may be in one of serveral statues (init, bid, contract, completed) | +| notes | String | Other related information about the contract | + +#Object - Event + +| Fields | Type | Description +| ------------- | ------- | ------------| +| Date | Date | Date of the event | +| startTime | Date | Event start time | +| endTime | Date | Event end time | +| numOfPeople | number | number of people attending the event | +| venue | venue | location of the event | + +#Object - commItem +A single communication interaction with a customer (e.g. emails, calls, in person meetings) + +| Fields | Type | Description +| ------------- | ------- | ------------| +| Date | Date | Date of the communication | +| commType | Enum | what mode of communication was used? (email, call, in person) | +| rep | String | Which employee represented the restaurant during the communication | +| description | String | Summary of the communication with the customer | + + + +##Other Notes + +**contract** +- I lost the document we collaborated on last thursday, this is the best I could do from memory. +- Do we need a deposit field on contracts object +- How should "Sequence of events be implemented"? Do we need a sequence object to do this? +- Should we have custom fields for customizable contracts to fit each restaurants needs? How would we implement this? +- We will evenutally implement "employees" or "staff" field to assign staff to a contract + +**Events** +- Events are broken out as a sperate object, is this effective? Are the fields assigned to the appropriate objects? + +**commItem** +- Old town dining has commType implemented as a enum drop down list. Is this how we should implement it for Banquet Ninja? + +##Pending changes + +**contracts** + - Initial review and implementation + +**events** + - Initial review and implementation + +**commItem** + - Intial review and implementation diff --git a/documentation/apiObjects/customer.md b/documentation/apiObjects/customer.md new file mode 100644 index 0000000..4441bcb --- /dev/null +++ b/documentation/apiObjects/customer.md @@ -0,0 +1,50 @@ +#Object - Customer +Restaurant patron + +| Fields | Type | Description +| ------------- | ------- | ------------| +| firstName | String | First name of customer | +| lastName | Number | Last name of customer | +| address | [address] | collection of address associated with a customer | +| emails | [email] | collection of emails associated with a customer | +| contactNumbers| [contactNumber]| collection of phone numbers associated with a customer | +| contracts | [contractID] | ID's of contract objects associated with a customer | + +#Object - address +Address + +| Fields | Type | Description +| ------------- | ------- | ------------| +| addressType | String | Type of address | +| primary | Boolean | Is this the primary address | +| address1 | String | address line 1 | +| address2 | String | address line 2 | +| city | String | City | +| State | String | State | +| Zip | String | Zip | + +#Object - email +Email address + +| Fields | Type | Description +| ------------- | ------- | ------------| +| emailType | Enum | type of email | +| primary | Boolean | Is this the primary email | +| email | String | email address | + +#Object - contactNumber +Email address + +| Fields | Type | Description +| ------------- | ------- | ------------| +| contactType | Enum | type of phone number | +| primary | Boolean | Is this the primary contact number | +| number | String | phone number | + +##Other Notes + - none + +##Pending changes + + - Initial review + diff --git a/documentation/apiObjects/menu.md b/documentation/apiObjects/menu.md new file mode 100644 index 0000000..eaedfcc --- /dev/null +++ b/documentation/apiObjects/menu.md @@ -0,0 +1,35 @@ +# Object - menu + +Colleciton of menuItem objects representing a menu. + + +| Fields | Type | Description +| ------------- | ------- | ------------| +| name | String | Name of the menu (for internal restaurant use/identification | +| title | String | Title of menu for restaurant guests | +| description | String | Description of menus purpose | +| subtitle | String | Subtitle of menu for restaurnt guests | +| sections | [menuSection] | Sections of the menu | +| footer | String | Footer of the menu | + + + +#Object - menuSection + +One section of a menu + +| Fields | Type | Description +| ------------- | ------- | ------------| +| title | String | Title of the section | +| subtitle | String | Subtitle of the section | +| items | [menuItem] | Collection of menuItems in the section | +| footer | String | Footer for the section | + + +##Other Notes + +- + +###Pending changes + +- none diff --git a/documentation/apiObjects/menuGroup.md b/documentation/apiObjects/menuGroup.md new file mode 100644 index 0000000..ff21a60 --- /dev/null +++ b/documentation/apiObjects/menuGroup.md @@ -0,0 +1,20 @@ + +#Object - menuGroup + +Collection of one or more menu Objects + +| Fields | Type | Description +| ------------- | ------- | ------------| +| title | String | title of the menu group | +| description | String | description of the menu group | +| subtitle | String | subtitle of the menu group | +| menus | [menu] | Collection of menu objects | + + +##Other Notes + +- Do we need the "State" Field that is currently implemented in the schema? I'm unclear on this fields purpose - Michael + +###Pending changes + +- abstracting dateCreated to the meta Data Object diff --git a/documentation/apiObjects/menuItem.md b/documentation/apiObjects/menuItem.md new file mode 100644 index 0000000..582f0f9 --- /dev/null +++ b/documentation/apiObjects/menuItem.md @@ -0,0 +1,19 @@ +# menuItem + +fully implemented 10/3/15 + +Represents any item (usually food or beverage) for sale by a restaurant. + + +| Fields | Type | Description +| ------------- | ------- | ------------| +| name | String | Name of the item | +| Description | String | Description of the item | +| Category | String | Type of food/beverage | + + +##Other Notes + +- Michael - Unclear on what category would, need examples +- Do we want to implement "varations" field? + diff --git a/documentation/apiObjects/metaData.md b/documentation/apiObjects/metaData.md new file mode 100644 index 0000000..0075d7e --- /dev/null +++ b/documentation/apiObjects/metaData.md @@ -0,0 +1,16 @@ +# MetaData + +Data fileds inherited by each API object. + + +| Fields | Type | Description +| ------------- | ------- | ------------| +| createDate | Date | Date of the objects creation | +| lastMod | Date | Last Date the object was modified | +| company | String | Company the object is associated with | + + +##Other Notes + +- Missing one field, current build not available + diff --git a/documentation/apiObjects/rentalItems.md b/documentation/apiObjects/rentalItems.md new file mode 100644 index 0000000..ad97c77 --- /dev/null +++ b/documentation/apiObjects/rentalItems.md @@ -0,0 +1,31 @@ +#Object - rentalItem +An item that may be rented by a patron. + +Fully Implemented - 9/18/15 + +| Fields | Type | Description +| ------------- | ------- | ------------| +| Name | String | Name of the item | +| Price | Number | Price to rent the item | +| inHouse | Boolean | Is the item stored in house (true), or is it kept with a third party (false) | +| contact | Contact | Contact object to be used if the rentalItem is kept with a third party | + +#Object - Contact +conctact information of third party that keeps a rental item + +| Fields | Type | Description +| ------------- | ------- | ------------| +| Name | String | Name of the contact | +| phone | Number | Phone number of contact | +| email | String | email of contact | + + + +##Other Notes + + - Should there be a third party rental price in the case that the third party rents the item to the restaurant? + - Third party contacts are abstracted, is this a good idead? + +##Pending changes + + diff --git a/documentation/apiObjects/venue.md b/documentation/apiObjects/venue.md new file mode 100644 index 0000000..0f16820 --- /dev/null +++ b/documentation/apiObjects/venue.md @@ -0,0 +1,18 @@ +#Object - venue +A location where events can be help + +Fully implemented 9/21/2015 + +| Fields | Type | Description +| ------------- | ------- | ------------| +| Name | String | Name of the venue | +| Description | String | Description of the venue | +| capacity | Number | Maximum amount of people the venue can support | +| price | Number | Price to rent the venue | +| notes | String | Additional information about the venue | + +##Other Notes + + - Should price field be attached to this object? or maybe the contract object? + +##Pending changes diff --git a/documentation/contracts/contract.md b/documentation/contracts/contract.md deleted file mode 100644 index ef2b060..0000000 --- a/documentation/contracts/contract.md +++ /dev/null @@ -1,15 +0,0 @@ -# Contract - -## Fields - - -| Fields | Type | Description -| ------------- | -------------- | ------------- | -| Customer | type: Number, ref: 'Customer' | description | -| Event | {date: Date, startTime: Time, endTime: Time, nature: String, venue: String, guestCount: String} | description | -| Notes | String | description | -| MenuItems | [{itemId: ObjId, name: String, description: String, notes: String, quan: Number, price: Number }] | description | -| CommLog | [{date: Date, time: Time, employee: String, notes: String}] | description | -| RentalItems | [{itemId: ObjId, name: String, description: String, quan: Number, price: Number }] | description | -| SequenceOfEvents | [{start: Time, end: Time, name: String, description: String}] | description | - diff --git a/server.js b/server.js index 3be67d4..9c573b9 100644 --- a/server.js +++ b/server.js @@ -22,15 +22,15 @@ require('./server/config/errors')(app); app.set('port', config.port); //app.listen(app.get('port')); var server = require('http').Server(app); -var io = require('socket.io')(server); +//var io = require('socket.io')(server); server.listen(app.get('port')); -io.on('connection', function(socket){ - socket.emit('news', {hello: 'world'}); - socket.on('my other event', function(data){ - console.log(data); - }); -}); +// io.on('connection', function(socket){ +// socket.emit('news', {hello: 'world'}); +// socket.on('my other event', function(data){ +// console.log(data); +// }); +//}); console.log('Listening on port ' + config.port + "..."); diff --git a/server/config/mongoose.js b/server/config/mongoose.js index 1cc2e57..984cd57 100644 --- a/server/config/mongoose.js +++ b/server/config/mongoose.js @@ -10,7 +10,9 @@ var mongoose = require('mongoose'), menuGroupModel = require('../models/MenuGroup'), menuItemModel = require('../models/MenuItem'), menuModel = require('../models/Menu'), - lookupsModel = require('../models/Lookups'); + lookupsModel = require('../models/Lookups'), + rentalItemModel = require('../models/RentalItem'), + venuesModel = require('../models/venues.js'); module.exports = function (config) { @@ -54,6 +56,8 @@ module.exports = function (config) { .then(customerModel.createDefaultCustomers(seedCompanyId)) .then(navigationModel.createDefaultNavigation()) .then(lookupsModel.createDefaultLookups(seedCompanyId)) + .then(rentalItemModel.createDefaultRentalItems(seedCompanyId)) + .then(venuesModel.createDefaultVenues(seedCompanyId)) ); diff --git a/server/config/routes.js b/server/config/routes.js index 8765aec..50b05e4 100644 --- a/server/config/routes.js +++ b/server/config/routes.js @@ -9,8 +9,9 @@ var auth = require('./auth'), menuRoutes = require('../routes/api_menus.js'), menuItemRoutes = require('../routes/api_menuItems.js'), menuGroupRoutes = require('../routes/api_menuGroups.js'), - lookupsRoutes = require('../routes/api_lookups.js'); - + lookupsRoutes = require('../routes/api_lookups.js'), + rentalItemRoutes = require('../routes/api_rentalItems.js'), + venueRoutes = require('../routes/api_venues.js'); module.exports = function (app) { @@ -41,7 +42,9 @@ module.exports = function (app) { app.use('/api/menuItems', menuItemRoutes); app.use('/api/menuGroups', menuGroupRoutes); app.use('/api/lookups', lookupsRoutes); - + app.use('/api/rentalItems', rentalItemRoutes); + app.use('/api/venues', venueRoutes); + // Partials app.get('/partials/*', function (req, res) { res.render('../../public/app/' + req.params[0]); diff --git a/server/controllers/rentalItems.js b/server/controllers/rentalItems.js new file mode 100644 index 0000000..3ad479e --- /dev/null +++ b/server/controllers/rentalItems.js @@ -0,0 +1,55 @@ +var RentalItem = require('mongoose').model('RentalItem'); + +exports.getRentalItems = function (req, res) { + RentalItem.find({ "meta.company": req.user.company}).exec(function (err, collection) { + if(err){ + res.status(400); + } + res.send(collection); + }); + + +}; + +exports.getRentalItemById = function (req, res) { + + RentalItem.findOne({ _id: req.params.id, "meta.company": req.user.company }).exec(function (err, rentalitem) { + res.send(rentalitem); + }); + +}; + +exports.createRentalItem = function (req, res, next) { + var rentalItemData = req.body; + rentalItemData.meta.company = req.user.company; + RentalItem.create(rentalItemData, function (err, rentalItem) { + if (err) { + res.status(400); + return res.send({ reason: err.toString() }); + } + res.send(rentalItem.toObject()); + }); +}; + +exports.updateRentalItem = function (req, res) { + delete req.body._id; + + RentalItem.findByIdAndUpdate({ _id: req.params.id }, req.body, function (err, rentalItem) { + if (err) { + console.log(err); + res.status(400); + return res.send({ reason: err.toString() }); + } + res.send(rentalItem.toObject()); + }); +}; + +exports.deleteRentalItem = function (req, res) { + RentalItem.remove({ _id: req.params.id }, function (err) { + if (err) { + res.status(400); + return res.send({ reason: err.toString() }); + } + res.send(204); + }); +}; \ No newline at end of file diff --git a/server/controllers/venues.js b/server/controllers/venues.js new file mode 100644 index 0000000..448f43a --- /dev/null +++ b/server/controllers/venues.js @@ -0,0 +1,58 @@ +var venues = require('mongoose').model('venues'); + +exports.getVenues = function (req, res) { + venues.find({ "meta.company": req.user.company}).exec(function (err, collection) { + if(err){ + res.status(400); + } + res.send(collection); + }); + + +}; + +exports.getVenueById = function (req, res) { + + venues.findOne({ _id: req.params.id, "meta.company": req.user.company }).exec(function (err, venue) { + if(err){ + res.status(400); + } + res.send(venue); + }); + +}; + +exports.createVenue = function (req, res, next) { + var venueData = req.body; + venueData.meta.company = req.user.company; + venues.create(venueData, function (err, venue) { + if (err) { + res.status(400); + return res.send({ reason: err.toString() }); + } + res.send(venue.toObject()); + }); +}; + +exports.updateVenue = function (req, res) { + delete req.body._id; + + venues.findByIdAndUpdate({ _id: req.params.id }, req.body, function (err, venue) { + if (err) { + console.log(err); + res.status(400); + return res.send({ reason: err.toString() }); + } + res.send(venue.toObject()); + }); +}; + +exports.deleteVenue = function (req, res) { + venues.remove({ _id: req.params.id }, function (err) { + if (err) { + res.status(400); + return res.send({ reason: err.toString() }); + } + res.send(204); + }); +}; \ No newline at end of file diff --git a/server/models/RentalItem.js b/server/models/RentalItem.js new file mode 100644 index 0000000..6846aa4 --- /dev/null +++ b/server/models/RentalItem.js @@ -0,0 +1,42 @@ +var mongoose = require('mongoose'); +var schema = require('./rentalItem_schema'); +var Q = require('q'); + +var RentalItem = mongoose.model('RentalItem', schema.rentalItemSchema); + +function createDefaultRentalItems(companyId) { + var dfd = Q.defer(); + + var items = []; + RentalItem.find({}).exec(function (err, collection) { + + if (collection.length === 0) { + var rentalItem1 = {meta: {company: companyId}, name: "Projector", price: 100, inHouse: true}; + var rentalItem2 = {meta: {company: companyId}, name: "Kegorator", price: 150, inHouse: true, contact: {firstName: "Arry", lastName: "Smith", phone: 7502434113, email: "ajSmith@Gmail.com"}}; + + RentalItem.create(rentalItem1, rentalItem2, function (err, item1, item2) { + + if (err) { + dfd.reject(new Error(err)); + } + items.push(item1); + items.push(item2); + //items.push(item1._id); + //.push(item2._id); + console.log('2 succesfully created rentalitem documents.....'); + //console.log(JSON.stringify(items)); + dfd.resolve(items); + + }); + + + + } + + }); + + return dfd.promise; + +} + +exports.createDefaultRentalItems = createDefaultRentalItems; \ No newline at end of file diff --git a/server/models/rentalItem_schema.js b/server/models/rentalItem_schema.js new file mode 100644 index 0000000..7b30be9 --- /dev/null +++ b/server/models/rentalItem_schema.js @@ -0,0 +1,22 @@ +var mongoose = require('mongoose'); +var sharedSchema = require('./sharedSchemas'); + +var contact = { + firstName: String, + lastName: String, + phone: Number, + email: String +}; + + +exports.rentalItemSchema = mongoose.Schema({ + meta: sharedSchema.metaSchema, + name: String, + price: Number, + inHouse: Boolean, + contact: contact + +}); + + + diff --git a/server/models/sharedSchemas.js b/server/models/sharedSchemas.js index 077dc49..5e1420b 100644 --- a/server/models/sharedSchemas.js +++ b/server/models/sharedSchemas.js @@ -3,5 +3,6 @@ var mongoose = require('mongoose'); exports.metaSchema = { dateCreated: { type: Date, default: Date.now }, dateLastMod: {type: Date}, - company: {type:mongoose.Schema.Types.ObjectId, ref:'Company'} + company: String + //{type:mongoose.Schema.Types.ObjectId, ref:'Company'} }; \ No newline at end of file diff --git a/server/models/venues.js b/server/models/venues.js new file mode 100644 index 0000000..8928c25 --- /dev/null +++ b/server/models/venues.js @@ -0,0 +1,42 @@ +var mongoose = require('mongoose'); +var schema = require('./venues_schema'); +var Q = require('q'); + +var venues = mongoose.model('venues', schema.venuesSchema); + +function createDefaultVenues(companyId) { + var dfd = Q.defer(); + + var items = []; + venues.find({}).exec(function (err, collection) { + + if (collection.length === 0) { + var venueItem1 = {meta: {company: companyId}, name: "Rotunda", price: 5000, description: "Main Round Dining Room", capacity: 40, notes: "Do not book on weekend nights"}; + var venueItem2 = {meta: {company: companyId}, name: "South Dining Room", price: 3000, description: "Small side dining room", capacity: 20, notes: "None"}; + + venues.create(venueItem1, venueItem2, function (err, item1, item2) { + + if (err) { + dfd.reject(new Error(err)); + } + items.push(item1); + items.push(item2); + //items.push(item1._id); + //.push(item2._id); + console.log('2 succesfully created venues .....'); + //console.log(JSON.stringify(items)); + dfd.resolve(items); + + }); + + + + } + + }); + + return dfd.promise; + +} + +exports.createDefaultVenues = createDefaultVenues; \ No newline at end of file diff --git a/server/models/venues_schema.js b/server/models/venues_schema.js new file mode 100644 index 0000000..28a9e0e --- /dev/null +++ b/server/models/venues_schema.js @@ -0,0 +1,15 @@ +var mongoose = require('mongoose'); +var sharedSchema = require('./sharedSchemas'); + + +exports.venuesSchema = mongoose.Schema({ + meta: sharedSchema.metaSchema, + name: String, + description: String, + capacity: Number, + price: Number, + notes: String +}); + + + diff --git a/server/routes/api_rentalItems.js b/server/routes/api_rentalItems.js new file mode 100644 index 0000000..40c26ef --- /dev/null +++ b/server/routes/api_rentalItems.js @@ -0,0 +1,12 @@ +var express = require('express'); +var controller = require('../controllers/rentalItems'); + +var router = express.Router(); +router.get('/', controller.getRentalItems); +router.get('/:id', controller.getRentalItemById); +router.delete('/:id', controller.deleteRentalItem); +router.put('/:id', controller.updateRentalItem); +router.post('/', controller.createRentalItem); + + +module.exports = router; \ No newline at end of file diff --git a/server/routes/api_venues.js b/server/routes/api_venues.js new file mode 100644 index 0000000..daad90e --- /dev/null +++ b/server/routes/api_venues.js @@ -0,0 +1,12 @@ +var express = require('express'); +var controller = require('../controllers/venues.js'); + +var router = express.Router(); +router.get('/', controller.getVenues); +router.get('/:id', controller.getVenueById); +router.delete('/:id', controller.deleteVenue); +router.put('/:id', controller.updateVenue); +router.post('/', controller.createVenue); + + +module.exports = router; \ No newline at end of file