flexbiz-server 12.2.0 → 12.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/server/auths/local.js +2 -1
- package/server/controllers/controller.js +61 -58
- package/server/libs/validator-vt.js +1 -1
- package/server/models/approve.js +6 -5
- package/server/models/assrequest.js +1 -1
- package/server/models/dmhoahonghd.js +5 -5
- package/server/models/file.js +2 -2
- package/server/models/folder.js +2 -2
- package/server/models/group.js +4 -4
- package/server/models/keyresult.js +2 -1
- package/server/models/moduleinfo.js +4 -3
- package/server/models/okr.js +1 -1
- package/server/models/so1.js +14 -14
- package/server/models/task.js +1 -1
- package/server/modules/lists/ls-customer.js +5 -4
- package/server/modules/lists/ls-dmbp.js +2 -2
- package/server/modules/lists/ls-dmdt.js +5 -5
- package/server/modules/lists/ls-dmdvt.js +1 -1
- package/server/modules/lists/ls-dmkho.js +1 -2
- package/server/modules/lists/ls-dmnhtask.js +5 -4
- package/server/modules/lists/ls-dmnv.js +14 -14
- package/server/modules/lists/ls-dvcs.js +1 -1
- package/server/modules/lists/ls-file.js +4 -4
- package/server/modules/lists/ls-task.js +4 -3
- package/server/modules/reports/rp-congviectheobp.js +4 -4
- package/server/modules/reports/rp-congviectheodt.js +5 -5
- package/server/modules/reports/rp-congviectheokh.js +5 -5
- package/server/modules/reports/rp-congviectheonv.js +3 -3
- package/server/modules/systems/sys-app.js +4 -4
- package/server/modules/vouchers/vo-hd2.js +37 -37
- package/server/modules/vouchers/vo-pnh.js +5 -4
- package/server/modules/vouchers/vo-pxh.js +4 -3
- package/server/modules/vouchers/vo-so1.js +68 -66
package/package.json
CHANGED
package/server/auths/local.js
CHANGED
|
@@ -4,7 +4,8 @@ function generateToken($user$$){var $body_n_n$$={email:$user$$.email};configs.AP
|
|
|
4
4
|
function saveOTP($Phone$$,$otp_code$$,$callback$$,$expires$$=5){let $expire_time$$=new Date;$expire_time$$.setMinutes($expire_time$$.getMinutes()+$expires$$);OTP.create({phone:$Phone$$,otp:$otp_code$$,expire_time:$expire_time$$},($e$$,$rs$$)=>{if($e$$)return $callback$$($e$$);$callback$$(null,$rs$$.toObject())})}
|
|
5
5
|
function findByUsername($username$$,$fn$$){if(!$username$$)return $fn$$("B\u1ea1n ch\u01b0a nh\u1eadp t\u00e0i kho\u1ea3n");User.findOne({$or:[{email:$username$$},{"local.phone":$username$$}]},function($error$$,$result$$){return!$error$$&&$result$$&&$result$$.local?$fn$$(null,$result$$):$fn$$($error$$||`T\u00e0i kho\u1ea3n ${$username$$} kh\u00f4ng t\u1ed3n t\u1ea1i`)})}
|
|
6
6
|
async function addUserToApp($user$$,$body$$,$cust_session_created$$){if($body$$.id_app){if(!await App.findById($body$$.id_app))throw console.error("Can't find app",$body$$.id_app),"Kh\u00f4ng th\u1ec3 t\u00ecm th\u1ea5y th\u00f4ng tin c\u00f4ng ty n\u00e0y";await Participant.asyncCreateParticipant({id_app:$body$$.id_app,name:$body$$.name||$user$$.email,email:$body$$.email,group_id:$body$$.group_id,active:!0,session_created:$cust_session_created$$});await global.getModel("customer").findOne({id_app:$body$$.id_app,
|
|
7
|
-
of_user:$user$$.email}).lean()||($cust_session_created$$={ten_kh:$body$$.name||$user$$.email,email
|
|
7
|
+
of_user:$user$$.email}).lean()||($cust_session_created$$={ten_kh:$body$$.name||$user$$.email,email:validator.isEmail($user$$.email)?$user$$.email:void 0},$body$$.customer_info&&($cust_session_created$$={...$cust_session_created$$,...$body$$.customer_info}),$cust_session_created$$.ten_kh||($cust_session_created$$.ten_kh=$body$$.name||$user$$.email),$cust_session_created$$={...$cust_session_created$$,id_app:$body$$.id_app,user_created:$user$$.email,user_updated:$user$$.email,kh_yn:!0,of_user:$user$$.email},
|
|
8
|
+
await Customer.asyncCreateCustomer($cust_session_created$$))}}
|
|
8
9
|
module.exports=async function($app$jscomp$0$$,$passport$$){const $rateLimiter$$=await global.createRateLimiterMiddleware(configs.limitRequest.auth||{},"auth");$passport$$.use(new BasicStrategy(function($username$$,$password$$,$done$$){if(!$username$$)return $done$$("B\u1ea1n ch\u01b0a nh\u1eadp t\u00e0i kho\u1ea3n");$username$$=$username$$.trim().toLowerCase();setImmediate(function(){findByUsername($username$$,function($err$$,$user$$){if($err$$)return $done$$($err$$);if(!$user$$)return $done$$("T\u00e0i kho\u1ea3n "+
|
|
9
10
|
$username$$+" ch\u01b0a \u0111\u01b0\u1ee3c \u0111\u0103ng k\u00fd.");if(0==$user$$.status)return $done$$("T\u00e0i kho\u1ea3n n\u00e0y kh\u00f4ng c\u00f2n hi\u1ec7u l\u1ef1c");if($user$$.local.rspassword)if($user$$.validRspassword($password$$))$user$$.local.password=$user$$.local.rspassword,$user$$.local.rspassword=void 0,User.findOneAndUpdate({email:$user$$.email},{local:$user$$.local},($e$$,$rs$$)=>{if($e$$)return console.error("Can't update password",$user$$.email,$e$$);console.log("updated new password",
|
|
10
11
|
$user$$.email,$rs$$)});else{if(!$user$$.validPassword($password$$))return $done$$("M\u1eadt kh\u1ea9u kh\u00f4ng ch\u00ednh x\u00e1c.")}else{if(!$user$$.local.password)return $done$$("M\u1eadt kh\u1ea9u cho ng\u01b0\u1eddi d\u00f9ng n\u00e0y kh\u00f4ng t\u1ed3n t\u1ea1i. H\u00e3y s\u1eed d\u1ee5ng t\u00ednh n\u0103ng kh\u00f4i ph\u1ee5c m\u1eadt kh\u1ea9u \u0111\u1ec3 \u0111\u1eb7t l\u1ea1i m\u1eadt kh\u1ea9u cho ng\u01b0\u1eddi d\u00f9ng n\u00e0y");if(!$user$$.validPassword($password$$))return $done$$("M\u1eadt kh\u1ea9u kh\u00f4ng ch\u00ednh x\u00e1c.")}return $done$$(null,
|
|
@@ -14,37 +14,38 @@ class controller{constructor($router$$,$model$$,$name$$,$options$jscomp$0$$={isV
|
|
|
14
14
|
!0===$options$jscomp$0$$.require_id_app?(this.require_id_app=!0,this.route_name=`/:id_app/${this.module}`):(this.require_id_app=!1,this.route_name=`/${this.module}`);this.collection_name=$options$jscomp$0$$.collection_name?$options$jscomp$0$$.collection_name:$name$$;this.sort=$options$jscomp$0$$.sort;this.unique=$options$jscomp$0$$.unique;this.getting=$options$jscomp$0$$.onGetting;this.finding=$options$jscomp$0$$.onFinding;this.found=$options$jscomp$0$$.onFound;this.validating=$options$jscomp$0$$.onValidating;
|
|
15
15
|
this.saving=$options$jscomp$0$$.onSaving;this.creating=$options$jscomp$0$$.onCreating;this.created=$options$jscomp$0$$.onCreated;this.updating=$options$jscomp$0$$.onUpdating;this.updated=$options$jscomp$0$$.onUpdated;this.deleting=$options$jscomp$0$$.onDeleting;this.deleted=$options$jscomp$0$$.onDeleted;this.approveData=$options$jscomp$0$$.approveData;this.view=$options$jscomp$0$$.onView;this.asyncView=async($user$$,$items$$,$options$$)=>{const $self$$=this;return new Promise($resolve$$=>{$self$$.onView($user$$,
|
|
16
16
|
$items$$,($error$$,$rs$$)=>{if($error$$)return console.error($error$$),$resolve$$($items$$);$resolve$$($rs$$)},$options$$)})};this.onView=($user$$,$items$$,$next$$,$options$$)=>{let $self$$=this,$fields_load$$="";$options$$&&$options$$.req&&$options$$.req.query&&$options$$.req.query.fields&&($fields_load$$=$options$$.req.query.fields);let $schema_paths$$=$model$$.schema.paths;underscore.has($schema_paths$$,"exfields")&&$items$$.forEach($item$$=>{delete $item$$.__v;$item$$.exfields||($item$$.exfields=
|
|
17
|
-
{})});async.series({_Participant_created:$callback$$=>{underscore.has($schema_paths$$,"id_app")
|
|
18
|
-
"id_app")
|
|
19
|
-
{title:1,trang_thai:1,user_approved:1,user_approved_name:1,date_approved:1,user_denied:1,user_denied_name:1,date_denied:1}).lean().exec(async($e$$,$rs$$)=>{setImmediate(async()=>{$item$$.approve_data=$rs$$;await $item$$.approve_data.asyncJoinModel2($item$$.id_app,Participant,{where:{user_approved:"email"},fields:{user_approved_name:"name",signature_image:"signature_image"}});
|
|
20
|
-
signature_image:"signature_image"}});$next$$(null)})})})},()=>{$callback$$(null)}):$callback$$(null)},transfer_ct:$callback$$=>{if(underscore.has($schema_paths$$,"id_ct_chuyen")&&$user$$.current_app_info&&$user$$.current_app_info.options&&$user$$.current_app_info.options.id_app_thue)async.mapSeries($items$$,($item$$,$next$$)=>{setImmediate(()=>
|
|
21
|
-
($item$$.id_ct_nhan=$rs$$._id);$next$$(null)})})},()=>{$callback$$(null)});else return $callback$$()},posted:$callback$$=>{$options$$&&$options$$.req&&($options$$.req.query.show_posted_book||$options$$.req.query.show_not_post_book)?async.mapSeries($items$$,($item$$,$next$$)=>{setImmediate(async()=>{let $book$$=$options$$.req.query.show_posted_book
|
|
22
|
-
|
|
23
|
-
$items$$,function($error$jscomp$0$$,$rs$jscomp$0$$){setImmediate(()=>{if($error$jscomp$0$$)return $next$$($error$jscomp$0$$);$self$$.dynamicView?$self$$.dynamicView($user$$,$rs$jscomp$0$$||$items$$,function($error$$,$rs$$){if($error$$)return $next$$($error$$);$next$$(null,$rs$$||$items$$)}):$next$$(null,$rs$jscomp$0$$||$items$$)})},$options$$)}catch($e$$){console.error("Error on view of"
|
|
24
|
-
$rs$$){if($error$$)return $next$$($error$$);$next$$(null,$rs$$||$items$$)}):$next$$(null,$items$$)})})};this.excelParse=$options$jscomp$0$$.onExcelParse;this.options=$options$jscomp$0$$;this.replaceIfExists=$options$jscomp$0$$.replaceIfExists;this.notNeedRight=$options$jscomp$0$$.notNeedRight}getProperty($name$$){return this[$name$$]}getNextId(){let $ma_ct$$=this.name;this.router.route(`${this.route_name}/next/:field`).get(($field
|
|
25
|
-
"so_ct"===$field$$?$res$$.send({[$field$$]:$ma_ct$$}):getNextSequence($id_app$$,$ma_ct$$,$field$$,($e$$,$rs$$)=>{if($e$$)return console.error($e$$),$e$$.error?$res$$.status(400).send($e$$):$res$$.status(400).send({error:$e$$.message||$e$$});$res$$.send($rs$$)})})}async checkData($appInfo$$,$data$$,$fn$$){const $options$$=this.options;if($data$$.trang_thai&&$data$$.ma_ct){let $tt$$=await trangthai.findOne({ma_ct:$data$$.ma_ct,
|
|
26
|
-
{$data$$.details&&$appInfo$$&&$appInfo$$.options&&$appInfo$$.options.khong_xuat_kho_am&&0!=$options$$.check_stock?(async()=>{let $details$$=$data$$.details.filter($d$$=>$d$$.ma_vt&&$d$$.sl_xuat);await $details$$.asyncJoinModel2($appInfo$$._id,dmvt,{where:{ma_vt:"ma_vt"},fields:["tg_tk","kg_kiem_tra_ton_kho","kg_kiem_tra_ton_kho_tt","combo","ten_vt"]})
|
|
27
|
-
0<$detail$$.combo.length?$detail$$.combo.map($c$$=>{$c$$=$c$$.toObject?$c$$.toObject():{...$c$$};$c$$.sl_xuat*=$detail$$.sl_xuat;$c$$.ma_kho=$detail$$.ma_kho;return $c$$}):[$detail$$]).reduce(($a$$,$b$$)=>$a$$.concat($b$$),[]);await $details$$.asyncJoinModel2($appInfo$$._id,dmqddvt,{where:{ma_vt:"ma_vt",ma_dvt:"ma_dvt"},fields:"ty_le_qd"});let $data_sokho$$=
|
|
28
|
-
1;$d$$.sl_xuat_qd=$d$$.he_so_qd*$d$$.sl_xuat});$details$$=await $details$$.asyncGroupBy(["ma_vt","ma_kho","ten_vt"],["sl_xuat_qd"]);async.mapSeries($details$$,($d$$,$callback$$)=>{let $ma_kho$$=$d$$.ma_kho||$data$$.ma_kho||$data$$.ma_kho_x,$query$$={ma_vt:$d$$.ma_vt,ma_kho:$ma_kho$$,ngay:new Date,id_app:$appInfo$$._id};$d$$.kg_kiem_tra_ton_kho_tt||($d$$.ma_lo&&
|
|
29
|
-
$d$$.ma_tt2),$d$$.ma_tt3&&($query$$.ma_tt3=$d$$.ma_tt3));ckvt($query$$,function($e$$,$rs$$){if($e$$)return $callback$$($e$$);$rs$$?($e$$=$rs$$.csum("ton"),$rs$$=$data_sokho$$.filter($s$$=>$s$$.ma_vt===$d$$.ma_vt&&$s$$.ma_kho===$ma_kho$$).reduce(($a$$,$b$$)=>($a$$.sl_xuat_qd||0)+($b$$.sl_xuat_qd||0),0),$d$$.sl_xuat_qd>utils.round($e$$+$rs$$,2)?$callback$$(`S\u1ea3n ph\u1ea9m ${$d$$.ma_vt} - ${$d$$.ten_vt} c\u00f3 s\u1ed1 l\u01b0\u1ee3ng xu\u1ea5t quy \u0111\u1ed5i (${$d$$.sl_xuat_qd}) l\u1edbn h\u01a1n s\u1ed1 l\u01b0\u1ee3ng t\u1ed3n quy \u0111\u1ed5i (${$e$$+
|
|
17
|
+
{})});async.series({_Participant_created:$callback$$=>{setImmediate(async()=>{underscore.has($schema_paths$$,"id_app")&&await $items$$.filter($item$$=>$item$$.user_created).asyncJoinModel2($user$$.current_id_app,Participant,{where:{user_created:"email"},fields:{name_user_created:"name"}});await $items$$.filter($item$$=>$item$$.user_created&&!$item$$.name_user_created).asyncJoinModel2(null,User,{where:{user_created:"email"},fields:{name_user_created:"name"}});$callback$$(null)})},_Participant_updated:$callback$$=>
|
|
18
|
+
{setImmediate(async()=>{underscore.has($schema_paths$$,"id_app")&&await $items$$.filter($item$$=>$item$$.user_updated).asyncJoinModel2($user$$.current_id_app,Participant,{where:{user_updated:"email"},fields:{name_user_updated:"name"}});await $items$$.filter($item$$=>$item$$.user_updated&&!$item$$.name_user_updated).asyncJoinModel2(null,User,{where:{user_updated:"email"},fields:{name_user_updated:"name"}});$callback$$(null)})},_approve:$callback$$=>{!$fields_load$$||0<=$fields_load$$.indexOf("approve_data")?
|
|
19
|
+
async.mapSeries($items$$,($item$$,$next$$)=>{setImmediate(()=>{Approve.find({id_ct:$item$$._id.toString()},{title:1,trang_thai:1,user_approved:1,user_approved_name:1,date_approved:1,user_denied:1,user_denied_name:1,date_denied:1}).lean().exec(async($e$$,$rs$$)=>{setImmediate(async()=>{$item$$.approve_data=$rs$$;await $item$$.approve_data.filter($r$$=>$r$$.user_approved).asyncJoinModel2($item$$.id_app,Participant,{where:{user_approved:"email"},fields:{user_approved_name:"name",signature_image:"signature_image"}});
|
|
20
|
+
await $item$$.approve_data.filter($r$$=>$r$$.user_denied).asyncJoinModel2($item$$.id_app,Participant,{where:{user_denied:"email"},fields:{user_denied_name:"name",signature_image:"signature_image"}});$next$$(null)})})})},()=>{$callback$$(null)}):$callback$$(null)},transfer_ct:$callback$$=>{if(underscore.has($schema_paths$$,"id_ct_chuyen")&&$user$$.current_app_info&&$user$$.current_app_info.options&&$user$$.current_app_info.options.id_app_thue)async.mapSeries($items$$,($item$$,$next$$)=>{setImmediate(()=>
|
|
21
|
+
{$model$$.findOne({id_app:$user$$.current_app_info.options.id_app_thue,id_ct_chuyen:$item$$._id.toString()},{_id:1}).lean().exec(async($e$$,$rs$$)=>{$rs$$&&($item$$.id_ct_nhan=$rs$$._id);$next$$(null)})})},()=>{$callback$$(null)});else return $callback$$()},posted:$callback$$=>{$options$$&&$options$$.req&&($options$$.req.query.show_posted_book||$options$$.req.query.show_not_post_book)?async.mapSeries($items$$,($item$$,$next$$)=>{setImmediate(async()=>{let $book$$=$options$$.req.query.show_posted_book||
|
|
22
|
+
$options$$.req.query.show_not_post_book,$exists$$=await global.getModel($book$$).findOne({id_ct:$item$$._id.toString()},{_id:1});$item$$[`${$book$$}_posted`]=!!$exists$$;$next$$()})},()=>{$callback$$(null)}):$callback$$()}},$e$jscomp$0$$=>{if($e$jscomp$0$$)return $next$$($e$jscomp$0$$);if($options$$&&$options$$.req&&($options$$.req.query.show_posted_book||$options$$.req.query.show_not_post_book)){let $book$$=$options$$.req.query.show_posted_book||$options$$.req.query.show_not_post_book;$items$$=$items$$.filter($r$$=>
|
|
23
|
+
$options$$.req.query.show_posted_book?$r$$[`${$book$$}_posted`]:!$r$$[`${$book$$}_posted`])}setImmediate(()=>{if($self$$.view)try{$self$$.view($user$$,$items$$,function($error$jscomp$0$$,$rs$jscomp$0$$){setImmediate(()=>{if($error$jscomp$0$$)return $next$$($error$jscomp$0$$);$self$$.dynamicView?$self$$.dynamicView($user$$,$rs$jscomp$0$$||$items$$,function($error$$,$rs$$){if($error$$)return $next$$($error$$);$next$$(null,$rs$$||$items$$)}):$next$$(null,$rs$jscomp$0$$||$items$$)})},$options$$)}catch($e$$){console.error("Error on view of",
|
|
24
|
+
$name$$,$e$$),$next$$(null,$items$$)}else $self$$.dynamicView?$self$$.dynamicView($user$$,$items$$,function($error$$,$rs$$){if($error$$)return $next$$($error$$);$next$$(null,$rs$$||$items$$)}):$next$$(null,$items$$)})})};this.excelParse=$options$jscomp$0$$.onExcelParse;this.options=$options$jscomp$0$$;this.replaceIfExists=$options$jscomp$0$$.replaceIfExists;this.notNeedRight=$options$jscomp$0$$.notNeedRight}getProperty($name$$){return this[$name$$]}getNextId(){let $ma_ct$$=this.name;this.router.route(`${this.route_name}/next/:field`).get(($field$$,
|
|
25
|
+
$res$$)=>{let $id_app$$=$field$$.user.current_id_app;$field$$=$field$$.params.field;"so_ct"===$field$$?$res$$.send({[$field$$]:$ma_ct$$}):getNextSequence($id_app$$,$ma_ct$$,$field$$,($e$$,$rs$$)=>{if($e$$)return console.error($e$$),$e$$.error?$res$$.status(400).send($e$$):$res$$.status(400).send({error:$e$$.message||$e$$});$res$$.send($rs$$)})})}async checkData($appInfo$$,$data$$,$fn$$){const $options$$=this.options;if($data$$.trang_thai&&$data$$.ma_ct){let $tt$$=await trangthai.findOne({ma_ct:$data$$.ma_ct,
|
|
26
|
+
ma_trang_thai:$data$$.trang_thai},{check_data:1}).lean();if($tt$$&&0==$tt$$.check_data)return $fn$$()}async.series({checkTonKho:$callback$jscomp$0$$=>{$data$$.details&&$appInfo$$&&$appInfo$$.options&&$appInfo$$.options.khong_xuat_kho_am&&0!=$options$$.check_stock?(async()=>{let $details$$=$data$$.details.filter($d$$=>$d$$.ma_vt&&$d$$.sl_xuat);await $details$$.asyncJoinModel2($appInfo$$._id,dmvt,{where:{ma_vt:"ma_vt"},fields:["tg_tk","kg_kiem_tra_ton_kho","kg_kiem_tra_ton_kho_tt","combo","ten_vt"]});
|
|
27
|
+
$details$$=$details$$.filter($d$$=>$d$$.tg_tk&&!$d$$.kg_kiem_tra_ton_kho||0<($d$$.combo||[]).length);$details$$=$details$$.map($detail$$=>$detail$$.combo&&0<$detail$$.combo.length?$detail$$.combo.map($c$$=>{$c$$=$c$$.toObject?$c$$.toObject():{...$c$$};$c$$.sl_xuat*=$detail$$.sl_xuat;$c$$.ma_kho=$detail$$.ma_kho;return $c$$}):[$detail$$]).reduce(($a$$,$b$$)=>$a$$.concat($b$$),[]);await $details$$.asyncJoinModel2($appInfo$$._id,dmqddvt,{where:{ma_vt:"ma_vt",ma_dvt:"ma_dvt"},fields:"ty_le_qd"});let $data_sokho$$=
|
|
28
|
+
[];$data$$._id&&($data_sokho$$=await Sokho.find({id_ct:$data$$._id.toString()}).lean());$details$$.forEach($d$$=>{$d$$.he_so_qd=$d$$.ty_le_qd||1;$d$$.sl_xuat_qd=$d$$.he_so_qd*$d$$.sl_xuat});$details$$=await $details$$.asyncGroupBy(["ma_vt","ma_kho","ten_vt"],["sl_xuat_qd"]);async.mapSeries($details$$,($d$$,$callback$$)=>{let $ma_kho$$=$d$$.ma_kho||$data$$.ma_kho||$data$$.ma_kho_x,$query$$={ma_vt:$d$$.ma_vt,ma_kho:$ma_kho$$,ngay:new Date,id_app:$appInfo$$._id};$d$$.kg_kiem_tra_ton_kho_tt||($d$$.ma_lo&&
|
|
29
|
+
($query$$.ma_lo=$d$$.ma_lo),$d$$.han_sd&&($query$$.han_sd=$d$$.han_sd),$d$$.ma_tt1&&($query$$.ma_tt1=$d$$.ma_tt1),$d$$.ma_tt2&&($query$$.ma_tt2=$d$$.ma_tt2),$d$$.ma_tt3&&($query$$.ma_tt3=$d$$.ma_tt3));ckvt($query$$,function($e$$,$rs$$){if($e$$)return $callback$$($e$$);$rs$$?($e$$=$rs$$.csum("ton"),$rs$$=$data_sokho$$.filter($s$$=>$s$$.ma_vt===$d$$.ma_vt&&$s$$.ma_kho===$ma_kho$$).reduce(($a$$,$b$$)=>($a$$.sl_xuat_qd||0)+($b$$.sl_xuat_qd||0),0),$d$$.sl_xuat_qd>utils.round($e$$+$rs$$,2)?$callback$$(`S\u1ea3n ph\u1ea9m ${$d$$.ma_vt} - ${$d$$.ten_vt} c\u00f3 s\u1ed1 l\u01b0\u1ee3ng xu\u1ea5t quy \u0111\u1ed5i (${$d$$.sl_xuat_qd}) l\u1edbn h\u01a1n s\u1ed1 l\u01b0\u1ee3ng t\u1ed3n quy \u0111\u1ed5i (${$e$$+
|
|
30
30
|
$rs$$})`):$callback$$()):$callback$$()})},$e$$=>{$callback$jscomp$0$$($e$$)})})():$callback$jscomp$0$$()}},$e$$=>{$fn$$($e$$)})}cacheData($obj$$,$callback$$){$obj$$&&$obj$$.toObject&&($obj$$=$obj$$.toObject());redisCache.set(this.model.collection.name.substring(0,this.model.collection.name.length-1),$obj$$,$callback$$)}deleteData($obj$$,$callback$$){$obj$$&&$obj$$.toObject&&($obj$$=$obj$$.toObject());redisCache.remove(this.model.collection.name.substring(0,this.model.collection.name.length-1),$obj$$,
|
|
31
31
|
$callback$$)}createRoute($routeName_url$$,$callback$$,$_options$$={method:"GET"}){let $self$$=this;$_options$$.method=$_options$$.method?$_options$$.method.toUpperCase():"GET";let $r$$=function($req$$,$res$$){!1===$self$$.require_id_app?$callback$$($req$$,function($e$$,$rs$$){if($e$$)return console.error($e$$),$e$$.error?$res$$.status(400).send($e$$):$res$$.status(400).send({error:$e$$.message||$e$$});$res$$.send($rs$$)},$res$$):permission.hasRight($req$$.params.id_app,$req$$.user.email,$self$$.module,
|
|
32
32
|
"view",function($error$$,$hr$$){$hr$$?$callback$$($req$$,function($e$$,$rs$$){if($e$$)return console.error($e$$),$e$$.error?$res$$.status(400).send($e$$):$res$$.status(400).send({error:$e$$.message||$e$$});$res$$.send($rs$$)},$res$$):$res$$.status(403).send({error:$error$$||ERR_NOT_PERMIT,code:ERR_NOT_PERMIT_CODE})},{notNeedRight:$self$$.notNeedRight||$_options$$.notNeedRight})};$routeName_url$$=`${this.route_name}/${$routeName_url$$}`;let $router$$=this.router;"DELETE"==$_options$$.method?$router$$.route($routeName_url$$).delete($r$$):
|
|
33
|
-
"POST"==$_options$$.method?$router$$.route($routeName_url$$).post($r$$):"PUT"==$_options$$.method?$router$$.route($routeName_url$$).put($r$$):$router$$.route($routeName_url$$).get($r$$)}async requestApprove($app_info$$,$user_request$$,$obj_request$$,$next$$,$voucher_options$$){let $ctrl$$=this;if(!$app_info$$)return $next$$(null,$obj_request$$);let $obj$$;$obj$$=$obj_request$$.toObject?$obj_request$$.toObject():_.cloneDeep($obj_request$$);$obj$$.ma_ct=$obj$$.ma_ct||$ctrl$$.name;let $approveDatas$$=
|
|
33
|
+
"POST"==$_options$$.method?$router$$.route($routeName_url$$).post($r$$):"PUT"==$_options$$.method?$router$$.route($routeName_url$$).put($r$$):$router$$.route($routeName_url$$).get($r$$)}async requestApprove($app_info$$,$user_request$$,$obj_request$$,$next$$,$voucher_options$$,$preRequest$$){let $ctrl$$=this;if(!$app_info$$)return $next$$(null,$obj_request$$);let $obj$$;$obj$$=$obj_request$$.toObject?$obj_request$$.toObject():_.cloneDeep($obj_request$$);$obj$$.ma_ct=$obj$$.ma_ct||$ctrl$$.name;let $approveDatas$$=
|
|
34
34
|
[];$voucher_options$$||($voucher_options$$=(await OptionsModel.findOne({id_app:$obj$$.id_app,id_func:$ctrl$$.name},{option:1}).lean()||{}).option);$voucher_options$$&&$voucher_options$$.custom_approve_user&&$voucher_options$$.custom_approve_user.forEach($trang_thai_approve$$=>{let $update_after_approve$$,$update_after_deny$$;if($trang_thai_approve$$.update_after_approve)try{let $str_func$$=$trang_thai_approve$$.update_after_approve;0>$str_func$$.indexOf("return ")&&($str_func$$=`return ${$str_func$$}`);
|
|
35
35
|
$update_after_approve$$=evalute($str_func$$)}catch($e$$){console.error($e$$),$update_after_approve$$={}}else $update_after_approve$$={};$trang_thai_approve$$.update_after_approve={module:$ctrl$$.name,data:{trang_thai:$trang_thai_approve$$.trang_thai2,...($update_after_approve$$.data||{})}};if($trang_thai_approve$$.update_after_deny)try{let $str_func$$=$trang_thai_approve$$.update_after_deny;0>$str_func$$.indexOf("return ")&&($str_func$$=`return ${$str_func$$}`);$update_after_deny$$=evalute($str_func$$)}catch($e$$){console.error($e$$)}if($update_after_deny$$||
|
|
36
36
|
$trang_thai_approve$$.trang_thai3)$trang_thai_approve$$.update_after_deny={module:$ctrl$$.name,data:{trang_thai:$trang_thai_approve$$.trang_thai3,...(($update_after_deny$$||{}).data||{})}};$approveDatas$$.push($trang_thai_approve$$)});$approveDatas$$=$approveDatas$$.filter($approveData_condition$$=>{$approveData_condition$$=$approveData_condition$$.condition;if(!$approveData_condition$$)return!0;$approveData_condition$$.indexOf(!1)&&($approveData_condition$$=`return ${$approveData_condition$$}`);
|
|
37
37
|
try{return evalute($approveData_condition$$,{master:$obj$$,data:$obj$$})}catch($e$$){return console.error("check condition approve",$e$$,$approveData_condition$$),!1}});$approveDatas$$.filter($a$$=>$a$$.approve_users).forEach($approveData$$=>{setImmediate(()=>{let $title$$=$approveData$$.title||"Y\u00eau c\u1ea7u duy\u1ec7t";if(0<=$title$$.indexOf("return ")){var $ds_nguoi_duyet_str_func$$=$title$$;try{$title$$=evalute($ds_nguoi_duyet_str_func$$,{master:$obj$$,data:$obj$$})}catch($e$$){console.error($e$$,
|
|
38
|
-
$ds_nguoi_duyet_str_func$$)}}$ds_nguoi_duyet_str_func$$=$approveData$$.approve_users;let $update_after_approve$$=$approveData$$.update_after_approve,$update_after_deny$$=$approveData$$.update_after_deny;if(_.isString($ds_nguoi_duyet_str_func$$))try{let $str_func$$=$ds_nguoi_duyet_str_func$$;0>$str_func$$.indexOf("return ")&&($str_func$$=`return ${$str_func$$}`);$ds_nguoi_duyet_str_func$$=evalute($str_func$$,{master:$obj$$,data:$obj$$});if(!_.isArray($ds_nguoi_duyet_str_func$$)){console.error("danh s\u00e1ch ng\u01b0\u1eddi duy\u1ec7t ph\u1ea3i l\u00e0 m\u1ed9t m\u1ea3ng, hi\u1ec7n t\u1ea1i \u0111ang l\u00e0",
|
|
39
|
-
$ds_nguoi_duyet_str_func$$);return}}catch($e$$){console.error($e$$,$ds_nguoi_duyet_str_func$$);return}if($approveData$$.approve_users_custom)try{let $str_func$$=$approveData$$.approve_users_custom;0>$str_func$$.indexOf("return ")&&($str_func$$=`return ${$str_func$$}`);let $ds_nguoi_duyet_custom$$=evalute($str_func$$,{master:$obj$$,data:$obj$$});$ds_nguoi_duyet_custom$$&&(_.isArray($ds_nguoi_duyet_custom$$)?$ds_nguoi_duyet_str_func$$=[...$ds_nguoi_duyet_str_func$$,...$ds_nguoi_duyet_custom$$]:
|
|
40
|
-
|
|
41
|
-
Participant,{where:"email",fields:"name"},()=>{Approve.request($user_request$$,$user_approves$$,$title$$,$obj$$,$e$$=>{$e$$&&console.error("error create request approve",$e$$.message)},$update_after_approve$$,$approveData$$.template_content,$update_after_deny$$)})})}})});$next$$(null,$obj$$)}async import($user$$,$id_app$$,$data$$,$callback$jscomp$0
|
|
42
|
-
let $info$$=await $listInfo$$.findOne({code:$ctrl$$.name.toLowerCase()}).lean();$info$$&&await $listInfo$$.updateModel($info$$,$ctrl$$.model);$data$$=$data$$.filter($row$$=>{let $has_data$$=!1;for(let $key$$ in $row$$)if($row$$[$key$$]){$has_data$$=!0;break}return $has_data$$});$data$$.forEach($r$$=>{delete $r$$.ten_dvcs});await $data$$.filter($r
|
|
43
|
-
Object.keys($row$$);$row_keys$$.filter($key$$=>$ctrl$$.model.schema.paths[$key$$]).forEach($key$$=>{let $data_type$$=$ctrl$$.model.schema.paths[$key$$].instance.toLowerCase(),$data_value$$=$row$$[$key$$];if($data_value$$&&_.isString($data_value$$)&&("mixed"==$data_type$$||"array"==$data_type$$)&&($data_value$$=$data_value$$.trim(),
|
|
44
|
-
$e$$)}});setImmediate(()=>{delete $row$$.__v;$row$$.ma_dvcs&&!$row$$.ten_dvcs&&delete $row$$.ma_dvcs;$row$$.id_app&&$id_app$$!=$row$$.id_app&&delete $row$$._id;delete $row$$.id_app;if($replace$$&&($ctrl$$.unique&&0<$ctrl$$.unique.length||$row$$._id)){let $query$$={};$row$$._id?$query$$._id=$row$$._id:(0!=$ctrl$$.require_id_app&&
|
|
45
|
-
$row_keys$$.indexOf($k$$)&&($query$$[$k$$]=$row$$[$k$$])}));$ctrl$$.model.find($query$$).lean().exec(function($error$$,$rss$$){if(1<$rss$$.length)return $callback$$("Kh\u00f4ng th\u1ec3 c\u1eadp nh\u1eadt \u0111\u1ed1i t\u01b0\u1ee3ng:"+Object.values($query$$).join("-"));setImmediate(()=>{if($error$$)return $callback$$($error$$);
|
|
46
|
-
$ctrl$$,$rs$$._id,$row$$,function($e$$){if($e$$){let $_e$$=$e$$;underscore.isArray($_e$$)||($_e$$=[$e$$]);$rows_error$$.push({row:$row$$,error:"Error update data:"+$_e$$})}$callback$$()},"import",$options$$.req)}else create($user$$,$ctrl$$,$row$$,function($e$$){if($e$$){let $_e$$=$e$$;underscore.isArray($_e$$)||($_e$$=
|
|
47
|
-
$e$$;underscore.isArray($_e$$)||($_e$$=[$e$$]);$rows_error$$.push({row:$row$$,error:$_e$$})}$callback$$()})},$row$$._id,$options$$.req)})},function($error$$){setImmediate(()=>{console.log("finish import...");if($error$$)return $callback$jscomp$0$$($error$$);0===$rows_error$$.length?$callback$jscomp$0$$(null,{rows_imported:$data$$.length,
|
|
38
|
+
$ds_nguoi_duyet_str_func$$)}}$ds_nguoi_duyet_str_func$$=$approveData$$.approve_users;let $update_after_approve$$=$approveData$$.update_after_approve,$update_after_deny$$=$approveData$$.update_after_deny;if(_.isString($ds_nguoi_duyet_str_func$$))try{let $str_func$$=$ds_nguoi_duyet_str_func$$;0>$str_func$$.indexOf("return ")&&($str_func$$=`return ${$str_func$$}`);$ds_nguoi_duyet_str_func$$=evalute($str_func$$,{master:$obj$$,data:$obj$$,preRequest:$preRequest$$});if(!_.isArray($ds_nguoi_duyet_str_func$$)){console.error("danh s\u00e1ch ng\u01b0\u1eddi duy\u1ec7t ph\u1ea3i l\u00e0 m\u1ed9t m\u1ea3ng, hi\u1ec7n t\u1ea1i \u0111ang l\u00e0",
|
|
39
|
+
$ds_nguoi_duyet_str_func$$);return}}catch($e$$){console.error($e$$,$ds_nguoi_duyet_str_func$$);return}if($approveData$$.approve_users_custom)try{let $str_func$$=$approveData$$.approve_users_custom;0>$str_func$$.indexOf("return ")&&($str_func$$=`return ${$str_func$$}`);let $ds_nguoi_duyet_custom$$=evalute($str_func$$,{master:$obj$$,data:$obj$$,preRequest:$preRequest$$});$ds_nguoi_duyet_custom$$&&(_.isArray($ds_nguoi_duyet_custom$$)?$ds_nguoi_duyet_str_func$$=[...$ds_nguoi_duyet_str_func$$,...$ds_nguoi_duyet_custom$$]:
|
|
40
|
+
console.error("danh s\u00e1ch ng\u01b0\u1eddi duy\u1ec7t ph\u1ea3i l\u00e0 m\u1ed9t m\u1ea3ng, hi\u1ec7n t\u1ea1i \u0111ang l\u00e0",$ds_nguoi_duyet_custom$$))}catch($e$$){console.error($e$$,$approveData$$.approve_users_custom)}if($ds_nguoi_duyet_str_func$$&&0!==$ds_nguoi_duyet_str_func$$.length&&($ds_nguoi_duyet_str_func$$=[...(new Set($ds_nguoi_duyet_str_func$$))],$obj$$.trang_thai==$approveData$$.trang_thai)){let $user_approves$$=$ds_nguoi_duyet_str_func$$.map($nguoi_duyet$$=>({email:$nguoi_duyet$$,
|
|
41
|
+
name:$nguoi_duyet$$}));$user_approves$$.joinModel2($obj$$.id_app,Participant,{where:"email",fields:"name"},()=>{[$user_request$$].joinModel2($obj$$.id_app,Participant,{where:"email",fields:"name"},()=>{Approve.request($user_request$$,$user_approves$$,$title$$,$obj$$,$e$$=>{$e$$&&console.error("error create request approve:",$e$$.message||$e$$)},$update_after_approve$$,$approveData$$.template_content,$update_after_deny$$)})})}})});$next$$(null,$obj$$)}async import($user$$,$id_app$$,$data$$,$callback$jscomp$0$$,
|
|
42
|
+
$options$$={replace:!0,req:null}){const $ctrl$$=this;let $replace$$=$options$$.replace,$rows_error$$=[];const $listInfo$$=global.getModel("listinfo");let $info$$=await $listInfo$$.findOne({code:$ctrl$$.name.toLowerCase()}).lean();$info$$&&await $listInfo$$.updateModel($info$$,$ctrl$$.model);$data$$=$data$$.filter($row$$=>{let $has_data$$=!1;for(let $key$$ in $row$$)if($row$$[$key$$]){$has_data$$=!0;break}return $has_data$$});$data$$.forEach($r$$=>{delete $r$$.ten_dvcs});await $data$$.filter($r$$=>
|
|
43
|
+
$r$$.ma_dvcs).asyncJoinModel2($id_app$$,global.getModel("dvcs"),{where:{ma_dvcs:"_id"},fields:"ten_dvcs"});async.mapSeries($data$$,function($row$$,$callback$$){const $row_keys$$=Object.keys($row$$);$row_keys$$.filter($key$$=>$ctrl$$.model.schema.paths[$key$$]).forEach($key$$=>{let $data_type$$=$ctrl$$.model.schema.paths[$key$$].instance.toLowerCase(),$data_value$$=$row$$[$key$$];if($data_value$$&&_.isString($data_value$$)&&("mixed"==$data_type$$||"array"==$data_type$$)&&($data_value$$=$data_value$$.trim(),
|
|
44
|
+
0==$data_value$$.indexOf("[")||0==$data_value$$.indexOf("{")))try{$row$$[$key$$]=JSONParser($data_value$$)}catch($e$$){delete $row$$[$key$$],console.error("Error parse data",$e$$)}});setImmediate(()=>{delete $row$$.__v;$row$$.ma_dvcs&&!$row$$.ten_dvcs&&delete $row$$.ma_dvcs;$row$$.id_app&&$id_app$$!=$row$$.id_app&&delete $row$$._id;delete $row$$.id_app;if($replace$$&&($ctrl$$.unique&&0<$ctrl$$.unique.length||$row$$._id)){let $query$$={};$row$$._id?$query$$._id=$row$$._id:(0!=$ctrl$$.require_id_app&&
|
|
45
|
+
($query$$.id_app=$id_app$$),$ctrl$$.options.unique_imp&&$row$$[$ctrl$$.options.unique_imp]?$query$$[$ctrl$$.options.unique_imp]=$row$$[$ctrl$$.options.unique_imp]:$ctrl$$.unique.forEach(function($k$$){0<=$row_keys$$.indexOf($k$$)&&($query$$[$k$$]=$row$$[$k$$])}));$ctrl$$.model.find($query$$).lean().exec(function($error$$,$rss$$){if(1<$rss$$.length)return $callback$$("Kh\u00f4ng th\u1ec3 c\u1eadp nh\u1eadt \u0111\u1ed1i t\u01b0\u1ee3ng:"+Object.values($query$$).join("-"));setImmediate(()=>{if($error$$)return $callback$$($error$$);
|
|
46
|
+
if(1===$rss$$.length){let $rs$$=$rss$$[0];$row$$.id_app=$rs$$.id_app;$row$$._id=$rs$$._id.toString();$ctrl$$.unique.forEach(function($k$$){$row$$[$k$$]=$rs$$[$k$$]});update($user$$,$ctrl$$,$rs$$._id,$row$$,function($e$$){if($e$$){let $_e$$=$e$$;underscore.isArray($_e$$)||($_e$$=[$e$$]);$rows_error$$.push({row:$row$$,error:"Error update data:"+$_e$$})}$callback$$()},"import",$options$$.req)}else create($user$$,$ctrl$$,$row$$,function($e$$){if($e$$){let $_e$$=$e$$;underscore.isArray($_e$$)||($_e$$=
|
|
47
|
+
[$e$$]);$rows_error$$.push({row:$row$$,error:$_e$$})}$callback$$()},$row$$._id,$options$$.req)})})}else create($user$$,$ctrl$$,$row$$,function($e$$){setImmediate(()=>{if($e$$){let $_e$$=$e$$;underscore.isArray($_e$$)||($_e$$=[$e$$]);$rows_error$$.push({row:$row$$,error:$_e$$})}$callback$$()})},$row$$._id,$options$$.req)})},function($error$$){setImmediate(()=>{console.log("finish import...");if($error$$)return $callback$jscomp$0$$($error$$);0===$rows_error$$.length?$callback$jscomp$0$$(null,{rows_imported:$data$$.length,
|
|
48
|
+
rows_error:[]}):$callback$jscomp$0$$(null,{rows_imported:$data$$.length-$rows_error$$.length,rows_error:$rows_error$$})})})}}controller.prototype.__proto__=EventEmitter.prototype;
|
|
48
49
|
const getNextSequence=async function($id_app$$,$ma_ct$$,$field$$,$callback$$,$options$$={}){var $condition_qct_qcts$$={status:!0,field:$field$$,id_app:$id_app$$,$and:[{$or:[{ma_ct:"#",ma_ct_khac:{$regex:$ma_ct$$,$options:"i"}},{cac_ma_ct:$ma_ct$$.toLowerCase()},{ma_ct:$ma_ct$$.toUpperCase()}]}]};$options$$.id_qct&&($condition_qct_qcts$$._id=$options$$.id_qct);if($options$$.ngay_ct){let $start_date$$=moment($options$$.ngay_ct).startOf("date").toDate(),$end_date$$=moment($options$$.ngay_ct).endOf("date").toDate();
|
|
49
50
|
$condition_qct_qcts$$.$and.push({$or:[{tu_ngay:null},{tu_ngay:{$lte:$end_date$$}}]});$condition_qct_qcts$$.$and.push({$or:[{den_ngay:null},{den_ngay:{$gte:$start_date$$}}]})}$options$$.toObject&&($options$$=$options$$.toObject());$condition_qct_qcts$$=await dmqct.find($condition_qct_qcts$$).lean();const $keys$$=Object.keys($options$$),$qct$$=$condition_qct_qcts$$.find($qct$$=>{if($qct$$.dieu_kien&&0<$keys$$.length)try{let $str_func$$=$qct$$.dieu_kien;if(0<=$str_func$$.indexOf("async "))return!1;0!==
|
|
50
51
|
$str_func$$.indexOf("return ")&&($str_func$$=`return ${$str_func$$}`);return evalute($str_func$$,{...$options$$,master:{...$options$$},moment,numeral})}catch($e$$){return console.error("Error find quyen chung tu",$e$$,$qct$$.dieu_kien),!1}else return!0});let $code$$=$qct$$?$qct$$._id.toString():$field$$;counter.getNextSequence($id_app$$,$ma_ct$$,$code$$,async function($error$$,$rs$$){if($error$$)console.error("auto create code for",$ma_ct$$,$code$$,$error$$),$callback$$($error$$);else{if($qct$$){let $tien_to$$=
|
|
@@ -267,32 +268,33 @@ null,$req$$)};this.router.route(`${this.route_name}/quickcreate/:template_code`)
|
|
|
267
268
|
const update=async function($user$jscomp$0$$,$ctrl$$,$id$$,$data$jscomp$0$$,$callback$jscomp$1$$,$action$jscomp$0$$,$req$$){delete $data$jscomp$0$$.__v;try{const $model$$=$ctrl$$.model,$unique$$=$ctrl$$.unique,$module$$=$ctrl$$.module,$schema_paths$$=$model$$.schema.paths;underscore.has($schema_paths$$,"ma_ct")&&$ctrl$$.options.isVoucher&&($data$jscomp$0$$.ma_ct=$ctrl$$.name.toUpperCase());delete $data$jscomp$0$$.session_updated;delete $data$jscomp$0$$.session_created;$req$$&&underscore.has($schema_paths$$,
|
|
268
269
|
"session_updated")&&($data$jscomp$0$$.session_updated=($req$$.cookies||{}).uid);const $voucher_options$$=(await OptionsModel.findOne({id_app:$user$jscomp$0$$.current_id_app,id_func:$ctrl$$.name}).lean()||{}).option;let $current_obj$$;if($ctrl$$.options.requireRecaptchaToken&&configs.GOOGLE_RECAPTCHA_SECRET_KEY){if(!$data$jscomp$0$$["g-recaptcha-response"])return $callback$jscomp$1$$("Ch\u1ee9c n\u0103ng n\u00e0y y\u00eau c\u1ea7u g-recaptcha-response");try{await permission.verifyReCaptcha($data$jscomp$0$$["g-recaptcha-response"])}catch($e$$){return $callback$jscomp$1$$($e$$.message||
|
|
269
270
|
$e$$.error||$e$$)}}let $requireOtp$$=$ctrl$$.options.requireOtp;$requireOtp$$&&_.isFunction($requireOtp$$)&&($requireOtp$$=$requireOtp$$($data$jscomp$0$$,{action:"update",_id:$id$$,user:$user$jscomp$0$$}));if($requireOtp$$)try{await permission.verifyOTP($user$jscomp$0$$.email,$data$jscomp$0$$["otp-id"],$data$jscomp$0$$["otp-code"])}catch($e$$){return $callback$jscomp$1$$({error:$e$$.message||$e$$.error||$e$$,code:ERR_VERIFY_OTP})}async.waterfall([function($callback$$){setImmediate(function(){$model$$.findOne({_id:$id$$}).exec(function($error$$,
|
|
270
|
-
$obj$$){setImmediate(async()=>{if($error$$)return $callback$$($error$$);if(!$obj$$)return $callback$$("Kh\u00f4ng th\u1ec3 t\u00ecm th\u1ea5y \u0111\u1ed1i t\u01b0\u1ee3ng n\u00e0y");if($
|
|
271
|
-
$e$$.error||$e$$)}underscore.has($schema_paths$$,"exfields")&&($obj$$.exfields=$obj$$.exfields||{})
|
|
272
|
-
function($error$$,$hr$$,$c_app$$){setImmediate(()=>{if($hr$$)$ctrl$$.checkData($c_app$$,{...$data$jscomp$0$$,_id:$obj$$._id.toString()},$e$$=>{if($e$$)return $callback$$($e$$);$callback$$(null
|
|
273
|
-
$data$jscomp$0$$.so_ct&&$obj$$.so_ct!==$data$jscomp$0$$.so_ct?OptionsModel.findOne({id_app:$obj$$.id_app,id_func:$ctrl$$.name},{option:1}).lean().exec(($e$jscomp$0$$,$rs$jscomp$0$$)=>
|
|
274
|
-
|
|
275
|
-
moment($date_check_den_ngay$$).startOf("
|
|
276
|
-
{setImmediate(()=>{if($rs$$)return $callback$$("S\u1ed1 ch\u1ee9ng t\u1eeb "+$data$jscomp$0$$.so_ct+" \u0111\u00e3 t\u1ed3n t\u1ea1i. H\u00e3y ch\u1ecdn m\u1ed9t s\u1ed1 ch\u1ee9ng t\u1eeb kh\u00e1c")
|
|
277
|
-
$
|
|
278
|
-
$
|
|
279
|
-
$callback$jscomp$0
|
|
280
|
-
$c2$$[$key$$]
|
|
281
|
-
$
|
|
282
|
-
$callback$$(
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
$
|
|
286
|
-
function($
|
|
287
|
-
{$
|
|
288
|
-
|
|
289
|
-
0
|
|
290
|
-
|
|
291
|
-
$
|
|
292
|
-
|
|
293
|
-
$
|
|
294
|
-
$
|
|
295
|
-
|
|
271
|
+
$obj$$){setImmediate(async()=>{if($error$$)return $callback$$($error$$);if(!$obj$$)return $callback$$("Kh\u00f4ng th\u1ec3 t\u00ecm th\u1ea5y \u0111\u1ed1i t\u01b0\u1ee3ng n\u00e0y");$data$jscomp$0$$.trang_thai&&($data$jscomp$0$$.trang_thai=$data$jscomp$0$$.trang_thai.toString());if($data$jscomp$0$$.trang_thai||$obj$$.trang_thai){var $old_obj$$={id_ct:$obj$$._id.toString(),user_approved:{$exists:!0}};$old_obj$$.trang_thai=$data$jscomp$0$$.trang_thai||$obj$$.trang_thai;if(await Approve.findOne($old_obj$$))return $callback$$("Kh\u00f4ng th\u1ec3 c\u1eadp nh\u1eadt ch\u1ee9ng t\u1eeb \u1edf tr\u1ea1ng th\u00e1i n\u00e0y do n\u00f3 \u0111\u00e3 \u0111\u01b0\u1ee3c duy\u1ec7t")}if($obj$$.ngay_ct&&
|
|
272
|
+
$obj$$.id_app&&$obj$$.schema&&$obj$$.schema.validate&&$obj$$.schema.validate.ngay_ct)try{await new Promise(($rs$$,$rj$$)=>{validator.unlockBook[0]($obj$$.id_app,$obj$$.ngay_ct,$unlock$$=>{if(!$unlock$$)return $rj$$(validator.unlockBook[1]);$rs$$($unlock$$)},$voucher_options$$)})}catch($e$$){return $callback$$($e$$.message||$e$$.error||$e$$)}underscore.has($schema_paths$$,"exfields")&&($obj$$.exfields=$obj$$.exfields||{});$old_obj$$=$obj$$.toObject();$current_obj$$=_.cloneDeep($old_obj$$);const $data_keys$$=
|
|
273
|
+
Object.keys($data$jscomp$0$$);for(let $key$$ in $old_obj$$)0>$data_keys$$.indexOf($key$$)&&($data$jscomp$0$$[$key$$]=$old_obj$$[$key$$]);$callback$$(null,$obj$$)})})})},function($obj$$,$callback$$){setImmediate(function(){permission.hasRight($user$jscomp$0$$.current_id_app,$user$jscomp$0$$.email,$module$$,"update",function($error$$,$hr$$,$c_app$$){setImmediate(()=>{if($hr$$)$ctrl$$.checkData($c_app$$,{...$data$jscomp$0$$,_id:$obj$$._id.toString()},$e$$=>{if($e$$)return $callback$$($e$$);$callback$$(null,
|
|
274
|
+
$obj$$)});else return $callback$$({error:$error$$||ERR_NOT_PERMIT,code:ERR_NOT_PERMIT_CODE})})},{data:$data$jscomp$0$$,obj:$obj$$,notNeedRight:$ctrl$$.options.notNeedRight})})},function($obj$$,$callback$$){underscore.has($model$$.schema.paths,"ngay_ct")&&underscore.has($model$$.schema.paths,"so_ct")&&$obj$$.ngay_ct&&$data$jscomp$0$$.so_ct&&$obj$$.so_ct!==$data$jscomp$0$$.so_ct?OptionsModel.findOne({id_app:$obj$$.id_app,id_func:$ctrl$$.name},{option:1}).lean().exec(($e$jscomp$0$$,$rs$jscomp$0$$)=>
|
|
275
|
+
{setImmediate(()=>{if($rs$jscomp$0$$&&$rs$jscomp$0$$.option&&$rs$jscomp$0$$.option.check_so_ct&&"0"!==$rs$jscomp$0$$.option.check_so_ct){let $query_check$$={id_app:$obj$$.id_app,so_ct:$data$jscomp$0$$.so_ct,_id:{$ne:$obj$$._id.toString()}},$tu_ngay$$;var $date_check_den_ngay$$=$data$jscomp$0$$.ngay_ct||$obj$$.ngay_ct;switch($rs$jscomp$0$$.option.check_so_ct){case "1":$tu_ngay$$=moment($date_check_den_ngay$$).startOf("date").toDate();$date_check_den_ngay$$=moment($date_check_den_ngay$$).endOf("date").toDate();
|
|
276
|
+
$query_check$$.ngay_ct={$gte:$tu_ngay$$,$lte:$date_check_den_ngay$$};break;case "2":$tu_ngay$$=moment($date_check_den_ngay$$).startOf("month").toDate();$date_check_den_ngay$$=moment($date_check_den_ngay$$).endOf("month").toDate();$query_check$$.ngay_ct={$gte:$tu_ngay$$,$lte:$date_check_den_ngay$$};break;case "3":$tu_ngay$$=moment($date_check_den_ngay$$).startOf("quarter").toDate();$date_check_den_ngay$$=moment($date_check_den_ngay$$).endOf("quarter").toDate();$query_check$$.ngay_ct={$gte:$tu_ngay$$,
|
|
277
|
+
$lte:$date_check_den_ngay$$};break;case "8":$tu_ngay$$=moment($date_check_den_ngay$$).startOf("year").toDate(),$date_check_den_ngay$$=moment($date_check_den_ngay$$).startOf("year").toDate(),$query_check$$.ngay_ct={$gte:$tu_ngay$$,$lte:$date_check_den_ngay$$}}$model$$.findOne($query_check$$,{so_ct:1}).lean().exec(($e$$,$rs$$)=>{setImmediate(()=>{if($rs$$)return $callback$$("S\u1ed1 ch\u1ee9ng t\u1eeb "+$data$jscomp$0$$.so_ct+" \u0111\u00e3 t\u1ed3n t\u1ea1i. H\u00e3y ch\u1ecdn m\u1ed9t s\u1ed1 ch\u1ee9ng t\u1eeb kh\u00e1c");
|
|
278
|
+
$callback$$(null,$obj$$)})})}else $callback$$(null,$obj$$)})}):$callback$$(null,$obj$$)},($obj$jscomp$0$$,$callback$jscomp$0$$)=>{(async($obj$$,$callback$$)=>{try{(await permission.getFieldNotRight($obj$$.id_app,$user$jscomp$0$$.email,$ctrl$$.name)).forEach($f$$=>{delete $data$jscomp$0$$[$f$$]})}catch($e$$){console.error("Error get field not right",$e$$)}setImmediate(function(){$ctrl$$.updating?$ctrl$$.updating($user$jscomp$0$$,$data$jscomp$0$$,$obj$$,function($error$jscomp$0$$,$_data$jscomp$0$$,
|
|
279
|
+
$_obj$$){setImmediate(()=>{if($error$jscomp$0$$)return $callback$$($error$jscomp$0$$);if($ctrl$$.dynamicUpdating)$ctrl$$.dynamicUpdating($user$jscomp$0$$,$_data$jscomp$0$$,$_obj$$,function($error$$,$_data$$){if($error$$)return $callback$$($error$$);for(let $f$$ in $_data$$)underscore.has($schema_paths$$,$f$$)&&($data$jscomp$0$$[$f$$]=$_data$$[$f$$]);$callback$$(null,$obj$$)});else{for(let $f$$ in $_data$jscomp$0$$)underscore.has($schema_paths$$,$f$$)&&($data$jscomp$0$$[$f$$]=$_data$jscomp$0$$[$f$$]);
|
|
280
|
+
$callback$$(null,$obj$$)}})}):$ctrl$$.dynamicUpdating?$ctrl$$.dynamicUpdating($user$jscomp$0$$,$data$jscomp$0$$,$obj$$,function($error$$,$_data$$){if($error$$)return $callback$$($error$$);for(let $f$$ in $_data$$)underscore.has($schema_paths$$,$f$$)&&($data$jscomp$0$$[$f$$]=$_data$$[$f$$]);$callback$$(null,$obj$$)}):$callback$$(null,$obj$$)})})($obj$jscomp$0$$,$callback$jscomp$0$$)},function($obj$$,$callback$$){setImmediate(function(){if(!$unique$$||0===$unique$$.length)return $callback$$(null,$obj$$);
|
|
281
|
+
let $c1$$={},$c2$$={};$obj$$.id_app&&($c1$$.id_app=$obj$$.id_app,$c2$$.id_app||($c2$$.id_app=$obj$$.id_app));$unique$$.forEach(function($key$$){$c1$$[$key$$]=$obj$$[$key$$];$ctrl$$.model.schema.paths[$key$$]?("number"==$ctrl$$.model.schema.paths[$key$$].instance.toLowerCase()?$c2$$[$key$$]=Number($data$jscomp$0$$[$key$$]):"date"==$ctrl$$.model.schema.paths[$key$$].instance.toLowerCase()?$c2$$[$key$$]=new Date($data$jscomp$0$$[$key$$]):"string"==$ctrl$$.model.schema.paths[$key$$].instance.toLowerCase()?
|
|
282
|
+
$c2$$[$key$$]=($data$jscomp$0$$[$key$$]||"").toString():$c2$$[$key$$]=$data$jscomp$0$$[$key$$],$c2$$[$key$$]||($c2$$[$key$$]=$c1$$[$key$$])):console.error("field",$key$$," is not exist. please check unique of controller")});!0!==underscore.isEqual($c1$$,$c2$$)?isExists($model$$,$unique$$,$c2$$,$ctrl$$.replaceIfExists,function($error$jscomp$0$$,$kq$$){setImmediate(()=>{if($error$jscomp$0$$||$kq$$){let $msgError$$=$error$jscomp$0$$||ERR_ALREADY_EXIST;if($ctrl$$.options.onErrorUpdating)$ctrl$$.options.onErrorUpdating($user$jscomp$0$$,
|
|
283
|
+
$obj$$,$e$$=>{$e$$&&($msgError$$=$msgError$$+"\n"+$e$$);$callback$$($msgError$$)},$current_obj$$);else $callback$$($msgError$$)}else checkReference($model$$,$obj$$,function($error$$){setImmediate(()=>{if($error$$)return console.error("Keys arise data",$c1$$,$c2$$,$error$$),$callback$$({error:ERR_KEY_ARISE+($error$$.error||$error$$.message||$error$$),code:ERR_KEY_ARISE_CODE});$callback$$(null,$obj$$)})},$unique$$)})}):$callback$$(null,$obj$$)})},function($obj$$,$callback$$){let $keys$$=underscore.keys($model$$.referenceKeys).filter($key$$=>
|
|
284
|
+
"_id"!==$key$$);$unique$$&&($keys$$=$keys$$.filter($key$$=>0>$unique$$.indexOf($key$$).length));if(0===$keys$$.length)return $callback$$(null,$obj$$);checkReference($model$$,$obj$$,function($msgError$$){setImmediate(()=>{if($msgError$$)if($ctrl$$.options.onErrorUpdating)$ctrl$$.options.onErrorUpdating($user$jscomp$0$$,$obj$$,$e$$=>{$e$$&&($msgError$$=$msgError$$+"\n"+$e$$);$callback$$($msgError$$)},$current_obj$$);else $callback$$({error:ERR_ARISE+($msgError$$.error||$msgError$$.message||$msgError$$),
|
|
285
|
+
code:ERR_ARISE_CODE});else $callback$$(null,$obj$$)})},$keys$$)},function($obj$jscomp$1$$,$callback$$){$ctrl$$.validating||($ctrl$$.validating=($user$$,$obj$$,$next$$)=>{$next$$(null,$obj$$)});$ctrl$$.validating($user$jscomp$0$$,$obj$jscomp$1$$,($error$$,$obj$jscomp$0$$)=>{if($error$$)return $callback$$($error$$);setImmediate(function(){$data$jscomp$0$$.date_updated=new Date;$data$jscomp$0$$.user_updated=$user$jscomp$0$$.email;delete $data$jscomp$0$$.__v;$ctrl$$.options.onUpdateExtending||($ctrl$$.options.onUpdateExtending=
|
|
286
|
+
function($obj$$,$data$$,$action$$,$fn$$){$fn$$()});$ctrl$$.options.onUpdateExtending($obj$jscomp$0$$,$data$jscomp$0$$,$action$jscomp$0$$,function(){underscore.has($schema_paths$$,"exfields")&&$data$jscomp$0$$.exfields&&($obj$jscomp$0$$.exfields=$data$jscomp$0$$.exfields);delete $data$jscomp$0$$.__v;for(let $f$$ in $data$jscomp$0$$)underscore.has($schema_paths$$,$f$$)&&"_id"!==$f$$&&($obj$jscomp$0$$.set($f$$,$data$jscomp$0$$[$f$$]),"exfields"!==$f$$||$obj$jscomp$0$$.exfields||($obj$jscomp$0$$.exfields=
|
|
287
|
+
{}));validate($obj$jscomp$0$$,function($msgError$$){setImmediate(()=>{if($msgError$$)if($ctrl$$.options.onErrorUpdating)$ctrl$$.options.onErrorUpdating($user$jscomp$0$$,$obj$jscomp$0$$,$e$$=>{$e$$&&($msgError$$=$msgError$$+"\n"+$e$$);$callback$$($msgError$$)},$current_obj$$);else $callback$$($msgError$$);else $callback$$(null,$obj$jscomp$0$$)})},$voucher_options$$)})})})},function($obj$$,$callback$$){$current_obj$$&&($obj$$._id=$current_obj$$._id);deletePost($user$jscomp$0$$,$obj$$,async $e$$=>{$callback$$($e$$,
|
|
288
|
+
$obj$$)})},function($obj$$,$callback$$){setImmediate(async()=>{$obj$$.ngay_ct&&($obj$$.ngay_ct=moment($obj$$.ngay_ct).toDate());for(var $$condition_k$$ in $ctrl$$.keyValues)$obj$$[$$condition_k$$]=$ctrl$$.keyValues[$$condition_k$$];Object.keys($model$$.schema.paths).filter($model_path$$=>$obj$$[$model_path$$]&&underscore.isArray($obj$$[$model_path$$])).forEach($model_path$$=>{$model$$.schema.paths[$model_path$$].schema&&$model$$.schema.paths[$model_path$$].schema.paths&&Object.keys($model$$.schema.paths[$model_path$$].schema.paths).filter($path$$=>
|
|
289
|
+
"line"!==$path$$&&"_id"!==$path$$&&"__v"!==$path$$&&0<=fields_sync_master_detail.indexOf($path$$)).forEach($path$$=>{$obj$$[$path$$]&&$obj$$[$model_path$$].filter($detail$$=>!$detail$$[$path$$]).forEach($detail$$=>{$detail$$[$path$$]=$obj$$[$path$$]})})});await createIdRef($model$$,$obj$$);$ctrl$$.saving&&await $ctrl$$.saving($user$jscomp$0$$,$obj$$);$ctrl$$.emit("saving",$obj$$);$current_obj$$&&($obj$$._id=$current_obj$$._id);let $obj_created$$,$error$jscomp$0$$;$data$jscomp$0$$.$condition&&($$condition_k$$=
|
|
290
|
+
$data$jscomp$0$$.$condition,$$condition_k$$._id=$obj$$._id,await $model$$.findOne($$condition_k$$)||($error$jscomp$0$$=ERR_CAN_NOT_UPDATE),delete $data$jscomp$0$$.$condition);if(!$error$jscomp$0$$)try{delete $obj$$.__v,$obj_created$$=await $obj$$.save()}catch($e$$){$error$jscomp$0$$=$e$$}if($error$jscomp$0$$){let $msgErrors$$=[];for(let $k$$ in $error$jscomp$0$$.errors)$msgErrors$$.push($error$jscomp$0$$.errors[$k$$].message);0==$msgErrors$$.length&&($msgErrors$$=$error$jscomp$0$$.message);$msgErrors$$||
|
|
291
|
+
($msgErrors$$=JSON.stringify($error$jscomp$0$$));if($ctrl$$.options.onErrorUpdating)$ctrl$$.options.onErrorUpdating($user$jscomp$0$$,$obj$$,$e$$=>{$e$$&&console.error("onErrorUpdating",$e$$);$callback$$({error:$msgErrors$$,code:ERR_CAN_NOT_UPDATE_CODE})},$current_obj$$);else $callback$$({error:$msgErrors$$,code:ERR_CAN_NOT_UPDATE_CODE})}else $req$$&&$req$$.header&&setImmediate(()=>{log.create({id_app:$user$jscomp$0$$.current_id_app,id_func:$ctrl$$.name,action:"UPDATE",data:{oldData:$current_obj$$,
|
|
292
|
+
newData:$data$jscomp$0$$,id:$obj$$._id.toString()}},$user$jscomp$0$$.email,$req$$.header("user-agent"),$req$$)}),postData($obj_created$$,$ctrl$$,function($msgError$$){$msgError$$?setImmediate(()=>{$current_obj$$&&$model$$.findByIdAndUpdate($current_obj$$._id,{$set:$current_obj$$},function($err$$,$restore_data$$){if($err$$||!$restore_data$$)return console.error("can't restore voucher",$err$$||": don't find voucher");console.log("restored data of voucher. posting...");$model$$.findById($current_obj$$._id,
|
|
293
|
+
($e$jscomp$0$$,$_d$$)=>{if(!$_d$$)return console.error("Don't find voucher",$current_obj$$._id);postData($_d$$,$ctrl$$,function($e$$){if($e$$)return console.error("can't repost voucher",$e$$);console.log("reposted voucher",$_d$$._id)},{req:$req$$})})});if($ctrl$$.options.onErrorUpdating)$ctrl$$.options.onErrorUpdating($user$jscomp$0$$,$obj$$,$e$$=>{$e$$&&($msgError$$=$msgError$$+"\n"+$e$$);$callback$$($msgError$$)},$current_obj$$);else $callback$$($msgError$$)}):setImmediate(()=>{$ctrl$$.emit("saved",
|
|
294
|
+
$obj_created$$);$ctrl$$.emit("updated",$obj_created$$);$obj_created$$=$obj_created$$.toObject();runWebhooks($ctrl$$,$obj_created$$,"UPDATE",$voucher_options$$);$ctrl$$.cacheData($obj_created$$);if($req$$&&!1!==$req$$.query.return_data)$ctrl$$.onView($user$jscomp$0$$,[$obj_created$$],function($error$$,$viewValue$$){setImmediate(()=>{if($error$$)return $callback$$($error$$);$req$$&&pushNotification($ctrl$$,$viewValue$$[0],"update",$current_obj$$,null,{exclude_token:$req$$.query.access_token});$callback$$(null,
|
|
295
|
+
$viewValue$$[0])})},{req:$req$$});else $callback$$(null,{_id:$obj_created$$._id})})},{req:$req$$})})},function($obj$$,$callback$$){$ctrl$$.requestApprove($user$jscomp$0$$.current_app_info,$user$jscomp$0$$,$obj$$,$callback$$,$voucher_options$$)},function($obj$jscomp$0$$,$callback$$){void 0!=$obj$jscomp$0$$.trang_thai&&setImmediate(async()=>{Approve.findOne({id_ct:$obj$jscomp$0$$._id.toString(),"update_after_approve.data.trang_thai":$obj$jscomp$0$$.trang_thai.toString()}).lean().exec(($e$$,$rs$$)=>
|
|
296
|
+
{!$rs$$||$rs$$.user_approved||$rs$$.user_denied||($rs$$.user_approved=$req$$.user.email,$rs$$.user_approved_name=$req$$.user.name,$rs$$.date_approved=new Date,Approve.updateOne({_id:$rs$$._id},$rs$$).then(()=>{Approve.sendNotifyApproved($rs$$,$req$$.query.access_token)}))})});setImmediate(async()=>{(await permission.getFieldNotRight($obj$jscomp$0$$.id_app,$user$jscomp$0$$.email,$ctrl$$.name)).forEach($f$$=>{delete $obj$jscomp$0$$[$f$$]});$obj$jscomp$0$$.collection_name=$ctrl$$.collection_name;$ctrl$$.updated?
|
|
297
|
+
$ctrl$$.updated($user$jscomp$0$$,$obj$jscomp$0$$,function($error$jscomp$0$$,$obj$$){if($error$jscomp$0$$)return console.error("error when saved",$error$jscomp$0$$),$callback$$($error$jscomp$0$$);$ctrl$$.dynamicUpdated?$ctrl$$.dynamicUpdated($user$jscomp$0$$,$obj$$,function($error$$){if($error$$)return $callback$$($error$$);$callback$$(null,$obj$$)}):$callback$$(null,$obj$$)},$current_obj$$):$ctrl$$.dynamicUpdated?$ctrl$$.dynamicUpdated($user$jscomp$0$$,$obj$jscomp$0$$,function($error$$){if($error$$)return $callback$$($error$$);
|
|
296
298
|
$callback$$(null,$obj$jscomp$0$$)}):$callback$$(null,$obj$jscomp$0$$)})}],($e$jscomp$174_name_cached$$,$rs$$)=>{$e$jscomp$174_name_cached$$?(console.error($e$jscomp$174_name_cached$$),$callback$jscomp$1$$($e$jscomp$174_name_cached$$)):($e$jscomp$174_name_cached$$=$model$$.collection.name,$user$jscomp$0$$.current_id_app&&($e$jscomp$174_name_cached$$+=$user$jscomp$0$$.current_id_app),delete global.cacheDatas[$e$jscomp$174_name_cached$$],$callback$jscomp$1$$(null,$rs$$))})}catch($e$$){console.error($e$$),
|
|
297
299
|
$callback$jscomp$1$$($e$$)}};
|
|
298
300
|
controller.prototype.update=function(){let $ctrl$$=this,$name$$=this.name;this.router.route(this.route_name+"/:id").put(function($req$$,$res$$){let $session$$=$req$$.session;if(!0===$session$$["updating_"+$name$$])return $res$$.status(400).send({error:"\u0110ang x\u1eed l\u00fd d\u1eef li\u1ec7u"});$session$$["updating_"+$name$$]=!0;let $body$$=$req$$.body;$req$$.files&&underscore.extend($body$$,$req$$.files);let $data$$;try{$data$$=bodyToJson($body$$)}catch($e$$){return $res$$.status(400).send({error:$e$$.message||$e$$.error||
|
|
@@ -301,14 +303,15 @@ function checkReference($model$jscomp$0$$,$obj$$,$fn$$,$keys$$){$model$jscomp$0$
|
|
|
301
303
|
$cb$$){setImmediate(()=>{let $model$$=mongoose.models[$r$$.model];if($model$$){let $query$$={id_app:$obj$$.id_app};var $_w_k$$=$r$$.key;$_w_k$$&&($query$$[$_w_k$$]=$value$$);$r$$.where&&(underscore.isObject($r$$.where)&&($query$$=Object.assign($query$$,$r$$.where)),underscore.isFunction($r$$.where)&&($_w_k$$=$r$$.where($obj$$),$query$$=Object.assign($query$$,$_w_k$$)));$model$$.find($query$$).limit(1).lean().exec(function($error$$,$o$$){setImmediate(()=>{if($error$$)return $cb$$($error$$);if($o$$&&
|
|
302
304
|
0<$o$$.length){let $msgError$$;$msgError$$=$r$$.error?(new Function("obj","return `"+$r$$.error.replace("{{VALUE}}",$value$$)+"`"))($obj$$):ERR_DATA_GENERATED;return $cb$$({error:$msgError$$,code:ERR_DATA_GENERATED_CODE})}$cb$$()})})}else $cb$$()})},function($e$$){if($e$$)return $callback$$($e$$);$callback$$()})})},$error$$=>{$fn$$($error$$)})):$fn$$()}
|
|
303
305
|
controller.prototype.delete=function(){let $model$$=this.model,$ctrl$$=this,$module$$=this.module;this.router.route(this.route_name+"/:id").delete(function($req$$,$res$$,$next$$){if(!global.mongoose.Types.ObjectId.isValid($req$$.params.id))return $res$$.status(400).send({error:ERR_NOT_FOUND,code:ERR_NOT_FOUND_CODE});$model$$.findOne({_id:$req$$.params.id}).exec(async function($e$jscomp$179_user$$,$obj$$){if($e$jscomp$179_user$$)return console.error($e$jscomp$179_user$$),$e$jscomp$179_user$$.error?
|
|
304
|
-
$res$$.status(400).send($e$jscomp$179_user$$):$res$$.status(400).send({error:$e$jscomp$179_user$$.message||$e$jscomp$179_user$$.error||$e$jscomp$179_user$$});if(!$obj$$)return $res$$.status(404).send({error:ERR_NOT_FOUND,code:ERR_NOT_FOUND_CODE});$e$jscomp$179_user$$=$req$$.user;
|
|
305
|
-
$rj$$)=>{validator.unlockBook[0]($obj$$.id_app,$obj$$.ngay_ct,$unlock$$=>{if(!$unlock$$)return $rj$$(validator.unlockBook[1]);$rs$$($unlock$$)},$voucher_options$$)})}catch($e$$){return $res$$.status(400).send({error:$e$$.message
|
|
306
|
-
$req$$.query["otp-id"],$req$$.query["otp-code"])}catch($e$$){return $res$$.status(400).send({error:$e$$.message||$e$$.error||$e$$,code:ERR_VERIFY_OTP})}setImmediate(()=>{permission.hasRight($obj$$.id_app
|
|
307
|
-
|
|
308
|
-
$req$$.obj
|
|
309
|
-
$
|
|
310
|
-
$
|
|
311
|
-
"DELETE"
|
|
306
|
+
$res$$.status(400).send($e$jscomp$179_user$$):$res$$.status(400).send({error:$e$jscomp$179_user$$.message||$e$jscomp$179_user$$.error||$e$jscomp$179_user$$});if(!$obj$$)return $res$$.status(404).send({error:ERR_NOT_FOUND,code:ERR_NOT_FOUND_CODE});$e$jscomp$179_user$$=$req$$.user;if($obj$$.trang_thai&&await Approve.findOne({id_ct:$obj$$._id.toString(),user_approved:{$exists:!0}}))return $res$$.status(400).send({error:"Kh\u00f4ng th\u1ec3 xo\u00e1 ch\u1ee9ng t\u1eeb n\u00e0y do n\u00f3 \u0111\u00e3 \u0111\u01b0\u1ee3c duy\u1ec7t"});
|
|
307
|
+
const $voucher_options$$=(await OptionsModel.findOne({id_app:$e$jscomp$179_user$$.current_id_app,id_func:$ctrl$$.name}).lean()||{}).option;if($obj$$.ngay_ct&&$obj$$.id_app&&$obj$$.schema&&$obj$$.schema.validate&&$obj$$.schema.validate.ngay_ct)try{await new Promise(($rs$$,$rj$$)=>{validator.unlockBook[0]($obj$$.id_app,$obj$$.ngay_ct,$unlock$$=>{if(!$unlock$$)return $rj$$(validator.unlockBook[1]);$rs$$($unlock$$)},$voucher_options$$)})}catch($e$$){return $res$$.status(400).send({error:$e$$.message||
|
|
308
|
+
$e$$.error||$e$$,code:BOOK_LOCK})}$obj$$=$obj$$.toObject();let $requireOtp$$=$ctrl$$.options.requireOtp;$requireOtp$$&&_.isFunction($requireOtp$$)&&($requireOtp$$=$requireOtp$$($obj$$,{action:"delete",_id:$req$$.params.id,user:$e$jscomp$179_user$$}));if($requireOtp$$)try{await permission.verifyOTP($e$jscomp$179_user$$.email,$req$$.query["otp-id"],$req$$.query["otp-code"])}catch($e$$){return $res$$.status(400).send({error:$e$$.message||$e$$.error||$e$$,code:ERR_VERIFY_OTP})}setImmediate(()=>{permission.hasRight($obj$$.id_app,
|
|
309
|
+
$req$$.user.email,$module$$,"delete",function($error$jscomp$0$$,$hr$$){if($hr$$)checkReference($model$$,$obj$$,function($error$$){if($error$$)return $res$$.status(400).send({error:ERR_ARISE+($error$$.error||$error$$.message||$error$$),code:ERR_ARISE_CODE});$req$$.obj=$obj$$;$next$$()});else return $res$$.status(403).send({error:$error$jscomp$0$$||ERR_NOT_PERMIT,code:ERR_NOT_PERMIT_CODE})},{obj:$obj$$,notNeedRight:$ctrl$$.options.notNeedRight})})})},function($req$$,$res$$,$next$$){setImmediate(()=>
|
|
310
|
+
{let $obj$jscomp$1$$=$req$$.obj;$ctrl$$.deleting?$ctrl$$.deleting($req$$.user,$obj$jscomp$1$$,function($e$$,$obj$jscomp$0$$){if($e$$)return console.error($e$$),$e$$.error?$res$$.status(400).send($e$$):$res$$.status(400).send({error:$e$$.message||$e$$});$ctrl$$.dynamicDeleting?$ctrl$$.dynamicDeleting($req$$.user,$obj$jscomp$0$$,function($error$$,$obj$$){if($error$$)return $next$$($error$$);$req$$.obj=$obj$$;$next$$()}):($req$$.obj=$obj$jscomp$0$$,$next$$())},{req:$req$$}):$ctrl$$.dynamicDeleting?$ctrl$$.dynamicDeleting($req$$.user,
|
|
311
|
+
$obj$jscomp$1$$,function($error$$,$obj$$){if($error$$)return $next$$($error$$);$req$$.obj=$obj$$;$next$$()}):($req$$.obj=$obj$jscomp$1$$,$next$$())})},function($req$$,$res$$){setImmediate(()=>{let $obj$jscomp$0$$=$req$$.obj;$ctrl$$.emit("deleting",{...$obj$jscomp$0$$});deletePost($req$$.user,$obj$jscomp$0$$,async $e$jscomp$1$$=>{if($e$jscomp$1$$)return console.error($e$jscomp$1$$),$e$jscomp$1$$.error?$res$$.status(400).send($e$jscomp$1$$):$res$$.status(400).send({error:$e$jscomp$1$$.message||$e$jscomp$1$$});
|
|
312
|
+
if($ctrl$$.dynamicDeletePost)try{await $ctrl$$.dynamicDeletePost($obj$jscomp$0$$)}catch($e$$){return $res$$.status(400).send({error:$e$$.message||$e$$.error||$e$$})}$model$$.deleteOne({_id:$obj$jscomp$0$$._id},function($e$jscomp$0$$){if($e$jscomp$0$$)return console.error($e$jscomp$0$$),$e$jscomp$0$$.error?$res$$.status(400).send($e$jscomp$0$$):$res$$.status(400).send({error:$e$jscomp$0$$.message||$e$jscomp$0$$});setImmediate(()=>{$ctrl$$.deleteData({...$obj$jscomp$0$$});log.create({id_app:$req$$.user.current_id_app,
|
|
313
|
+
id_func:$ctrl$$.name,action:"DELETE",data:{id:$obj$jscomp$0$$._id,data:$obj$jscomp$0$$}},$req$$.user.email,$req$$.header("user-agent"),$req$$);link.deleteMany({$or:[{id_a:$obj$jscomp$0$$._id},{id_b:$obj$jscomp$0$$._id}]},function($e$$){$e$$&&console.error("Can't delete links\n"+$e$$)})});setImmediate(()=>{$ctrl$$.emit("deleted",$obj$jscomp$0$$);runWebhooks($ctrl$$,$obj$jscomp$0$$,"DELETE")});pushNotification($ctrl$$,$obj$jscomp$0$$,"delete",null,null,{exclude_token:$req$$.query.access_token});setImmediate(()=>
|
|
314
|
+
{$ctrl$$.deleted?$ctrl$$.deleted($req$$.user,$obj$jscomp$0$$,function($e$$,$obj$$){setImmediate(()=>{if($e$$)return console.error($e$$),$e$$.error?$res$$.status(400).send($e$$):$res$$.status(400).send({error:$e$$.message||$e$$});$res$$.send($obj$$)})}):$res$$.send($obj$jscomp$0$$)})})})})})};
|
|
312
315
|
controller.prototype.history=function(){let $name$$=this.name;this.router.route(this.route_name+"/g/history/:id").get(function($actions_req$$,$res$$){let $query$$={id_func:$name$$,id_app:$actions_req$$.user.current_id_app,"data.id":$actions_req$$.params.id};($actions_req$$=$actions_req$$.query.actions)?($actions_req$$=$actions_req$$.split(","),$query$$.action={$in:$actions_req$$,$ne:"GET"}):$query$$.action={$ne:"GET"};log.find($query$$).lean().exec(function($e$$,$rs$$){setImmediate(()=>$e$$?(console.error($e$$),
|
|
313
316
|
$e$$.error?$res$$.status(400).send($e$$):$res$$.status(400).send({error:$e$$.message||$e$$})):$res$$.send($rs$$))})})};
|
|
314
317
|
controller.prototype.logs=function(){let $ctrl$$=this,$name$$=this.name;this.router.route(this.route_name+"/g/log/:action").get(function($req$$,$res$$){var $action$jscomp$3_den_ngay$$=$req$$.params.action.toUpperCase();let $query$$={id_func:$name$$,id_app:$req$$.user.current_id_app};"ALL"!==$action$jscomp$3_den_ngay$$&&($query$$.action=$action$jscomp$3_den_ngay$$);if($req$$.query.tu_ngay){var $date_created_tu_ngay$$=moment(new Date($req$$.query.tu_ngay)).startOf("date").toDate();$date_created_tu_ngay$$=
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';exports.existsVt=[function($id_app$$,$ma_vt$$,$callback$$){$ma_vt$$?global.getModel("dmvt").findOne({id_app:$id_app$$,ma_vt:$ma_vt$$},{ma_vt:1},function($error$$,$vt$$){$error$$||!$vt
|
|
1
|
+
'use strict';exports.existsVt=[function($id_app$$,$ma_vt$$,$callback$$){$ma_vt$$?global.getModel("dmvt").findOne({id_app:$id_app$$,ma_vt:$ma_vt$$},{ma_vt:1},function($error$$,$vt$$){$error$$||!$vt$$?(console.log("Kh\u00f4ng t\u1ed3n t\u1ea1i v\u1eadt t\u01b0 "+$ma_vt$$+" \u1edf id_app "+$id_app$$),$callback$$(!1)):$callback$$(!0)}):$callback$$(!0)},"M\u00e3 v\u1eadt t\u01b0 {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
|
|
2
2
|
exports.existsKho=[function($id_app$$,$ma_kho$$,$callback$$){$ma_kho$$?global.getModel("dmkho").findOne({id_app:$id_app$$,ma_kho:$ma_kho$$},{ma_kho:1},function($error$$,$kho$$){$error$$||!$kho$$?$callback$$(!1):$callback$$(!0)}):$callback$$(!0)},"M\u00e3 kho {VALUE} kh\u00f4ng t\u1ed3n t\u1ea1i"];
|
package/server/models/approve.js
CHANGED
|
@@ -28,10 +28,11 @@ approveSchema.index({user_denied:1});approveSchema.index({status:1});approveSche
|
|
|
28
28
|
<div><span style='color:#16726D'>Last Update by:</span> <span style='color:#397A3A'>{{datasource.name_user_updated || datasource.user_updated}} at {{datasource.date_created|date:'dd/MM/yyyy HH:mm'}}</span></div>
|
|
29
29
|
</p>
|
|
30
30
|
`;
|
|
31
|
-
model.request=function($user_request$$,$user_approve$$,$title$$,$_c_data_request$$,$callback$$,$update_after_approve$$,$template_content$$,$update_after_deny$$){let $user_approves$$=$user_approve$$;underscore.isArray($user_approves$$)||($user_approves$$=[$user_approve$$]);let $data$$;$data$$=$_c_data_request$$.toObject?$_c_data_request$$.toObject():_.cloneDeep($_c_data_request$$);$data$$._id=($data$$._id||"").toString();$_c_data_request$$={id_ct:$data$$._id};Object.keys($data$$).includes("trang_thai")&&($_c_data_request$$.trang_thai=
|
|
32
|
-
$data$$.trang_thai);model.deleteOne($_c_data_request$$,async()=>{const $m$$={id_app:$data$$.id_app,id_ct:$data$$._id,ma_ct:$data$$.ma_ct,trang_thai:$data$$.trang_thai,
|
|
33
|
-
|
|
34
|
-
{}).system||{}).templateRpt||"").split("<em>").join("").split("</em>").join(""));
|
|
31
|
+
model.request=async function($user_request$$,$user_approve$$,$title$$,$_c_data_request$$,$callback$$,$update_after_approve$$,$template_content$$,$update_after_deny$$){let $user_approves$$=$user_approve$$;underscore.isArray($user_approves$$)||($user_approves$$=[$user_approve$$]);let $data$$;$data$$=$_c_data_request$$.toObject?$_c_data_request$$.toObject():_.cloneDeep($_c_data_request$$);$data$$._id=($data$$._id||"").toString();$_c_data_request$$={id_ct:$data$$._id};Object.keys($data$$).includes("trang_thai")&&($_c_data_request$$.trang_thai=
|
|
32
|
+
$data$$.trang_thai);const $old_request$$=await model.findOne($_c_data_request$$);if($old_request$$&&$old_request$$.user_approved)return $callback$$(`Kh\u00f4ng th\u1ec3 t\u1ea1o y\u00eau c\u1ea7u duy\u1ec7t cho tr\u1ea1ng th\u00e1i ${$_c_data_request$$.trang_thai} c\u1ee7a ch\u1ee9ng t\u1eeb ${$data$$._id} v\u00ec \u0111\u00e3 \u0111\u01b0\u1ee3c duy\u1ec7t`);model.deleteOne($_c_data_request$$,async()=>{const $m$$={id_app:$data$$.id_app,id_ct:$data$$._id,ma_ct:$data$$.ma_ct,trang_thai:$data$$.trang_thai,
|
|
33
|
+
user_request:$user_request$$.email,user_request_name:$user_request$$.name,user_approves:$user_approves$$,update_after_approve:$update_after_approve$$,update_after_deny:$update_after_deny$$,title:$title$$,template_content:$template_content$$,visible_to_users:$user_approves$$.map($u$$=>$u$$.email)};let $app_info$$=await App.findOne({_id:$data$$.id_app}).lean();if($app_info$$){var $details_option_template_gen$$;$data$$.ma_ct&&($details_option_template_gen$$=await Options.findOne({id_app:$data$$.id_app,
|
|
34
|
+
id_func:{$regex:"^"+$data$$.ma_ct+"$",$options:"i"}}).lean());var $ngEnviorment$$=new ngcompile([]),$template$$=$template_content$$;!$template$$&&$details_option_template_gen$$&&$details_option_template_gen$$.option&&$details_option_template_gen$$.option.system&&($template$$=($template$$=((($details_option_template_gen$$.option||{}).system||{}).templateEmail||(($details_option_template_gen$$.option||{}).system||{}).templateRpt||"").split("<em>").join("").split("</em>").join(""))||"Ch\u01b0a khai b\u00e1o n\u1ed9i dung duy\u1ec7t");
|
|
35
|
+
if($template$$){$details_option_template_gen$$=`<h3>${$title$$}</h3>
|
|
35
36
|
<div>Ng\u01b0\u1eddi y\u00eau c\u1ea7u: {{user_request.name}}</div>
|
|
36
37
|
<div>Ng\u00e0y y\u00eau c\u1ea7u: {{datasource.date_created|date:'dd/MM/yyyy HH:mm:ss'}}</div>
|
|
37
38
|
<div>N\u1ed9i dung:</div><hr/>${$template$$}<hr/>
|
|
@@ -68,7 +69,7 @@ $_id$$=$key_data$$.id_request;$user_approved$$=$key_data$$.email;$user_approved_
|
|
|
68
69
|
new Date;$rq$$.user_approved=$user_approved$$;$rq$$.user_approved_name=$user_approved_name$$;$rq$$.approved_reason=$options$$.reason||"";if(!$rq$$.user_approves||!$rq$$.user_approves.find($u$$=>0<=$u$$.email.indexOf($user_approved$$)))return $callback$$("User n\u00e0y kh\u00f4ng c\u00f3 quy\u1ec1n duy\u1ec7t y\u00eau c\u1ea7u n\u00e0y");$rq$$.save(($e$jscomp$2$$,$approve$$)=>{if($e$jscomp$2$$)return $callback$$($e$jscomp$2$$);model.sendNotifyApproved($rq$$,$token$$);if($rq$$.update_after_approve&&
|
|
69
70
|
$rq$$.update_after_approve.data)try{let $module_name$$=$rq$$.update_after_approve.module||$rq$$.update_after_approve.model,$ctrl$$;$module_name$$&&($ctrl$$=global.controllers[$module_name$$.toUpperCase()]);let $_m$$;$rq$$.update_after_approve.model?$_m$$=global.getModel($rq$$.update_after_approve.model):$ctrl$$&&($_m$$=$ctrl$$.getProperty("model"));if(!$_m$$)return;$_m$$.updateOne({_id:$rq$$.id_ct},$rq$$.update_after_approve.data,async $e$jscomp$1$$=>{if($e$jscomp$1$$)return console.error("Can't update data after approved, error:",
|
|
70
71
|
$e$jscomp$1$$);if($ctrl$$)try{const $obj$$=await $_m$$.findOne({_id:$rq$$.id_ct});if($obj$$){const $u$$=await global.getModel("user").findOne({email:$user_approved$$});$u$$.current_id_app=$obj$$.id_app;const $app_info$$=await App.findOne({_id:$obj$$.id_app});$ctrl$$.postData($obj$$,$e$$=>{$e$$&&console.error($e$$)});$ctrl$$.handleAfterAproved&&await $ctrl$$.handleAfterAproved($obj$$);$ctrl$$.onView($u$$,[$obj$$.toObject()],($e$jscomp$0$$,$rs$$)=>{$ctrl$$.requestApprove($app_info$$,$u$$,$rs$$[0],$e$$=>
|
|
71
|
-
{$e$$&&console.error($e$$)})})}}catch($e$$){console.error($e$$)}})}catch($e$$){console.error("Can't update data after approved, error:",$e$$.message)}$callback$$(null,$approve$$)})})};
|
|
72
|
+
{$e$$&&console.error($e$$)},null,$rq$$)})}}catch($e$$){console.error($e$$)}})}catch($e$$){console.error("Can't update data after approved, error:",$e$$.message)}$callback$$(null,$approve$$)})})};
|
|
72
73
|
model.deny=function($_c$jscomp$2_encrypted$$,$callback$$,$token$$,$options$$={reason:""}){let $key_data$$,$_id$$,$user_denied$$,$user_denied_name$$,$trang_thai$$;if(underscore.isObject($_c$jscomp$2_encrypted$$))$_id$$=$_c$jscomp$2_encrypted$$.id_request,$user_denied$$=$_c$jscomp$2_encrypted$$.email,$user_denied_name$$=$_c$jscomp$2_encrypted$$.name,$trang_thai$$=$_c$jscomp$2_encrypted$$.trang_thai;else try{const $decipher$$=crypto.createDecipher("aes192",configs.cryptoPassword||"PVT@1");let $decrypted$$=
|
|
73
74
|
$decipher$$.update($_c$jscomp$2_encrypted$$,"hex","utf8");$decrypted$$+=$decipher$$.final("utf8");$key_data$$=JSON.parse($decrypted$$);$_id$$=$key_data$$.id_request;$user_denied$$=$key_data$$.email;$user_denied_name$$=$key_data$$.name;$trang_thai$$=$key_data$$.trang_thai}catch($e$$){return $callback$$("Y\u00eau c\u1ea7u n\u00e0y kh\u00f4ng c\u00f3 gi\u00e1 tr\u1ecb")}if(!$_id$$||!$user_denied$$)return $callback$$("request id and deny user are required");if(!global.mongoose.Types.ObjectId.isValid($_id$$))return $callback$$("request id '"+
|
|
74
75
|
$_id$$+"' is not valid");$_c$jscomp$2_encrypted$$={_id:$_id$$};void 0!==$trang_thai$$&&null!==$trang_thai$$&&($_c$jscomp$2_encrypted$$.trang_thai=$trang_thai$$);model.findOne($_c$jscomp$2_encrypted$$,($e$jscomp$2$$,$rq$$)=>{if($e$jscomp$2$$||!$rq$$||!$rq$$.ma_ct)return $callback$$($e$jscomp$2$$||"Y\u00eau c\u1ea7u n\u00e0y kh\u00f4ng t\u1ed3n t\u1ea1i");if($rq$$.date_approved)return $callback$$("Y\u00eau c\u1ea7u n\u00e0y \u0111\u00e3 \u0111\u01b0\u1ee3c duy\u1ec7t b\u1edfi "+$rq$$.user_approved_name);
|
|
@@ -3,7 +3,7 @@ sender_date:Date,transaction:Schema.Types.Mixed,return_url:String,notify_url:Str
|
|
|
3
3
|
assrequestSchema.index({request_id:1});assrequestSchema.index({ma_ct:1});assrequestSchema.index({denom:1});assrequestSchema.index({order_id:1});assrequestSchema.index({order_info:1});assrequestSchema.index({receiver_name:1});assrequestSchema.index({receiver_address:1});assrequestSchema.index({status:1});assrequestSchema.index({user_created:1});assrequestSchema.index({trang_thai:1});
|
|
4
4
|
assrequestSchema.index({receiver_address:"text",order_id:"text",order_info:"text",receiver_name:"text",sender_name:"text"},{name:"assrequest_index2"});const model=mongoose.models.assrequest||mongoose.model("assrequest",assrequestSchema);model.on("index",async function($err$$){$err$$?console.error("assrequest index error",$err$$):console.info("assrequest indexing complete")});
|
|
5
5
|
model.createVirtualPaymentClientURL=async($order$$,$_app_client_ip$$,$_paymentViaWallet_item$$)=>{$_app_client_ip$$=await global.getModel("app").findOne({_id:$order$$.id_app});$_paymentViaWallet_item$$=await model.create({id_app:$order$$.id_app,user_created:$order$$.user_created,user_updated:$order$$.user_created,receiver_name:$_paymentViaWallet_item$$.wallet_configs.receiver_name,receiver_address:$_paymentViaWallet_item$$.wallet_configs.receiver_address,request_id:$order$$._id.toString(),ma_ct:$order$$.ma_ct||
|
|
6
|
-
"",amount:$order$$.amount,denom:$_paymentViaWallet_item$$.wallet_configs.denom,order_id:$order$$.so_ct||$order$$._id.toString(),order_info
|
|
6
|
+
"",amount:$order$$.amount,denom:$_paymentViaWallet_item$$.wallet_configs.denom,order_id:$order$$.so_ct||$order$$._id.toString(),order_info:"Thanh to\u00e1n cho \u0111\u01a1n h\u00e0ng "+($order$$.so_ct||$order$$._id.toString())});$_paymentViaWallet_item$$.return_url=`${configs.domain?`https://${configs.domain}`:configs.api_url}/public/${$order$$.id_app}/assrequest/${$_paymentViaWallet_item$$._id.toString()}/callback`;await $_paymentViaWallet_item$$.save();return($_app_client_ip$$.domain||"")+"/#/payment/"+
|
|
7
7
|
$_paymentViaWallet_item$$._id.toString()};
|
|
8
8
|
model.verifyReturnUrl=async($again_link_id_app$$,$id_transaction_request$$,$query_results$$)=>{$again_link_id_app$$=`${configs.domain?`https://${configs.domain}`:configs.api_url}/public/payment/again`;$id_transaction_request$$=await model.findOne({_id:$id_transaction_request$$}).lean();if(!$id_transaction_request$$)throw"Y\u00eau c\u1ea7u thanh to\u00e1n kh\u00f4ng t\u1ed3n t\u1ea1i";$query_results$$={...$query_results$$};$query_results$$.isSuccess="1"==$id_transaction_request$$.trang_thai;if($query_results$$.isSuccess&&
|
|
9
9
|
$id_transaction_request$$.ma_ct){let $_v$$=global.getModel(`${$id_transaction_request$$.ma_ct.toLowerCase()}`);const $obj_updated$$=await $_v$$.findOne({_id:$id_transaction_request$$.request_id});try{let $ctrl$$=global.controllers[$id_transaction_request$$.ma_ct.toUpperCase()];if($ctrl$$&&$obj_updated$$){if($ctrl$$.handleAfterPayment){console.log("handle after payment");try{await $ctrl$$.handleAfterPayment($obj_updated$$),controller.pushNotification($ctrl$$,$obj_updated$$,"payment",null,!1,{title:`Bill ${$obj_updated$$.so_ct} \u0111\u00e3 \u0111\u01b0\u1ee3c thanh to\u00e1n`})}catch($e$$){console.error("error handle after payment",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
'use strict';const dmhoahonghdSchema=new Schema({id_app:{type:String,required:!0,maxlength:1024},kieu:{type:String,default:"0"},doi_tuong:{type:String,default:"0"},hinh_thuc_tt:{type:String,default:"0"},ma_hoahong:{type:String,uppercase:!0,required:!0,maxlength:32},ten_hoahong:{type:String,required:!0,maxlength:1024},mieu_ta:{type:String},chi_su_dung_cho_ct:{type:String,uppercase:!0},khong_su_dung_cho_ct:{type:String,uppercase:!0},user_group:String,ma_nv:{type:String,
|
|
2
|
-
ma_bp:{type:String,default:"",maxlength:1024},ten_bp:String,ma_kh:{type:String,default:"",maxlength:32},ten_kh:String,nh_kh:{type:String,default:"",maxlength:1024},ten_nh_kh:String,ma_kho:{type:String,default:"",maxlength:32},ten_kho:String,gt_tu:{type:Number,default:0},gt_den:{type:Number,default:0},vts:[],sl_toi_thieu:{type:Number,default:0},tien_hh:{type:Number,default:0},ty_le_hh:{type:Number,default:0},so_tien_max:{type:Number,default:0},hieu_luc_tu:{type:Date,
|
|
3
|
-
required:!0},ap_dung_lan_mua_thu:{type:Number},ap_dung_lan_mua_tu_thu:{type:Number},ap_dung_lan_mua_den_thu:{type:Number},details_km:[],picture:{type:String},exfields:Schema.Types.Mixed,newsfeed:{type:Boolean,default:!0},online:{type:Boolean},offline:{type:Boolean},status:{type:Boolean,default:!0},date_created:{type:Date,default:Date.now},date_updated:{type:Date,default:Date.now},user_created:{type:String,default:""},user_updated:{type:String,default:""},ma_kh_id:{type:Schema.Types.ObjectId,
|
|
4
|
-
localField:["ma_kh"],foreignField:["ma_kh"]},ma_kho_id:{type:Schema.Types.ObjectId,ref:"dmkho",localField:["ma_kho"],foreignField:["ma_kho"]}});dmhoahonghdSchema.index({id_app:1,ma_hoahong:1,ma_kho:1,ma_kh:1,hieu_luc_tu:-1,hieu_luc_den:-1});dmhoahonghdSchema.index({ap_dung_lan_mua_thu:1});dmhoahonghdSchema.index({ap_dung_lan_mua_tu_thu:1});dmhoahonghdSchema.index({ap_dung_lan_mua_den_thu:1});dmhoahonghdSchema.index({gt_tu:1});dmhoahonghdSchema.index({gt_den:1});dmhoahonghdSchema.index({ten_kho:1});
|
|
5
|
-
dmhoahonghdSchema.index({nh_kh:1});dmhoahonghdSchema.index({ten_nh_kh:1});dmhoahonghdSchema.index({ma_nv:1});dmhoahonghdSchema.index({ma_bp:1});dmhoahonghdSchema.index({user_group:1});dmhoahonghdSchema.index({date_updated:-1});dmhoahonghdSchema.index({date_created:-1});dmhoahonghdSchema.index({user_created:1});dmhoahonghdSchema.index({online:1});dmhoahonghdSchema.index({offline:1});
|
|
1
|
+
'use strict';const dmhoahonghdSchema=new Schema({id_app:{type:String,required:!0,maxlength:1024},kieu:{type:String,default:"0"},doi_tuong:{type:String,default:"0"},hinh_thuc_tt:{type:String,default:"0"},do_uu_tien:{type:Number,default:0},ma_hoahong:{type:String,uppercase:!0,required:!0,maxlength:32},ten_hoahong:{type:String,required:!0,maxlength:1024},mieu_ta:{type:String},chi_su_dung_cho_ct:{type:String,uppercase:!0},khong_su_dung_cho_ct:{type:String,uppercase:!0},user_group:String,ma_nv:{type:String,
|
|
2
|
+
default:"",maxlength:32},ten_nv:String,ma_bp:{type:String,default:"",maxlength:1024},ten_bp:String,ma_kh:{type:String,default:"",maxlength:32},ten_kh:String,nh_kh:{type:String,default:"",maxlength:1024},ten_nh_kh:String,ma_kho:{type:String,default:"",maxlength:32},ten_kho:String,gt_tu:{type:Number,default:0},gt_den:{type:Number,default:0},vts:[],sl_toi_thieu:{type:Number,default:0},tien_hh:{type:Number,default:0},ty_le_hh:{type:Number,default:0},so_tien_max:{type:Number,default:0},hieu_luc_tu:{type:Date,
|
|
3
|
+
required:!0},hieu_luc_den:{type:Date,required:!0},ap_dung_lan_mua_thu:{type:Number},ap_dung_lan_mua_tu_thu:{type:Number},ap_dung_lan_mua_den_thu:{type:Number},details_km:[],picture:{type:String},exfields:Schema.Types.Mixed,newsfeed:{type:Boolean,default:!0},online:{type:Boolean},offline:{type:Boolean},status:{type:Boolean,default:!0},date_created:{type:Date,default:Date.now},date_updated:{type:Date,default:Date.now},user_created:{type:String,default:""},user_updated:{type:String,default:""},ma_kh_id:{type:Schema.Types.ObjectId,
|
|
4
|
+
ref:"customer",localField:["ma_kh"],foreignField:["ma_kh"]},ma_kho_id:{type:Schema.Types.ObjectId,ref:"dmkho",localField:["ma_kho"],foreignField:["ma_kho"]}});dmhoahonghdSchema.index({id_app:1,ma_hoahong:1,ma_kho:1,ma_kh:1,hieu_luc_tu:-1,hieu_luc_den:-1});dmhoahonghdSchema.index({ap_dung_lan_mua_thu:1});dmhoahonghdSchema.index({ap_dung_lan_mua_tu_thu:1});dmhoahonghdSchema.index({ap_dung_lan_mua_den_thu:1});dmhoahonghdSchema.index({gt_tu:1});dmhoahonghdSchema.index({gt_den:1});dmhoahonghdSchema.index({ten_kho:1});
|
|
5
|
+
dmhoahonghdSchema.index({nh_kh:1});dmhoahonghdSchema.index({ten_nh_kh:1});dmhoahonghdSchema.index({ma_nv:1});dmhoahonghdSchema.index({ma_bp:1});dmhoahonghdSchema.index({user_group:1});dmhoahonghdSchema.index({kieu:1});dmhoahonghdSchema.index({do_uu_tien:1});dmhoahonghdSchema.index({date_updated:-1});dmhoahonghdSchema.index({date_created:-1});dmhoahonghdSchema.index({user_created:1});dmhoahonghdSchema.index({online:1});dmhoahonghdSchema.index({offline:1});
|
|
6
6
|
dmhoahonghdSchema.index({mieu_ta:"text",ma_hoahong:"text",ten_hoahong:"text",ma_kh:"text",ten_kh:"text",nh_kh:"text",ten_nh_kh:"text",ma_kho:"text",ten_kho:"text",ma_nv:"text",ten_nv:"text",ma_bp:"text",ten_bp:"text"},{name:"dmhoahonghd_index_text"});dmhoahonghdSchema.set("toObject",{virtuals:!0});dmhoahonghdSchema.set("toJSON",{virtuals:!0});dmhoahonghdSchema.index({status:1});const model=mongoose.models.dmhoahonghd||mongoose.model("dmhoahonghd",dmhoahonghdSchema);module.exports=model;
|
package/server/models/file.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
'use strict';const fileSchema=new Schema({id_app:{type:String,required:!0,maxlength:1024},file:{},id_link:String,id_folder:String,collection_link:String,group:{type:String,default:"document"},mieu_ta:{type:String,maxlength:1024},nh_file:{type:String,maxlength:1024},title_topic:{type:String,maxlength:1024},url_topic:{type:String,maxlength:1024},server:String,refresh_token:String,account:String,meta:{},is_avatar:{type:Boolean},read_image:Boolean,text_from_image:String,shared:{type:Boolean},visible_to:{type:Number,
|
|
2
|
-
default:0},visible_to_users:[String],update_right:[String],delete_right:[String],status:{type:Boolean,default:!0},date_created:{type:Date,default:Date.now},date_updated:{type:Date,default:Date.now},user_created:{type:String,default:""},user_updated:{type:String,default:""}});fileSchema.index({id_app:1,id_link:1});fileSchema.index({shared:1});fileSchema.index({group:1});fileSchema.index({id_folder:1});fileSchema.index({collection_link:1});fileSchema.index({mieu_ta:"text"});
|
|
3
|
-
fileSchema.index({user_created:1,visible_to:1,visible_to_users:1});module.exports=mongoose.models.file||mongoose.model("file",fileSchema);
|
|
2
|
+
default:0},visible_to_users:[String],visible_to_usergroups:[String],update_right:[String],delete_right:[String],status:{type:Boolean,default:!0},date_created:{type:Date,default:Date.now},date_updated:{type:Date,default:Date.now},user_created:{type:String,default:""},user_updated:{type:String,default:""}});fileSchema.index({id_app:1,id_link:1});fileSchema.index({shared:1});fileSchema.index({group:1});fileSchema.index({id_folder:1});fileSchema.index({collection_link:1});fileSchema.index({mieu_ta:"text"});
|
|
3
|
+
fileSchema.index({status:1});fileSchema.index({user_created:1,visible_to:1,visible_to_users:1});module.exports=mongoose.models.file||mongoose.model("file",fileSchema);
|
package/server/models/folder.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
'use strict';const folderSchema=new Schema({id_app:{type:String,required:!0,maxlength:1024},id_link:String,collection_link:String,thu_muc_goc:String,ten_thu_muc:{type:String,maxlength:1024},phu_trach:String,ma_bp:String,ma_dt:String,mieu_ta:{type:String,maxlength:1024},shared:{type:Boolean},visible_to:{type:Number,default:0},visible_to_users:[String],update_right:[String],delete_right:[String],status:{type:Boolean,default:!0},date_created:{type:Date,default:Date.now},
|
|
2
|
-
user_created:{type:String,default:""},user_updated:{type:String,default:""}});folderSchema.index({id_app:1,id_link:1});folderSchema.index({shared:1});folderSchema.index({phu_trach:1});folderSchema.index({ma_bp:1});folderSchema.index({ma_dt:1});folderSchema.index({phu_trach:1});folderSchema.index({ten_thu_muc:1});folderSchema.index({collection_link:1});folderSchema.index({mieu_ta:"text",ten_thu_muc:"text"},{name:"folder_index_text"});folderSchema.index({status:1});
|
|
1
|
+
'use strict';const folderSchema=new Schema({id_app:{type:String,required:!0,maxlength:1024},id_link:String,collection_link:String,thu_muc_goc:String,ten_thu_muc:{type:String,maxlength:1024},phu_trach:String,ma_bp:String,ma_dt:String,mieu_ta:{type:String,maxlength:1024},shared:{type:Boolean},visible_to:{type:Number,default:0},visible_to_users:[String],visible_to_usergroups:[String],update_right:[String],delete_right:[String],status:{type:Boolean,default:!0},date_created:{type:Date,default:Date.now},
|
|
2
|
+
date_updated:{type:Date,default:Date.now},user_created:{type:String,default:""},user_updated:{type:String,default:""}});folderSchema.index({id_app:1,id_link:1});folderSchema.index({shared:1});folderSchema.index({phu_trach:1});folderSchema.index({ma_bp:1});folderSchema.index({ma_dt:1});folderSchema.index({phu_trach:1});folderSchema.index({ten_thu_muc:1});folderSchema.index({collection_link:1});folderSchema.index({mieu_ta:"text",ten_thu_muc:"text"},{name:"folder_index_text"});folderSchema.index({status:1});
|
|
3
3
|
folderSchema.index({user_created:1,visible_to:1,visible_to_users:1});module.exports=mongoose.models.folder||mongoose.model("folder",folderSchema);
|
package/server/models/group.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
'use strict';const groupSchema=new Schema({id_app:{type:String,required:!0,maxlength:1024},group_type:{type:String,uppercase:!0,required:!0,maxlength:1024},group_name:{type:String,required:!0,maxlength:1024},group_name_en:{type:String,maxlength:1024},ma_kho:{type:String,maxlength:32},ma_bp:{type:String,maxlength:32},ma_dt:{type:String,maxlength:32},color:{type:String,maxlength:32},muc_tieu_bieu:{type:Number,default:0},ma_doi_tuong_danh_gia_default:{type:String},id_link:String,
|
|
2
|
-
phu_trach:String,attends:[],dac_thu:Schema.Types.Mixed,exfields:Schema.Types.Mixed,status:{type:Boolean,default:!0},date_created:{type:Date,default:Date.now},date_updated:{type:Date,default:Date.now},user_created:{type:String,default:""},user_updated:{type:String,default:""},visible_to:{type:Number,default:0},visible_to_users:[String],update_right:[String],delete_right:[String],dataview_to:{type:Number,default:0},dataview_to_users:[String]});
|
|
3
|
-
groupSchema.index({group_type:1});groupSchema.index({group_name:1});groupSchema.index({ma_kho:1});groupSchema.index({ma_dt:1});groupSchema.index({ma_bp:1});groupSchema.index({phu_trach:1});groupSchema.index({id_link:1});groupSchema.index({status:1});groupSchema.index({attends:1});groupSchema.index({group_name:"text",group_type:"text"},{name:"group_index_text"});groupSchema.index({status:1});
|
|
4
|
-
const model=mongoose.models.group||mongoose.model("group",groupSchema);model.referenceKeys={_id:[{model:"task",key:"nh_cv",error:"Nh\u00f3m n\u00e0y \u0111\u00e3 c\u00f3 ph\u00e1t sinh chi ti\u1ebft. B\u1ea1n c\u1ea7n xo\u00e1 t\u1ea5t c\u1ea3 chi ti\u1ebft tr\u01b0\u1edbc khi xo\u00e1 nh\u00f3m n\u00e0y"}]};
|
|
1
|
+
'use strict';const groupSchema=new Schema({id_app:{type:String,required:!0,maxlength:1024},group_type:{type:String,uppercase:!0,required:!0,maxlength:1024},group_name:{type:String,required:!0,maxlength:1024},group_name_en:{type:String,maxlength:1024},group_mother:String,ma_kho:{type:String,maxlength:32},ma_bp:{type:String,maxlength:32},ma_dt:{type:String,maxlength:32},color:{type:String,maxlength:32},muc_tieu_bieu:{type:Number,default:0},ma_doi_tuong_danh_gia_default:{type:String},id_link:String,
|
|
2
|
+
collection_link:String,phu_trach:String,attends:[],dac_thu:Schema.Types.Mixed,exfields:Schema.Types.Mixed,status:{type:Boolean,default:!0},date_created:{type:Date,default:Date.now},date_updated:{type:Date,default:Date.now},user_created:{type:String,default:""},user_updated:{type:String,default:""},visible_to:{type:Number,default:0},visible_to_users:[String],visible_to_usergroups:[String],update_right:[String],delete_right:[String],dataview_to:{type:Number,default:0},dataview_to_users:[String]});
|
|
3
|
+
groupSchema.index({id_app:1,group_type:1,ma_dt:1,ma_bp:1});groupSchema.index({group_type:1});groupSchema.index({group_mother:1});groupSchema.index({group_name:1});groupSchema.index({ma_kho:1});groupSchema.index({ma_dt:1});groupSchema.index({ma_bp:1});groupSchema.index({phu_trach:1});groupSchema.index({id_link:1});groupSchema.index({status:1});groupSchema.index({attends:1});groupSchema.index({group_name:"text",group_type:"text"},{name:"group_index_text"});groupSchema.index({status:1});
|
|
4
|
+
groupSchema.index({user_created:1,visible_to:1,visible_to_users:1});const model=mongoose.models.group||mongoose.model("group",groupSchema);model.referenceKeys={_id:[{model:"task",key:"nh_cv",error:"Nh\u00f3m n\u00e0y \u0111\u00e3 c\u00f3 ph\u00e1t sinh chi ti\u1ebft. B\u1ea1n c\u1ea7n xo\u00e1 t\u1ea5t c\u1ea3 chi ti\u1ebft tr\u01b0\u1edbc khi xo\u00e1 nh\u00f3m n\u00e0y"}]};
|
|
5
5
|
model.getInfo=async($id_app$$,$condition$$,$fields$$)=>{$condition$$.id_app=$id_app$$;return new Promise(($resolve$$,$reject$$)=>{model.findOne($condition$$).lean().exec(($e$$,$rs$$)=>{if($e$$||!$rs$$)return $reject$$(Error($e$$?$e$$.message:"Can't find information"));$resolve$$($fields$$?$rs$$[$fields$$]:$rs$$)})})};module.exports=model;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';const checkinactivity=require("./checkinactivity"),task=require("./task"),{round}=require("../libs/utils"),keyresultSchema=new Schema({id_app:{type:String,required:!0,maxlength:1024},id_link:{type:String,required:!0,maxlength:1024},name:{type:String,maxlength:1024},note:{type:String,maxlength:4E3},phu_trach:String,ten_phu_trach:String,attends:[],start_date:{type:Date,required:!0},due_date:{type:Date,required:!0},update_interval:{type:Number,default:1},update_source:String,tk_no:[String],
|
|
2
2
|
tk_co:[String],giam_tru_no:Boolean,giam_tru_co:Boolean,cong_don_gia_tri:Boolean,measure_as:{type:Number,default:1},current_value:{type:Number,default:0},target_value:{type:Number,default:0},aim:{type:Number,default:1},exfields:Schema.Types.Mixed,status:{type:Boolean,default:!0},date_created:{type:Date,default:Date.now},date_updated:{type:Date,default:Date.now},user_created:{type:String,default:""},user_updated:{type:String,default:""},visible_to:{type:Number,default:0},visible_to_users:[String],update_right:[String],
|
|
3
|
-
delete_right:[String]});keyresultSchema.index({id_app:1});keyresultSchema.index({id_link:1});keyresultSchema.index({phu_trach:1});keyresultSchema.index({attends:1});keyresultSchema.index({phu_trach:"text",name:"text",ten_phu_trach:"text"});keyresultSchema.index({status:1});keyresultSchema.index({user_created:1,visible_to:1,visible_to_users:1});
|
|
3
|
+
delete_right:[String]});keyresultSchema.index({id_app:1});keyresultSchema.index({id_link:1});keyresultSchema.index({phu_trach:1});keyresultSchema.index({start_date:1});keyresultSchema.index({name:1});keyresultSchema.index({due_date:1});keyresultSchema.index({attends:1});keyresultSchema.index({phu_trach:"text",name:"text",ten_phu_trach:"text"});keyresultSchema.index({status:1});keyresultSchema.index({user_created:1,visible_to:1,visible_to_users:1});
|
|
4
|
+
const model=mongoose.models.keyresult||mongoose.model("keyresult",keyresultSchema);
|
|
4
5
|
model.asyncGetScore=async $item$$=>{var $checkins_target_remain$$=await checkinactivity.find({id_link:$item$$._id.toString()});$item$$.num_check_ins=$checkins_target_remain$$.length;$item$$.num_check_ins_done=$checkins_target_remain$$.filter($c$$=>"1"===$c$$.trang_thai).length;$item$$.num_tasks=await task.countDocuments({id_link:$item$$._id.toString()});$item$$.score_avg_check_ins=0!=$item$$.num_check_ins_done?round($checkins_target_remain$$.filter($c$$=>"1"===$c$$.trang_thai).map($checkin$$=>$checkin$$.score||
|
|
5
6
|
0).reduce(($a$$,$b$$)=>$a$$+$b$$,0)/$item$$.num_check_ins_done,2):0;$checkins_target_remain$$=Math.abs($item$$.target_value-$item$$.current_value);switch($item$$.aim){case 1:$item$$.score=!$checkins_target_remain$$||!$item$$.score_avg_check_ins||$item$$.score_avg_check_ins<=$item$$.current_value?0:100*round(($item$$.score_avg_check_ins-$item$$.current_value)/$checkins_target_remain$$,2);break;case 2:$item$$.score=!$checkins_target_remain$$||!$item$$.score_avg_check_ins||$item$$.score_avg_check_ins>=
|
|
6
7
|
$item$$.current_value?0:100*round(($item$$.current_value-$item$$.score_avg_check_ins)/$checkins_target_remain$$,2);break;case 3:!$checkins_target_remain$$||!$item$$.score_avg_check_ins||$item$$.score_avg_check_ins<=$item$$.current_value?$item$$.score=0:($item$$.score=100*round(($item$$.score_avg_check_ins-$item$$.current_value)/$checkins_target_remain$$,2),100<$item$$.score&&($item$$.score=100-($item$$.score-100)))}return $item$$};module.exports=model;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
'use strict';const itemSchema=new Schema({code:{type:String,required:!0,maxlength:1024,trim:!0},title:{type:String,required:!0,maxlength:1024},path:{type:String,maxlength:3024,trim:!0},href:{type:String,maxlength:3024,trim:!0},rights:[String],type:{type:String,maxlength:32,trim:!0},dashboard:{type:String,maxlength:1024},horizontal:Boolean,stt:Number,visible:{type:Boolean,default:!0},line:{type:Number,default:0}}),moduleinfoSchema=new Schema({app:{type:String,required:!0,maxlength:1024,
|
|
2
|
-
trim:!0},code:{type:String,required:!0,maxlength:1024,uppercase:!0,trim:!0},title:{type:String,required:!0,maxlength:1024},mother_module:{type:String,maxlength:1024,trim:!0},name_mother_module:{type:String,maxlength:2024},items:[itemSchema],stt:Number,visible:{type:Boolean,default:!0},only_for_companies:[String],not_for_companies:[String],active_require:{type:Boolean,default:!0},allow_users:{type:String},status:{type:Boolean,default:!0},date_created:{type:Date,default:Date.now},
|
|
3
|
-
default:Date.now},user_created:{type:String,default:""},user_updated:{type:String,default:""}});moduleinfoSchema.index({app:1,code:1,moduleinfo:1,mother_module:1});moduleinfoSchema.index({title:"text"});moduleinfoSchema.index({title:1});moduleinfoSchema.index({"items.code":1});moduleinfoSchema.index({status:1});moduleinfoSchema.index({user_created:1,visible_to:1,visible_to_users:1});const model=mongoose.models.menu||mongoose.model("moduleinfo",moduleinfoSchema);
|
|
1
|
+
'use strict';const itemSchema=new Schema({code:{type:String,required:!0,maxlength:1024,trim:!0},title:{type:String,required:!0,maxlength:1024},path:{type:String,maxlength:3024,trim:!0},href:{type:String,maxlength:3024,trim:!0},rights:[String],type:{type:String,maxlength:32,trim:!0},dashboard:{type:String,maxlength:1024},horizontal:Boolean,stt:Number,icon:String,visible:{type:Boolean,default:!0},line:{type:Number,default:0}}),moduleinfoSchema=new Schema({app:{type:String,required:!0,maxlength:1024,
|
|
2
|
+
uppercase:!0,trim:!0},code:{type:String,required:!0,maxlength:1024,uppercase:!0,trim:!0},title:{type:String,required:!0,maxlength:1024},mother_module:{type:String,maxlength:1024,trim:!0},name_mother_module:{type:String,maxlength:2024},items:[itemSchema],stt:Number,visible:{type:Boolean,default:!0},only_for_companies:[String],not_for_companies:[String],active_require:{type:Boolean,default:!0},allow_users:{type:String},icon:String,status:{type:Boolean,default:!0},date_created:{type:Date,default:Date.now},
|
|
3
|
+
date_updated:{type:Date,default:Date.now},user_created:{type:String,default:""},user_updated:{type:String,default:""}});moduleinfoSchema.index({app:1,code:1,moduleinfo:1,mother_module:1});moduleinfoSchema.index({title:"text"});moduleinfoSchema.index({title:1});moduleinfoSchema.index({"items.code":1});moduleinfoSchema.index({status:1});moduleinfoSchema.index({user_created:1,visible_to:1,visible_to_users:1});const model=mongoose.models.menu||mongoose.model("moduleinfo",moduleinfoSchema);
|
|
4
|
+
module.exports=model;
|
package/server/models/okr.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
'use strict';const okrSchema=new Schema({id_app:{type:String,required:!0,maxlength:1024},id_link:{type:String,maxlength:1024},title:{type:String,required:!0,maxlength:1024},type:{type:String,maxlength:1024},ma_bp:{type:String},phu_trach:String,ten_phu_trach:String,attends:[],description:{type:String,maxlength:4E3},start_date:Date,due_date:Date,color:String,id_parent:{type:String,maxlength:1024},exfields:Schema.Types.Mixed,status:{type:Boolean,default:!0},date_created:{type:Date,default:Date.now},
|
|
2
|
-
date_updated:{type:Date,default:Date.now},user_created:{type:String,default:""},user_updated:{type:String,default:""},visible_to:{type:Number,default:0},visible_to_users:[String],update_right:[String],delete_right:[String]});okrSchema.index({id_app:1});okrSchema.index({id_link:1});okrSchema.index({id_parent:1});okrSchema.index({phu_trach:1});okrSchema.index({ten_phu_trach:1});okrSchema.index({title:1});okrSchema.index({description:1});
|
|
2
|
+
date_updated:{type:Date,default:Date.now},user_created:{type:String,default:""},user_updated:{type:String,default:""},visible_to:{type:Number,default:0},visible_to_users:[String],visible_to_usergroups:[String],update_right:[String],delete_right:[String]});okrSchema.index({id_app:1});okrSchema.index({id_link:1});okrSchema.index({id_parent:1});okrSchema.index({phu_trach:1});okrSchema.index({ten_phu_trach:1});okrSchema.index({title:1});okrSchema.index({description:1});
|
|
3
3
|
okrSchema.index({phu_trach:"text",ten_phu_trach:"text",title:"text",description:"text"},{name:"okr_index_text"});okrSchema.index({attends:1});okrSchema.index({status:1});okrSchema.index({user_created:1,visible_to:1,visible_to_users:1});const model=mongoose.models.okr||mongoose.model("okr",okrSchema);
|
|
4
4
|
model.referenceKeys={_id:[{model:"okr",key:"id_parent",error:"B\u1ea1n ph\u1ea3i xo\u00e1 t\u1ea5t c\u1ea3 m\u1ee5c ti\u00eau con c\u1ee7a m\u1ee5c ti\u00eau n\u00e0y tr\u01b0\u1edbc khi xo\u00e1 n\u00f3"},{model:"keyresult",key:"id_link",error:"B\u1ea1n ph\u1ea3i xo\u00e1 t\u1ea5t c\u1ea3 k\u1ebft qu\u1ea3 c\u1ed1t l\u00f5i c\u1ee7a m\u1ee5c ti\u00eau n\u00e0y tr\u01b0\u1edbc khi xo\u00e1 n\u00f3"}]};module.exports=model;
|