Blame view
imports/collections/staff/methods.js
3.3 KB
d75229d74
|
1 2 3 4 5 6 7 8 |
// import {Parents } from '/imports/collections/parents/methods' import _ from 'lodash'; import { Meteor } from 'meteor/meteor'; import { ValidatedMethod } from 'meteor/mdg:validated-method'; import { SimpleSchema } from 'meteor/aldeed:simple-schema'; import { DDPRateLimiter } from 'meteor/ddp-rate-limiter'; import { Bert } from 'meteor/themeteorchef:bert'; import { Users } from '/imports/collections/users/index'; |
ec5f044a9
|
9 |
import { Staffs } from '/imports/collections/staff/index'; |
d75229d74
|
10 |
import { Orgs } from '/imports/collections/orgs/index'; |
ec5f044a9
|
11 12 |
export const staffMethods = new ValidatedMethod({ name: 'staff.method', |
d75229d74
|
13 14 15 16 17 18 19 20 21 22 |
validate: new SimpleSchema({ itemId: { type: String }, }).validator(), run({itemId}) { return {}; }, }); |
ec5f044a9
|
23 24 25 26 27 28 29 30 31 32 33 |
export const staffAddNew = new ValidatedMethod({ name: 'staff.addNew', validate: new SimpleSchema({ employeeId: { type: String }, firstName: { type: String }, lastName: { type: String }, martialStatus: { type: String }, gender: { type: String }, dob: { type: String }, |
df05c55ea
|
34 |
desgnation: { type: String }, |
ec5f044a9
|
35 36 37 38 39 40 41 42 |
type: { type: String }, doj: { type: String }, teaching: { type: String }, qualifaication: { type: String }, specialization: { type: String }, university: { type: String }, degreeFrom: { type: String }, degreeEnded: { type: String }, |
df05c55ea
|
43 44 45 46 47 |
email: { type: String }, phone: { type: String }, address: { type: String }, city: { type: String }, state: { type: String }, |
ec5f044a9
|
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
}).validator(), run(data) { const user = Users.findOne({_id: Meteor.userId()}); if(!user) return false; const org = Orgs.findOne({_id: user.orgId}); if(!org) return false; // console.log(data);return true; orgId = user.orgId; newUserId = Users.insert({ emails: [{address:data.email, verified: false}], phones: [{number:data.phone, verified: false}], firstName: data.firstName, lastName: data.lastName, address: data.address, orgId: orgId, role: 'STAFF' }); console.log("newUserId"); console.log(newUserId); if(newUserId){ newStaffId = Staffs.insert({ |
df05c55ea
|
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
userId: newUserId, orgId: orgId, employeeId: data.employeeId, martialStatus: data.martialStatus, gender: data.gender, dob: data.dob, teaching: data.teaching, type: data.type, 'educationDetails':[{ qualifaication: data.qualifaication, specialization: data.specialization, university: data.university, from: data.degreeFrom, to: data.degreeEnded, }], permanentAddress:{ address: data.data, city: data.city, state: data.state, }, doj: data.doj |
ec5f044a9
|
91 92 93 94 95 96 97 98 |
}); } console.log("newStaffId"); console.log(newStaffId); return {}; }, }); |