This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exports.update = function(req, res){ | |
| var chk = req.body.chkId; | |
| var sel = req.body.selUpd; | |
| for(i=0; i<chk.length; i++){ | |
| if(sel == 'del'){ | |
| _this._delete(chk[i]); | |
| req.flash('success_msg', 'The data has been deleted.'); | |
| res.redirect('/' + control + '/'); | |
| } else { | |
| _this._status(chk[i],(sel == 'ena' ? 1 : 0)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exports.status = function(req, res) { | |
| if(req.params.id!=1&&(req.params.id!=req.session.uId)){ | |
| _this._status(req.params.id, req.params.st); | |
| req.flash('success_msg', 'The changes have been saved.'); | |
| res.redirect('/' + control + '/'); | |
| } else { | |
| req.flash('error_msg', 'The data can not change.'); | |
| res.redirect('/' + control + '/'); | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exports.delete = function(req, res) { | |
| if(req.params.id!=1&&(req.params.id!=req.session.uId)){ | |
| _this._delete(req.params.id); | |
| req.flash('success_msg', 'The data has been deleted.'); | |
| res.redirect('/' + control + '/'); | |
| } else { | |
| req.flash('error_msg', 'The data can not delete.'); | |
| res.redirect('/' + control + '/'); | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exports.save = function(req, res) { | |
| var id = req.body.hdId; | |
| var save = req.body.hdSave; | |
| //Upload | |
| var imgPath = req.files.fiAva.path; | |
| var imgName = req.files.fiAva.name!=''?(Date.now() + '_' + req.files.fiAva.name):''; | |
| fs.readFile(imgPath, function(err, data){ | |
| if(req.files.fiAva.name){ | |
| var newPath = "./public/uploads/" + imgName; | |
| fs.writeFile(newPath, data, function(err){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exports.chkName = function(req, res) { | |
| var id = req.params.id; //console.log(id); | |
| if(id==0){ | |
| var query = conn.query("SELECT * FROM `" + prefix + "user`" + " WHERE uName=" + conn.escape(req.body.txtName), function(err, rows){ | |
| if(err) { console.log(query.sql); console.log(err);} | |
| if(rows.length==0){ | |
| res.send('1'); | |
| } else { | |
| res.send('{ "error": "The Username is exist." }'); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exports.edit = function(req, res) { | |
| var id = req.params.id; | |
| var query = conn.query("SELECT * FROM `" + prefix + "user`" + " WHERE uId=" + conn.escape(id), function(err, rows){ | |
| if(err) { console.log(query.sql); console.log(err);} | |
| var query = conn.query(sqlLstComp, function(err, lstComp){ | |
| if(err) { console.log(query.sql); console.log(err);} | |
| var query = conn.query(sqlLstBr, function(err, lstBr){ | |
| if(err) { console.log(query.sql); console.log(err);} | |
| var query = conn.query(sqlLstRl, function(err, lstRl){ | |
| if(err) { console.log(query.sql); console.log(err);} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exports.create = function(req, res){ | |
| var query = conn.query(sqlLstComp, function(err, lstComp){ | |
| if(err) { console.log(query.sql); console.log(err);} | |
| var query = conn.query(sqlLstBr, function(err, lstBr){ | |
| if(err) { console.log(query.sql); console.log(err);} | |
| res.render(control + '/frm', { | |
| title: 'User', | |
| control: control, | |
| lstComp: lstComp, | |
| lstBr: lstBr, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exports.index = function(req, res) { | |
| delete req.session.search; | |
| _this._showlist(req, res); | |
| }; | |
| exports.search = function(req, res) { | |
| search['per_page'] = req.body.selLimit?req.body.selLimit:10; | |
| search['name'] = req.body.txtName?req.body.txtName:''; | |
| search['status'] = req.body.selStatus?req.body.selStatus:''; | |
| req.session.search = search; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var _this = this, | |
| prefix = cfg.db.prefix, | |
| prefixDt = cfg.db.prefixDt, | |
| control = 'ad_user'; | |
| var search = { | |
| per_page: '10', | |
| name: '', | |
| status: '', | |
| sort: '', | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * GET admin user page. | |
| */ | |
| var _this = this, | |
| prefix = cfg.db.prefix, | |
| prefixDt = cfg.db.prefixDt, | |
| control = 'ad_user'; | |
| var search = { | |
| per_page: '10', |