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 @@
| Name | +NAME | UID | -Admin Access | -Last Action | -Edit | +ADMIN ACCESS | +EDIT | +REMOVE | {{user.full_name}} | {{user.id}} | {{user.isAdmin}} | -@@ -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}} + |
|---|---|---|---|---|---|---|---|---|---|
| {{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}} |
{{typeName}}
{{object.name}}
+ {{/each}} +| Item Name | +QUANITY | +ADD/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'}} + | ++ + + | +
| Item Name | +CURRENT QUANITY | +ADD 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}} | ++ + | +
{{item.id}} {{item.name}}
-{{/each}} +| Item Name | +PRICE | +CATEGORY | +Other | + +
|---|---|---|---|
| {{item.name}} | +{{item.sales_price}} | +{{item.typeName}} | +
+ {{#each item.Details as |detail|}}
+ Quanity: {{detail.quanity}}
+ {{#if detail.issue_num}}
+ Issue Num: {{detail.issue_num}}
+ + {{/if}} + {{#if detail.size}} + Size: {{detail.size}} + + {{/if}} + {{/each}} + {{#if item.gender}} + Gender: {{item.gender}} + {{/if}} + {{#if item.vol_num}} + Vol: {{item.vol_num}} + + {{/if}} + {{#if item.bindingType}} + Vol: {{item.bindingType}} + {{/if}} + {{#if item.figureType}} + Figure Type: {{item.figureType}} + + {{/if}} + {{#if item.materialType}} + Material Type: {{item.materialType}} + {{/if}} + {{#if item.gameType}} + Game Type: {{item.gameType}} + {{/if}} + |
+