var user = function(data) { var self = this; self.id = ko.observable(); self.first_name = ko.observable(); self.last_name = ko.observable(); self.email = ko.observable(); self.type = ko.observable(); self.name = ko.observable(typeof data != 'undefined' && data.name != amplify.store("__client").name ? amplify.store("__client").name : ''); self.sendahDirectWallet = ko.observable(amplify.store("__client").sendahDirectWallet); self.moneyWallet = ko.observable(amplify.store("__client").moneyWallet); self.pcortezpaymayaWallet = ko.observable(amplify.store("__client").pcortezpaymayaWallet); self.raquelpaymayaWallet = ko.observable(amplify.store("__client").raquelpaymayaWallet); self.joyaspaymayaWallet = ko.observable(amplify.store("__client").joyaspaymayaWallet); self.wallets = ko.observableArray([ { 'key': 'money', 'value': 'money' } ]); self.walletType = ko.observable(); self.attributes = ko.observableArray(); self.showCode = ko.observable(false); self.status = ko.observable(); self.type = ko.observable(); self.created_at = ko.observable(); self.updated_at = ko.observable(); self.tokens = ko.observableArray(); self.refresh_tokens = ko.observableArray(); self._token = ko.observable($('meta[name="_token"]').attr('content')); self.ancestor = ko.observable(); self.ancestor_id = ko.observable(); self.relation = ko.observable(); self.rel_id = ko.observable(); self.currency = ko.observable(); self.password = ko.observable(); self.verification_code = ko.observable(); self.password_confirmation = ko.observable(); self.user_attribute_address_region = ko.observable(); self.user_attribute_address_city = ko.observable(); self.user_attribute_address_municipality = ko.observable(); self.user_attribute_address_zipcode = ko.observable(); self.user_attribute_address = ko.observable(); self.user_attribute_company_name = ko.observable(); self.user_attribute_branch_name = ko.observable(); self.user_attribute_branch_address = ko.observable(); self.user_attribute_branch_region = ko.observable(); self.user_attribute_branch_city = ko.observable(); self.user_attribute_branch_municipality = ko.observable(); self.user_attribute_branch_zipcode = ko.observable(); self.user_attribute_max_login_attempts = ko.observable(); self.user_attribute_login_attempts = ko.observable(); self.acl_smartpadala_acceptance = ko.observable(); self.acl_smartpadala_encashment = ko.observable(); self.acl_smartpadala_settlement = ko.observable(); self.acl_diskartech_cash_in = ko.observable(); self.acl_nextbank_cash_in = ko.observable(); self.acl_nextbank_cash_out = ko.observable(); self.acl_netbank_cash_in = ko.observable(); self.acl_netbank_cash_out = ko.observable(); self.acl_netizen_cash_in = ko.observable(); self.acl_netizen_cash_out = ko.observable(); self.acl_valise_cash_in = ko.observable(); self.acl_valise_cash_out = ko.observable(); self.acl_insurance = ko.observable(); self.acl_epin = ko.observable(); self.acl_billspayment = ko.observable(); self.acl_egc_send = ko.observable(); self.acl_egc_redeem = ko.observable(); self.acl_agents = ko.observable(); self.msisdn = ko.observable(); self.ancestor_email = ko.computed(function() { var user = ko.toJS(self.ancestor()); if (typeof user != "undefined" && user == "null") { if (user.length) return user[0]['email']; } return ''; }, this); if (data) { self.update(data); } }; user.prototype.update = function(data) { var acl = ko.utils.parseJson(data.attributes['acl']); this.id(data.id); this.first_name(data.first_name); this.last_name(data.last_name); this.name(data.name); this.email(data.email); this.type(data.type); this.name(data.name); this.walletType(data.walletType); this.sendahDirectWallet(typeof data.wallets.sendah_direct == 'undefined' ? 0.00.toFixed(2) : data.wallets.sendah_direct.amount.toFixed(2)); this.moneyWallet(typeof data.wallets.money == 'undefined' ? 0.00.toFixed(2) : data.wallets.money.amount.toFixed(2)); this.pcortezpaymayaWallet(typeof data.wallets.pcortezpaymaya == 'undefined' ? 0.00.toFixed(2) : data.wallets.pcortezpaymaya.amount.toFixed(2)); this.joyaspaymayaWallet(typeof data.wallets.joyaspaymaya == 'undefined' ? 0.00.toFixed(2) : data.wallets.joyaspaymaya.amount.toFixed(2)); this.raquelpaymayaWallet(typeof data.wallets.raquelpaymaya == 'undefined' ? 0.00.toFixed(2) : data.wallets.raquelpaymaya.amount.toFixed(2)); this.attributes(data.attributes); this.showCode(data.showCode); this.status(data.status); this.type(data.type); this.created_at(data.created_at); this.updated_at(data.updated_at); this.tokens(data.tokens); this.refresh_tokens(data.refresh_tokens); this.ancestor(data.ancestor); this.ancestor_id(data.ancestor_id); this.relation(data.relation); this.rel_id(data.rel_id); this.currency(data.currency); this.password(data.password); this.verification_code(data.verification_code); this.password_confirmation(data.password_confirmation); this.user_attribute_address_region((typeof data.attributes != "undefined" && data.attributes != null) ? data.attributes['address_region'] : ''); this.user_attribute_address_city((typeof data.attributes != "undefined" && data.attributes != null) ? data.attributes['address_city'] : ''); this.user_attribute_address_municipality((typeof data.attributes != "undefined" && data.attributes != null) ? data.attributes['address_municipality'] : ''); this.user_attribute_address_zipcode((typeof data.attributes != "undefined" && data.attributes != null) ? data.attributes['address_zipcode'] : ''); this.user_attribute_address((typeof data.attributes != "undefined" && data.attributes != null) ? data.attributes['address'] : ''); this.user_attribute_company_name((typeof data.attributes != "undefined" && data.attributes != null) ? data.attributes['company_name'] : ''); this.user_attribute_branch_name((typeof data.attributes != "undefined" && data.attributes != null) ? data.attributes['branch_name'] : ''); this.user_attribute_branch_address((typeof data.attributes != "undefined" && data.attributes != null) ? data.attributes['branch_address'] : ''); this.user_attribute_branch_region((typeof data.attributes != "undefined" && data.attributes != null) ? data.attributes['branch_region'] : ''); this.user_attribute_branch_city((typeof data.attributes != "undefined" && data.attributes != null) ? data.attributes['branch_city'] : ''); this.user_attribute_branch_municipality((typeof data.attributes != "undefined" && data.attributes != null) ? data.attributes['branch_municipality'] : ''); this.user_attribute_branch_zipcode((typeof data.attributes != "undefined" && data.attributes != null) ? data.attributes['branch_zipcode'] : ''); this.user_attribute_max_login_attempts((typeof data.attributes != "undefined" && data.attributes != null && data.attributes['max_login_attempts'] != null) ? data.attributes['max_login_attempts'] : ''); this.user_attribute_login_attempts((typeof data.attributes != "undefined" && data.attributes != null && data.attributes['login_attempts'] != null) ? data.attributes['login_attempts'] : ''); this.acl_smartpadala_acceptance(acl != null ? acl.hasOwnProperty('smartpadala_acceptance') && acl.smartpadala_acceptance : false); this.acl_smartpadala_encashment(acl != null ? acl.hasOwnProperty('smartpadala_encashment') && acl.smartpadala_encashment : false); this.acl_smartpadala_settlement(acl != null ? acl.hasOwnProperty('smartpadala_settlement') && acl.smartpadala_settlement : false); this.acl_diskartech_cash_in(acl != null ? acl.hasOwnProperty('diskartech_cash_in') && acl.diskartech_cash_in : false); this.acl_nextbank_cash_in(acl != null ? acl.hasOwnProperty('nextbank_cash_in') && acl.nextbank_cash_in : false); this.acl_nextbank_cash_out(acl != null ? acl.hasOwnProperty('nextbank_cash_out') && acl.nextbank_cash_out : false); this.acl_netizen_cash_in(acl != null ? acl.hasOwnProperty('netizen_cash_in') && acl.netizen_cash_in : false); this.acl_netizen_cash_out(acl != null ? acl.hasOwnProperty('netizen_cash_out') && acl.netizen_cash_out : false); this.acl_netbank_cash_in(acl != null ? acl.hasOwnProperty('netbank_cash_in') && acl.netbank_cash_in : false); this.acl_netbank_cash_out(acl != null ? acl.hasOwnProperty('netbank_cash_out') && acl.netbank_cash_out : false); this.acl_valise_cash_in(acl != null ? acl.hasOwnProperty('valise_cash_in') && acl.valise_cash_in : false); this.acl_valise_cash_out(acl != null ? acl.hasOwnProperty('valise_cash_out') && acl.valise_cash_out : false); this.acl_agents(acl != null ? acl.hasOwnProperty('agents') && acl.agents : false); this.acl_insurance(acl != null ? acl.hasOwnProperty('insurance') && acl.insurance : false); this.acl_epin(acl != null ? acl.hasOwnProperty('epin') && acl.epin : false); this.acl_billspayment(acl != null ? acl.hasOwnProperty('billspayment') && acl.billspayment : false); this.acl_diskartech_cash_in(acl != null ? acl.hasOwnProperty('diskartech_cash_in') && acl.diskartech_cash_in : false); this.acl_egc_send(acl != null ? acl.hasOwnProperty('egc_send') && acl.egc_send : false); this.acl_egc_redeem(acl != null ? acl.hasOwnProperty('egc_redeem') && acl.egc_redeem : false); this.msisdn(data.msisdn); };