diff --git a/brandAndVendor.sql b/brandAndVendor.sql index 9c33828..c7caad9 100644 --- a/brandAndVendor.sql +++ b/brandAndVendor.sql @@ -9,35 +9,88 @@ INSERT INTO vendor(id, name, strAddress, city, state, zipcode) VALUES(null, 'Bro INSERT INTO vendor(id, name, strAddress, city, state, zipcode) VALUES(null, 'Cain Inc','4712 Trapoole Way','Livonia','MI','92650'); INSERT INTO vendor(id, name, strAddress, city, state, zipcode) VALUES(null, 'CollectorsRUs','1902 Renaissance Parkway','Atlanta ','GA','30308'); +INSERT INTO orders(id,user_id,vendor_id,type,closedInvoice) VALUES(null,1,1,'reorder',false); +INSERT INTO orders(id,user_id,vendor_id,type,closedInvoice) VALUES(null,1,2,'reorder',false); +INSERT INTO orders(id,user_id,vendor_id,type,closedInvoice) VALUES(null,1,3,'reorder',false); +INSERT INTO orders(id,user_id,vendor_id,type,closedInvoice) VALUES(null,1,4,'reorder',false); +INSERT INTO orders(id,user_id,vendor_id,type,closedInvoice) VALUES(null,1,5,'reorder',false); +INSERT INTO orders(id,user_id,vendor_id,type,closedInvoice) VALUES(null,1,6,'reorder',false); +INSERT INTO orders(id,user_id,vendor_id,type,closedInvoice) VALUES(null,1,7,'reorder',false); +INSERT INTO orders(id,user_id,vendor_id,type,closedInvoice) VALUES(null,1,8,'reorder',false); +INSERT INTO orders(id,user_id,vendor_id,type,closedInvoice) VALUES(null,1,9,'reorder',false); +INSERT INTO orders(id,user_id,vendor_id,type,closedInvoice) VALUES(null,1,10,'reorder',false); -INSERT INTO tag(id, name) VALUES(null,'Marvel') -INSERT INTO tag(id, name) VALUES(null,'Batman') -INSERT INTO tag(id, name) VALUES(null,'Hulk') -INSERT INTO tag(id, name) VALUES(null,'Avengers') -INSERT INTO tag(id, name) VALUES(null,'Superman') -INSERT INTO tag(id, name) VALUES(null,'Game of Thrones') -INSERT INTO tag(id, name) VALUES(null,'Aquaman') -INSERT INTO tag(id, name) VALUES(null,'Naruto') -INSERT INTO tag(id, name) VALUES(null,'Bleach') -INSERT INTO tag(id, name) VALUES(null,'Attack on Titian') -INSERT INTO tag(id, name) VALUES(null,'DC ') -INSERT INTO tag(id, name) VALUES(null,'Flash') -INSERT INTO tag(id, name) VALUES(null,'Justic League') -INSERT INTO tag(id, name) VALUES(null,'Deadpool') -INSERT INTO tag(id, name) VALUES(null,'Spiderman') -INSERT INTO tag(id, name) VALUES(null,'Captain America') -INSERT INTO tag(id, name) VALUES(null,'Magic The Gathering') -INSERT INTO tag(id, name) VALUES(null,'Dugeon & Dragons') -INSERT INTO tag(id, name) VALUES(null,'Yugioh') -INSERT INTO tag(id, name) VALUES(null,'Pokemon') -INSERT INTO tag(id, name) VALUES(null,'Wolverine') -INSERT INTO tag(id, name) VALUES(null,'X-Men') -INSERT INTO tag(id, name) VALUES(null,'Antman') -INSERT INTO tag(id, name) VALUES(null,'DareDevil') -INSERT INTO tag(id, name) VALUES(null,'Thor') -INSERT INTO tag(id, name) VALUES(null,'Iron Man') -INSERT INTO tag(id, name) VALUES(null,'Nightwing') -INSERT INTO tag(id, name) VALUES(null,'Hawkman') -INSERT INTO tag(id, name) VALUES(null,'Wonder Woman') -INSERT INTO tag(id, name) VALUES(null,'Supergirl') -INSERT INTO tag(id, name) VALUES(null,'The Walking Dead') + + +INSERT INTO tag(id, name) VALUES(null,'Marvel'); +INSERT INTO tag(id, name) VALUES(null,'Batman'); +INSERT INTO tag(id, name) VALUES(null,'Hulk'); +INSERT INTO tag(id, name) VALUES(null,'Avengers'); +INSERT INTO tag(id, name) VALUES(null,'Superman'); +INSERT INTO tag(id, name) VALUES(null,'Game of Thrones'); +INSERT INTO tag(id, name) VALUES(null,'Aquaman'); +INSERT INTO tag(id, name) VALUES(null,'Naruto'); +INSERT INTO tag(id, name) VALUES(null,'Bleach'); +INSERT INTO tag(id, name) VALUES(null,'Attack on Titian'); +INSERT INTO tag(id, name) VALUES(null,'DC '); +INSERT INTO tag(id, name) VALUES(null,'Flash'); +INSERT INTO tag(id, name) VALUES(null,'Justic League'); +INSERT INTO tag(id, name) VALUES(null,'Deadpool'); +INSERT INTO tag(id, name) VALUES(null,'Spiderman'); +INSERT INTO tag(id, name) VALUES(null,'Captain America'); +INSERT INTO tag(id, name) VALUES(null,'Magic The Gathering'); +INSERT INTO tag(id, name) VALUES(null,'Dugeon & Dragons'); +INSERT INTO tag(id, name) VALUES(null,'Yugioh'); +INSERT INTO tag(id, name) VALUES(null,'Pokemon'); +INSERT INTO tag(id, name) VALUES(null,'Wolverine'); +INSERT INTO tag(id, name) VALUES(null,'X-Men'); +INSERT INTO tag(id, name) VALUES(null,'Antman'); +INSERT INTO tag(id, name) VALUES(null,'DareDevil'); +INSERT INTO tag(id, name) VALUES(null,'Thor'); +INSERT INTO tag(id, name) VALUES(null,'Iron Man'); +INSERT INTO tag(id, name) VALUES(null,'Nightwing'); +INSERT INTO tag(id, name) VALUES(null,'Hawkman'); +INSERT INTO tag(id, name) VALUES(null,'Wonder Woman'); +INSERT INTO tag(id, name) VALUES(null,'Supergirl'); +INSERT INTO tag(id, name) VALUES(null,'The Walking Dead'); + +INSERT INTO brand(id, name) VALUES(null, 'ACE Comics'); +INSERT INTO brand(id, name) VALUES(null, 'All Star DC Comics'); +INSERT INTO brand(id, name) VALUES(null, 'Atlas Comics'); +INSERT INTO brand(id, name) VALUES(null, 'Caliber Comics'); +INSERT INTO brand(id, name) VALUES(null, 'Calvary Comics'); +INSERT INTO brand(id, name) VALUES(null, 'DC Comics'); +INSERT INTO brand(id, name) VALUES(null, 'D. C. Thomson & Co. Ltd'); +INSERT INTO brand(id, name) VALUES(null, 'Deep Sea Comics'); +INSERT INTO brand(id, name) VALUES(null, 'Disney Comics'); +INSERT INTO brand(id, name) VALUES(null, 'La Pastèque'); +INSERT INTO brand(id, name) VALUES(null, 'Marvel Comics'); +INSERT INTO brand(id, name) VALUES(null, 'Marvel Adventures'); +INSERT INTO brand(id, name) VALUES(null, 'Marvel Age'); +INSERT INTO brand(id, name) VALUES(null, 'Matrix Graphic Series'); +INSERT INTO brand(id, name) VALUES(null, 'Maverick'); +INSERT INTO brand(id, name) VALUES(null, 'Max Comics (MAX)'); +INSERT INTO brand(id, name) VALUES(null, 'Media Factory'); +INSERT INTO brand(id, name) VALUES(null, 'Michael Hunt Publishing'); +INSERT INTO brand(id, name) VALUES(null, 'Mighty Comics'); +INSERT INTO brand(id, name) VALUES(null, 'Milestone Media'); +INSERT INTO brand(id, name) VALUES(null, 'Mille-Îles'); +INSERT INTO brand(id, name) VALUES(null, 'Millennium Publications'); +INSERT INTO brand(id, name) VALUES(null, 'Milk Shadow Books'); +INSERT INTO brand(id, name) VALUES(null, 'MiniKomix'); +INSERT INTO brand(id, name) VALUES(null, 'Mirage Studios'); +INSERT INTO brand(id, name) VALUES(null, 'Mirror Comics'); +INSERT INTO brand(id, name) VALUES(null, 'M. F. Enterprises'); +INSERT INTO brand(id, name) VALUES(null, 'MLJ Magazines'); +INSERT INTO brand(id, name) VALUES(null, 'Mojo Press'); +INSERT INTO brand(id, name) VALUES(null, 'Moonstone Books'); +INSERT INTO brand(id, name) VALUES(null, 'MOSAIK Steinchen für Steinchen Verlag'); +INSERT INTO brand(id, name) VALUES(null, 'M Press'); +INSERT INTO brand(id, name) VALUES(null, 'MU Press'); +INSERT INTO brand(id, name) VALUES(null, 'MyInkComics.com'); +INSERT INTO brand(id, name) VALUES(null, 'NBM Publishing'); +INSERT INTO brand(id, name) VALUES(null, 'Neko Press'); +INSERT INTO brand(id, name) VALUES(null, 'Standard Comics'); +INSERT INTO brand(id, name) VALUES(null, 'New Century Comics'); +INSERT INTO brand(id, name) VALUES(null, 'New Comics Group'); +INSERT INTO brand(id, name) VALUES(null, 'Square Enix'); diff --git a/client/app/components/add-inventory.js b/client/app/components/add-inventory.js index 25c970c..78582b2 100644 --- a/client/app/components/add-inventory.js +++ b/client/app/components/add-inventory.js @@ -1,18 +1,18 @@ import Ember from 'ember'; export default Ember.Component.extend({ + session: Ember.inject.service('session'), itemTypes:[{name:'comic'},{name:'figure'},{name:'game'},{name:'trade'},{name:'apparel'}], type:null, genderTypes:[{name:'male'},{name:'female'},{name:'unisex'}], - genderChoice:null, figureChoices:[{name:'game'},{name:'figure'},{name:'collectable'},{name:'action'}], - figureChoice:null, + //figureChoice:null, gameChoices:[{name:'card'},{name:'dice'},{name:'board'},{name:'role playing'}], - gameChoice:null, + //gameChoice:null, materialChoices:[{name:'plush'},{name:'vinyl'},{name:'plastic'},{name:'die-cast'},{name:'metal'}], - materialChoice:null, + //materialChoice:null, bindingChoices:[{name:'hardback'},{name:'paperback'}], - bindingChoice:null, + total:0, quanity:0, issue_num:null, @@ -36,7 +36,6 @@ export default Ember.Component.extend({ return true; } } - }), newBrand:Ember.computed('brand',function(){ if(this.get('brand')){ @@ -55,28 +54,7 @@ export default Ember.Component.extend({ writersOptions:[], illustratorOptions:[], tagOptions:[], - bindingOberserver:Ember.observer('bindingType','bindingChoice',function(){ - if(this.bindingChoice!=null){ - this.set('bindingType',this.bindingChoice.name); - } - }), - materialObserver:Ember.observer('materialType','materialChoice',function(){ - if(this.materialChoice!=null){ - this.set('materialType',this.materialChoice.name); - } - }), - gameObserver:Ember.observer('gameType','gameChoice',function(){ - if(this.gameChoice!=null){ - this.set('gameType',this.gameChoice.name); - } - }), - figureObserver:Ember.observer('figureType','figureChoice', function(){ - var item = this.get('item'); - if(this.figureChoice!=null){ - this.set('figureType',this.figureChoice.name); - } - }), sizeObserver:Ember.observer('size','sizeChoice',function(){ var item = this.get('item'); @@ -85,13 +63,6 @@ export default Ember.Component.extend({ } }), - genderObserver:Ember.observer('gender','genderChoice',function(){ - var item = this.get('item'); - - if(this.genderChoice!=null){ - this.set('gender',this.genderChoice.name); - } - }), typeObserver:Ember.observer('type',function(){ var item=this.get('item'); if(this.type.name==='comic' || this.type.name==='trade'){ @@ -160,11 +131,11 @@ export default Ember.Component.extend({ } }, setSize(value){ + console.log(value); this.set('detail_id',value); }, setWriters(event){ const writer = Ember.$(event.target).val(); - if(writer.get('firstObject') === "other"){ this.sendAction('newWriter'); } else @@ -199,6 +170,30 @@ export default Ember.Component.extend({ }, createNewItem(){ this.sendAction('createNewItem'); + }, + deleteItem(value){ + console.log(value); + this.sendAction('deleteItem',value); + }, + setFigure(value){ + console.log(value); + this.set('figureChoice',value); + }, + setMaterial(value){ + console.log(value); + this.set('materialChoice',value); + }, + setApparelType(value){ + this.set('apparelType',value); + }, + setGame(value){ + this.set('gameType',value); + }, + setBinding(value){ + this.set('bindingType',value); + }, + setGender(value){ + this.set('gender',value); } } }); diff --git a/client/app/components/invoice-finder.js b/client/app/components/invoice-finder.js new file mode 100644 index 0000000..b4f0619 --- /dev/null +++ b/client/app/components/invoice-finder.js @@ -0,0 +1,9 @@ +import Ember from 'ember'; + +export default Ember.Component.extend({ + actions:{ + setVendor(value){ + this.sendAction('findInvoice',value); + } + } +}); diff --git a/client/app/components/invoice-graph.js b/client/app/components/invoice-graph.js new file mode 100644 index 0000000..ec7f0bf --- /dev/null +++ b/client/app/components/invoice-graph.js @@ -0,0 +1,20 @@ +import Ember from 'ember'; + +export default Ember.Component.extend({ + actions:{ + addToInvoice(value){ + this.sendAction('addLineItem',value); + }, + removeLineItem(value){ + //console.log(value); + this.sendAction('removeLineItem',value); + }, + setQuanity(value){ + console.log(value); + this.sendAction('setQuanity',value); + }, + sendInvoice(value){ + this.sendAction('sendInvoice',value); + } + } +}); diff --git a/client/app/components/low-inventory-button.js b/client/app/components/low-inventory-button.js new file mode 100644 index 0000000..7c3171c --- /dev/null +++ b/client/app/components/low-inventory-button.js @@ -0,0 +1,7 @@ +import Ember from 'ember'; + +export default Ember.Component.extend({ + lowStockNum:Ember.computed('details',function(){ + return this.get('details').toArray().filterBy('lowStock',true).length; + }) +}); diff --git a/client/app/components/low-inventory-list.js b/client/app/components/low-inventory-list.js new file mode 100644 index 0000000..a330011 --- /dev/null +++ b/client/app/components/low-inventory-list.js @@ -0,0 +1,9 @@ +import Ember from 'ember'; + +export default Ember.Component.extend({ + actions:{ + addToInvoice(value){ + this.sendAction('findLowInvoice',value); + } + } +}); diff --git a/client/app/controllers/adminpage/invoices.js b/client/app/controllers/adminpage/invoices.js new file mode 100644 index 0000000..0e63a98 --- /dev/null +++ b/client/app/controllers/adminpage/invoices.js @@ -0,0 +1,89 @@ +import Ember from 'ember'; + +export default Ember.Controller.extend({ + session: Ember.inject.service('session'), + vendorItems:[], + invoice:null, + vendor:null, + actions:{ + findInvoice(value){ + console.log(value); + var _this= this; + this.set('vendor',value); + console.log(this.get('vendor')); + this.store.queryRecord('order',{vendor_id:value,closedInvoice:false}).then(function(invoice){ + _this.set('invoice',invoice); + }); + this.send('getDetails',value); + }, + getDetails(value){ + var details = this.get('model').details; + details = details.filterBy('item_id.vendor_id.id',value); + this.set('vendorItems',details); + }, + addLineItem(values){ + var vendor = this.store.peekRecord('vendor',this.get('vendor')); + console.log(vendor); + var detail = this.store.peekRecord('detail',values); + console.log(detail); + var user = this.store.peekRecord('user',this.get('session.session.authenticated.user.id')); + console.log(this.get('session.currentUser')); + ////var item = this.store.peekRecord('item',detail.item_id.id); + let lineItem = this.store.createRecord('line',{ + order_id:this.get('invoice'), + user_id:user, + detail_id:detail + }).save(); + console.log(lineItem); + }, + removeLineItem(value){ + this.store.findRecord('line', value).then(function(line) { + line.destroyRecord(); // => DELETE to /posts/2 + }); + }, + setQuanity(value){ + this.store.findRecord('line',value).then(function(line){ + line.save(); + }); + }, + sendInvoice(value){ + var vendor = this.store.peekRecord('vendor',this.get('vendor')); + console.log(vendor); + var user = this.store.peekRecord('user',this.get('session.session.authenticated.user.id')); + console.log(user); + this.store.findRecord('order',value).then(function(order){ + order.set('closedInvoice',true); + order.save(); + }); + this.store.createRecord('order',{ + type:'reorder', + vendor:vendor, + user_id:user + }).save(); + } + /*findLowInvoice(values){ + this.set('invoice',null); + console.log(values); + var _this=this; + var item = this.store.peekRecord('item',values); + console.log(item); + this.store.queryRecord('order',{vendor_id:item.vendor_id.id,closedInvoice:false}).then(function(invoice){ + _this.set('invoice',invoice); + _this.send('addLineItemLow',item); + _this.send('getDetails',_this.get('invoice.vendor_id.id')); + }); + }, + addLineItemLow(values){ + console.log(values); + var user = this.store.peekRecord('user',this.get('session.session.authenticated.user.id')) + console.log(this.get('session.currentUser')); + ////var item = this.store.peekRecord('item',detail.item_id.id); + let lineItem = this.store.createRecord('line',{ + order_id:this.get('invoice'), + user_id:user, + item_id:values + }).save(); + console.log(lineItem); + }*/ + } +}); diff --git a/client/app/controllers/general/add-inventory.js b/client/app/controllers/general/add-inventory.js index ad86338..9533318 100644 --- a/client/app/controllers/general/add-inventory.js +++ b/client/app/controllers/general/add-inventory.js @@ -52,7 +52,6 @@ export default Ember.Controller.extend({ }), actions:{ alertToNoItem(){ - console.log(this.id); var item = this.get('item'); if(item===null){ $('.no-item-found').removeClass('hidden'); @@ -64,8 +63,6 @@ export default Ember.Controller.extend({ this.set('id',null); $('.no-item-found').addClass('hidden'); }, - checkForDetail(){ - }, addItem(values){ var _this=this; var issue_num=values.issue_num; @@ -74,36 +71,37 @@ export default Ember.Controller.extend({ var total = values.total*1; var detail; var currentQuanity; - console.log(values.vendor); if(values.vendor!=null){ var vendor = this.store.peekRecord('vendor',values.vendor); this.get('item').set('vendor_id',vendor); } - console.log(values.brand); if(values.brand!=null){ var brand = this.store.peekRecord('brand',values.brand); this.get('item').set('brand',values.brand); } if(this.get('item').get('typeName')==="comic"||this.get('item').get('typeName')==="trade"){ + values.writers.forEach(function(item,index){ - _this.store.peekRecord('writer',item).then(function(writer){ + var writer = _this.store.peekRecord('writer',item);/*.then(function(writer){ _this.get('item').get('Writers').pushObject(writer); - }); + });*/ + _this.get('item').get('Writers').pushObject(writer); }); values.illustrators.forEach(function(item,index){ - _this.store.peekRecord('illustrator',item).then(function(illustrator){ + var illustrator = _this.store.peekRecord('illustrator',item); + //_this.store.peekRecord('illustrator',item).then(function(illustrator){ _this.get('item').get('Illustrators').pushObject(illustrator); - }); + //}); }); if(this.get('item').get('typeName')==="trade"){ values.comics.forEach(function(item,index){ - _this.store.peekRecord('detail',item).then(function(detail){ - _this.get('item').get('collects').pushObject(comicIssue); - }); + var detail = _this.store.peekRecord('detail',item); + //_this.store.peekRecord('detail',item).then(function(detail){ + _this.get('item').get('collects').pushObject(detail); + //}); }); } } - console.log(values.tags); values.tags.forEach(function(item,index){ _this.get('item').get('tags').pushObject(item); }); @@ -114,6 +112,7 @@ export default Ember.Controller.extend({ subTotal:total, user_id:this.get('session.currentUser'), }).save(); + //console.log(values.detail_id); if(values.newComic){ this.store.createRecord('detail',{ item_id:this.get('item'), @@ -122,23 +121,23 @@ export default Ember.Controller.extend({ quanity:quanity }).save(); } else if (values.detail_id) { - console.log("hello"); detail = this.store.peekRecord('detail',values.detail_id); currentQuanity = detail.get('quanity')*1; detail.set('quanity',currentQuanity+quanity); detail.save(); - console.log(detail); } else { detail = this.get('item').get('Details').get('firstObject'); currentQuanity = detail.get('quanity')*1; detail.set('quanity',currentQuanity+quanity); detail.save(); } - this.get('item').save().then(function(){ - _this.send('clearValue'); - },function(reason){ - console.log(reason); + this.store.findRecord('item',this.get('id')).then(function(item){ + item.save().then(function(){ + _this.set('tagOptions',[]); + _this.transitionToRoute({ queryParams: { id: 'null' }}); + }); }); + }, setType(value){ this.set('type',value); @@ -171,6 +170,31 @@ export default Ember.Controller.extend({ first_name:values.fname, last_name:values.lname }).save(); + }, + deleteItem(value){ + var _this=this; + this.store.createRecord('line',{ + removal:true, + add:false, + item_id:this.get('item'), + user_id:this.get('session.currentUser') + }); + this.store.query('detail',{item_id:value}).then(function(details){ + console.log(details); + details.toArray(); + details.forEach(function(item,index){ + var removeRecord = _this.store.peekRecord('detail',item.id); + removeRecord.destroyRecord(); + + }); + }); + this.store.findRecord('item',value).then(function(item){ + item.destroyRecord(); + //_this.set('item',null); + _this.set('tagOptions',[]); + _this.transitionToRoute({ queryParams: { id: 'null' }}); + }); + } } }); diff --git a/client/app/controllers/general/search.js b/client/app/controllers/general/search.js index 85ca919..ae0898a 100644 --- a/client/app/controllers/general/search.js +++ b/client/app/controllers/general/search.js @@ -34,7 +34,14 @@ export default Ember.Controller.extend({ } if(size){ if(size!= null){ - items = items.filterBy('size',size); + var filterPromise = Ember.RSVP.filter(items,item =>{ + return item.get('Details').then(detail => { + return detail.isAny('size', size); + }); + }); + return DS.PromiseArray.create({ + promise: filterPromise + }); } } if(apparelType){ diff --git a/client/app/models/detail.js b/client/app/models/detail.js index 9c10d84..e22e053 100644 --- a/client/app/models/detail.js +++ b/client/app/models/detail.js @@ -5,8 +5,27 @@ export default DS.Model.extend({ size:DS.attr(), quanity:DS.attr('number',{defaultValue:0}), issue_num:DS.attr(), + lineitems:DS.hasMany('line'), includedIn:DS.hasMany('item', {inverse: 'collects'}), fullName:Ember.computed('item_id',function(){ - console.log(this.get('item_id')); + //console.log(this.get('item_id')); + }), + lowStock:Ember.computed('quanity',function(){ + if(this.get('quanity')*1<=5){ + return true; + } + return false; + }), + numberSold:Ember.computed('lineitems',function(){ + var lineitems = this.get('lineitems'); + var totalSold = 0; + var order; + var _this=this; + lineitems = lineitems.filterBy('add',false); + lineitems.forEach(function(item,index){ + totalSold+=item.get('quanity'); + console.log(item.get('quanity')); + }); + return totalSold; }) }); diff --git a/client/app/models/item.js b/client/app/models/item.js index 5916995..fb89515 100644 --- a/client/app/models/item.js +++ b/client/app/models/item.js @@ -7,10 +7,10 @@ export default DS.Model.extend({ trade:DS.attr('boolean',{ defaultValue: false }), apparel:DS.attr('boolean',{ defaultValue: false }), price:DS.attr('dollars'), - Details:DS.hasMany('detail'), + Details:DS.hasMany('detail',), name:DS.attr(), sales_price:DS.attr(), - lineitems:DS.hasMany('line'), + //lineitems:DS.hasMany('line'), tags:DS.hasMany('tag'), vendor_id:DS.belongsTo('vendor'), brand:DS.belongsTo('brand'), @@ -53,17 +53,5 @@ export default DS.Model.extend({ return "figure"; } return null; - }), - numberSold:Ember.computed('lineitems',function(){ - var lineitems = this.get('lineitems'); - var totalSold = 0; - var order; - var _this=this; - lineitems = lineitems.filterBy('add',false); - lineitems.forEach(function(item,index){ - totalSold+=item.get('quanity'); - console.log(item.get('quanity')); - }); - return totalSold; }) }); diff --git a/client/app/models/line.js b/client/app/models/line.js index 6206f0e..2abc265 100644 --- a/client/app/models/line.js +++ b/client/app/models/line.js @@ -1,12 +1,13 @@ import DS from 'ember-data'; export default DS.Model.extend({ - item_id:DS.belongsTo('item'), - subTotal:DS.attr(), + detail_id:DS.belongsTo('detail'), quanity:DS.attr(), order_id:DS.belongsTo('order'), user_id:DS.belongsTo('user'), add:DS.attr('boolean'), sale:DS.attr('boolean'), createdAt:DS.attr('date'), + removal:DS.attr('boolean'), + subTotal:DS.attr() }); diff --git a/client/app/models/order.js b/client/app/models/order.js index 78a505c..e5e99a3 100644 --- a/client/app/models/order.js +++ b/client/app/models/order.js @@ -8,5 +8,8 @@ export default DS.Model.extend({ original_receipt:DS.belongsTo('order',{inverse:'return_receipt'}), return_receipt:DS.belongsTo('order',{inverse:'original_receipt'}), reason:DS.attr(), - user_id:DS.belongsTo('user') + user_id:DS.belongsTo('user'), + vendor_id:DS.belongsTo('vendor'), + createdAt:DS.attr(), + closedInvoice:DS.attr('boolean') }); diff --git a/client/app/models/vendor.js b/client/app/models/vendor.js index 76bd1aa..8364027 100644 --- a/client/app/models/vendor.js +++ b/client/app/models/vendor.js @@ -7,4 +7,5 @@ export default DS.Model.extend({ state:DS.attr(), zipcode:DS.attr(), Items:DS.hasMany('item'), + Orders:DS.hasMany('order') }); diff --git a/client/app/routes/adminpage/invoices.js b/client/app/routes/adminpage/invoices.js index 26d9f31..35879fb 100644 --- a/client/app/routes/adminpage/invoices.js +++ b/client/app/routes/adminpage/invoices.js @@ -1,4 +1,12 @@ import Ember from 'ember'; export default Ember.Route.extend({ + + model(){ + return Ember.RSVP.hash({ + vendors: this.store.findAll('vendor'), + details: this.store.findAll('detail'), + items: this.store.findAll('item') + }); + } }); diff --git a/client/app/routes/adminpage/sales-report.js b/client/app/routes/adminpage/sales-report.js index 17e81e9..b65c688 100644 --- a/client/app/routes/adminpage/sales-report.js +++ b/client/app/routes/adminpage/sales-report.js @@ -2,6 +2,6 @@ import Ember from 'ember'; export default Ember.Route.extend({ model(){ - return this.store.findAll('item'); + return this.store.findAll('detail'); } }); diff --git a/client/app/routes/general/add-inventory.js b/client/app/routes/general/add-inventory.js index a63ee48..9f7ada7 100644 --- a/client/app/routes/general/add-inventory.js +++ b/client/app/routes/general/add-inventory.js @@ -1,13 +1,15 @@ import Ember from 'ember'; export default Ember.Route.extend({ + session: Ember.inject.service('session'), queryParams: { id: { refreshModel: true } }, - beforeModel(){ + /*beforeModel(){ + console.log("hello"); this.set('item',null); - this.set('id', null); + //this.set('id', null); this.set('newItemAdded',false); this.set('type',null); this.set('total',null); @@ -15,47 +17,31 @@ export default Ember.Route.extend({ this.set('issue_num',null); this.set('type',null); this.set('size',null); - }, + },*/ model(params){ - return this.store.query('item',params); + console.log(params); + + return this.store.query('item',params).catch(function(){ + console.log("not found"); + }); + + }, resetController(controller, isExiting, transition) { if (isExiting) { - this.set('item',null); + //this.set('item',null); this.set('id', null); - this.set('newItemAdded',false); - this.set('type',null); - this.set('total',null); - this.set('quanity',null); - this.set('issue_num',null); - this.set('type',null); - this.set('size',null); + //this.set('newItemAdded',false); + //this.set('type',null); + //this.set('total',null); + //this.set('quanity',null); + //this.set('issue_num',null); + //this.set('type',null); + //this.set('size',null); } }, actions:{ - willTransition(transition) { - this.set('item',null); - this.set('id', null); - this.set('newItemAdded',false); - this.set('type',null); - this.set('total',null); - this.set('quanity',null); - this.set('issue_num',null); - this.set('type',null); - this.set('size',null); - return true; - }, - clearValue(){ - alert("hello"); - this.set('item',null); - this.set('id', null); - this.set('newItemAdded',false); - this.set('type',null); - this.set('total',null); - this.set('quanity',null); - this.set('issue_num',null); - this.set('type',null); - this.set('size',null); - } + + } }); diff --git a/client/app/templates/adminpage/employees.hbs b/client/app/templates/adminpage/employees.hbs index 1bef6cf..bb819b7 100644 --- a/client/app/templates/adminpage/employees.hbs +++ b/client/app/templates/adminpage/employees.hbs @@ -3,11 +3,11 @@ - + - - - + + + @@ -16,7 +16,6 @@ - @@ -36,4 +35,4 @@ {{new-employee-form createEmployee="createEmployee"}} -{{edit-employee-form commitEdit="commitEdit" first_name=editUser.first_name last_name=editUser.last_name}} +{{edit-employee-form commitEdit="commitEdit" admin=User.isAdmin first_name=editUser.first_name last_name=editUser.last_name}} diff --git a/client/app/templates/adminpage/invoices.hbs b/client/app/templates/adminpage/invoices.hbs index c24cd68..c513b87 100644 --- a/client/app/templates/adminpage/invoices.hbs +++ b/client/app/templates/adminpage/invoices.hbs @@ -1 +1,16 @@ -{{outlet}} +
+
+ {{invoice-finder findInvoice="findInvoice" vendors=model.vendors}} +
+
+ {{low-inventory-button details=model.details}} +
+
+
+
+ {{invoice-graph removeLineItem="removeLineItem" sendInvoice="sendInvoice" setQuanity="setQuanity" addLineItem="addLineItem" invoice=invoice vendorItems=vendorItems vendor=vendor}} +
+ + + +{{low-inventory-list findLowInvoice="findLowInvoice" details=model.details}} diff --git a/client/app/templates/adminpage/sales-report.hbs b/client/app/templates/adminpage/sales-report.hbs index 1328e4f..1c4f046 100644 --- a/client/app/templates/adminpage/sales-report.hbs +++ b/client/app/templates/adminpage/sales-report.hbs @@ -31,14 +31,21 @@ - {{#each model as |item|}} - {{#if item.comic}} + {{#each model as |detail|}} + {{#if detail.item_id.comic}} - - - - - + + + + + {{/if}} {{/each}} @@ -60,14 +67,21 @@ - {{#each model as |item|}} - {{#if item.trade}} + {{#each model as |detail|}} + {{#if detail.item_id.trade}} - - - - - + + + + + {{/if}} {{/each}} @@ -91,17 +105,25 @@ - {{#each model as |item|}} - {{#if item.game}} + {{#each model as |detail|}} + {{#if detail.item_id.game}} - - - - - + + + + + {{/if}} {{/each}} +
NameNAME UIDAdmin AccessLast ActionEditADMIN ACCESSEDITREMOVE
{{user.full_name}} {{user.id}} {{user.isAdmin}}
{{item.id}}{{item.name}}{{item.price}}{{item.sales_price}}{{item.numberSold}}{{detail.item_id.id}}{{detail.item_id.name}} + {{#if detail.item_id.comic}} + Issue #: {{detail.issue_num}} + {{/if}} + {{#if detail.item_id.apparel}} + Size: {{detail.size}} + {{/if}} + {{detail.item_id.price}}{{detail.item_id.sales_price}}{{detail.numberSold}}
{{item.id}}{{item.name}}{{item.price}}{{item.sales_price}}{{item.numberSold}}{{detail.item_id.id}}{{detail.item_id.name}} + {{#if detail.item_id.comic}} + Issue #: {{detail.issue_num}} + {{/if}} + {{#if detail.item_id.apparel}} + Size: {{detail.size}} + {{/if}} + {{detail.item_id.price}}{{detail.item_id.sales_price}}{{detail.numberSold}}
{{item.id}}{{item.name}}{{item.price}}{{item.sales_price}}{{item.numberSold}}{{detail.item_id.id}}{{detail.item_id.name}} + {{#if detail.item_id.comic}} + Issue #: {{detail.issue_num}} + {{/if}} + {{#if detail.item_id.apparel}} + Size: {{detail.size}} + {{/if}} + {{detail.item_id.price}}{{detail.item_id.sales_price}}{{detail.numberSold}}
@@ -120,17 +142,25 @@ - {{#each model as |item|}} - {{#if item.figure}} + {{#each model as |detail|}} + {{#if detail.item_id.figure}} - {{item.id}} - {{item.name}} - {{item.price}} - {{item.sales_price}} - {{item.numberSold}} + {{detail.item_id.id}} + {{detail.item_id.name}} + {{#if detail.item_id.comic}} + Issue #: {{detail.issue_num}} + {{/if}} + {{#if detail.item_id.apparel}} + Size: {{detail.size}} + {{/if}} + + {{detail.item_id.price}} + {{detail.item_id.sales_price}} + {{detail.numberSold}} {{/if}} {{/each}} + @@ -149,17 +179,25 @@ - {{#each model as |item|}} - {{#if item.apparel}} + {{#each model as |detail|}} + {{#if detail.item_id.apparel}} - {{item.id}} - {{item.name}} - {{item.price}} - {{item.sales_price}} - {{item.numberSold}} + {{detail.item_id.id}} + {{detail.item_id.name}} + {{#if detail.item_id.comic}} + Issue #: {{detail.issue_num}} + {{/if}} + {{#if detail.item_id.apparel}} + Size: {{detail.size}} + {{/if}} + + {{detail.item_id.price}} + {{detail.item_id.sales_price}} + {{detail.numberSold}} {{/if}} {{/each}} + diff --git a/client/app/templates/components/add-inventory.hbs b/client/app/templates/components/add-inventory.hbs index de8b10e..a4df1ca 100644 --- a/client/app/templates/components/add-inventory.hbs +++ b/client/app/templates/components/add-inventory.hbs @@ -36,10 +36,10 @@

{{typeName}}

- {{input id='price' type="text" value=price class='form-control'}} + {{input id='price' value=price class='form-control'}}
- {{input id='sales_price' type="text" value=sales_price class='form-control'}} + {{input id='sales_price' value=sales_price class='form-control'}}

@@ -61,6 +61,9 @@ {{/each}} + {{#each Writers as |writer|}} + + {{/each}}
- + {{#each Illustrators as |illustrator|}} + + {{/each}}

@@ -109,13 +114,13 @@ {{input id='vol_num' type="text" value=vol_num class='form-control'}}
- {{ember-selectize - content=bindingChoices - optionValuePath="content.name" - optionLabelPath="content.name" - selection=bindingChoice - value=bindingType - placeholder="Binding" }} + +
{{/if}} @@ -145,30 +150,47 @@ {{/if}} {{#if apparel}}
-
+
-
+
+
+ +

-
+
-
- {{ember-selectize - content=genderTypes - optionValuePath="content.name" - optionLabelPath="content.name" - selection=genderChoice - value=gender - placeholder="Select an item" }} +
+ + +
+
+ {{#if apparelType}} + {{apparelType}} + {{else}} + + {{/if}}

@@ -186,22 +208,28 @@
- {{ember-selectize - content=figureChoices - optionValuePath="content.name" - optionLabelPath="content.name" - selection=figureChoice - value=figureType - placeholder="Select an item" }} + {{#if figureChoice}} + {{figureChoice}} + {{else}} + + {{/if}}
- {{ember-selectize - content=materialChoices - optionValuePath="content.name" - optionLabelPath="content.name" - selection=materialChoice - value=materialType - placeholder="Select an item" }} + {{#if materialChoice}} + {{materialChoice}} + {{else}} + + {{/if}}

@@ -215,13 +243,16 @@
- {{ember-selectize - content=gameChoices - optionValuePath="content.name" - optionLabelPath="content.name" - selection=gameChoice - value=gameType - placeholder="Select an item" }} + {{#if gameChoice}} + {{gameType}} + {{else}} + + {{/if}}

@@ -245,6 +276,13 @@ placeholder="Select an item" }}
+
+
+ {{#each tags as |object|}} +

{{object.name}}

+ {{/each}} +
+
@@ -289,9 +327,14 @@
-
- +
+ +
+ {{#if session.currentUser.isAdmin}} +
+
+ {{/if}}

diff --git a/client/app/templates/components/edit-employee-form.hbs b/client/app/templates/components/edit-employee-form.hbs index 6ec2831..2b27897 100644 --- a/client/app/templates/components/edit-employee-form.hbs +++ b/client/app/templates/components/edit-employee-form.hbs @@ -4,7 +4,7 @@ diff --git a/client/app/templates/components/extra b/client/app/templates/components/extra new file mode 100644 index 0000000..1af65d3 --- /dev/null +++ b/client/app/templates/components/extra @@ -0,0 +1,14 @@ +50-55 for first year + +hyrbid testing and development enviroment +java and sql +contract-to-hire +agile development +2 week sprints + +12 months to go perm 25 hr +client sandy-spring/dunwoody + +autotrader - +3oclock interview tomorrow + diff --git a/client/app/templates/components/invoice-finder.hbs b/client/app/templates/components/invoice-finder.hbs new file mode 100644 index 0000000..7fe12b7 --- /dev/null +++ b/client/app/templates/components/invoice-finder.hbs @@ -0,0 +1,5 @@ + diff --git a/client/app/templates/components/invoice-graph.hbs b/client/app/templates/components/invoice-graph.hbs new file mode 100644 index 0000000..199b931 --- /dev/null +++ b/client/app/templates/components/invoice-graph.hbs @@ -0,0 +1,71 @@ +
+
+ + + + + + + + + + {{#each invoice.lineitems as |line|}} + + + + + + + {{/each}} + +
Item NameQUANITYADD/REMOVE
{{line.detail_id.item_id.name}} + {{#if line.detail_id.item_id.comic}} + Issue #: {{line.detail_id.issue_num}} + {{/if}} + {{#if line.detail_id.item_id.apparel}} + Size: {{line.detail_id.size}} + {{/if}} + {{input min="0" type="number" value=line.quanity class='form-control'}} + + + +
+
+
+
+
+ +
+
+
+
+
+ + + + + + + + + + {{#each vendorItems as |detail|}} + + + + + + {{/each}} + +
Item NameCURRENT QUANITYADD TO INVOICE
{{detail.item_id.name}} + {{#if detail.item_id.comic}} + Issue #: {{detail.issue_num}} + {{/if}} + {{#if detail.item_id.apparel}} + Size: {{detail.size}} + {{/if}} + {{detail.quanity}} + +
+
+
diff --git a/client/app/templates/components/low-inventory-button.hbs b/client/app/templates/components/low-inventory-button.hbs new file mode 100644 index 0000000..cb2584a --- /dev/null +++ b/client/app/templates/components/low-inventory-button.hbs @@ -0,0 +1,3 @@ + diff --git a/client/app/templates/components/low-inventory-list.hbs b/client/app/templates/components/low-inventory-list.hbs new file mode 100644 index 0000000..bbe025f --- /dev/null +++ b/client/app/templates/components/low-inventory-list.hbs @@ -0,0 +1,42 @@ + diff --git a/client/app/templates/components/main-navbar.hbs b/client/app/templates/components/main-navbar.hbs index 7566773..3e2f440 100644 --- a/client/app/templates/components/main-navbar.hbs +++ b/client/app/templates/components/main-navbar.hbs @@ -8,5 +8,5 @@ {{link-to 'Subscriptions' 'general.subscriptions'}}
  • - {{link-to 'Add Inventory' 'general.add_inventory' (query-params id="null" name="null")}} + {{link-to 'Add Inventory' 'general.add_inventory' (query-params id="null")}}
  • diff --git a/client/app/templates/components/new-employee-form.hbs b/client/app/templates/components/new-employee-form.hbs index 11e6437..dae87b7 100644 --- a/client/app/templates/components/new-employee-form.hbs +++ b/client/app/templates/components/new-employee-form.hbs @@ -10,23 +10,23 @@