@@ -338,6 +338,97 @@ Object GetDTS()
338338 return result ;
339339 }
340340 }
341+ static class DebtDetailDialog extends SLib .SlDialog {
342+ CmdROrderPrereqActivity ActivityCtx ;
343+ public DebtDetailDialog (Context ctx , Object data )
344+ {
345+ super (ctx , R .id .DLG_DEBTDETAILLIST , data );
346+ if (ctx instanceof CmdROrderPrereqActivity )
347+ ActivityCtx = (CmdROrderPrereqActivity )ctx ;
348+ if (data instanceof BusinessEntity .ArDebtList )
349+ Data = data ;
350+ }
351+ @ Override public Object HandleEvent (int ev , Object srcObj , Object subj )
352+ {
353+ Object result = null ;
354+ switch (ev ) {
355+ case SLib .EV_CREATE :
356+ requestWindowFeature (Window .FEATURE_NO_TITLE );
357+ setContentView (R .layout .dialog_debtdetaillist );
358+ SetDTS (Data );
359+ break ;
360+ case SLib .EV_COMMAND :
361+ if (srcObj != null && srcObj instanceof View ) {
362+ final int view_id = ((View ) srcObj ).getId ();
363+ if (view_id == R .id .STDCTL_CLOSEBUTTON ) {
364+ this .dismiss ();
365+ }
366+ }
367+ break ;
368+ case SLib .EV_LISTVIEWCOUNT :
369+ {
370+ SLib .RecyclerListAdapter a = (SLib .RecyclerListAdapter )srcObj ;
371+ if (a .GetListRcId () == R .id .CTL_DEBTDETAILLIST_LIST ) {
372+ BusinessEntity .ArDebtList _data = (Data != null && Data instanceof BusinessEntity .ArDebtList ) ? (BusinessEntity .ArDebtList )Data : null ;
373+ result = new Integer ((_data != null && _data .List != null ) ? _data .List .size () : 0 );
374+ }
375+ }
376+ break ;
377+ case SLib .EV_GETLISTITEMVIEW :
378+ {
379+ SLib .ListViewEvent ev_subj = (subj instanceof SLib .ListViewEvent ) ? (SLib .ListViewEvent ) subj : null ;
380+ if (ev_subj != null && ev_subj .ItemIdx >= 0 ) {
381+ if (ev_subj .RvHolder != null ) {
382+ // RecyclerView
383+ if (SLib .IsRecyclerListAdapter (srcObj )) {
384+ SLib .RecyclerListAdapter a = (SLib .RecyclerListAdapter )srcObj ;
385+ if (a .GetListRcId () == R .id .CTL_DEBTDETAILLIST_LIST ) {
386+ BusinessEntity .ArDebtList _data = (Data != null && Data instanceof BusinessEntity .ArDebtList ) ? (BusinessEntity .ArDebtList )Data : null ;
387+ if (_data != null && _data .List != null && ev_subj .ItemIdx < _data .List .size ()) {
388+ //CPM.FindGoodsItemByGoodsID()
389+ BusinessEntity .DebtEntry cur_entry = _data .List .get (ev_subj .ItemIdx );
390+ View iv = ev_subj .RvHolder .itemView ;
391+ SLib .SetCtrlString (iv , R .id .CTL_DEBTDETAILLISTITEM_CODE , cur_entry .BillCode );
392+ SLib .SetCtrlString (iv , R .id .CTL_DEBTDETAILLISTITEM_DATE , cur_entry .BillDate .Format (SLib .DATF_DMY ));
393+ SLib .SetCtrlString (iv , R .id .CTL_DEBTDETAILLISTITEM_AMOUNT , SLib .formatdouble (cur_entry .Amount , 2 ));
394+ SLib .SetCtrlString (iv , R .id .CTL_DEBTDETAILLISTITEM_DEBT , SLib .formatdouble (cur_entry .Debt , 2 ));
395+ }
396+ }
397+ }
398+ }
399+ }
400+ }
401+ break ;
402+
403+ }
404+ return result ;
405+ }
406+ boolean SetDTS (Object objData )
407+ {
408+ boolean ok = true ;
409+ StyloQApp app_ctx = (ActivityCtx != null ) ? ActivityCtx .GetAppCtx () : null ;
410+ if (app_ctx != null ) {
411+ //Context ctx = getContext();
412+ BusinessEntity .ArDebtList _data = (Data != null && Data instanceof BusinessEntity .ArDebtList ) ? (BusinessEntity .ArDebtList )Data : null ;
413+ if (_data != null ) {
414+ String hint_text = _data .ArName ; // @todo
415+ SLib .SetCtrlString (this , R .id .CTL_DEBTDETAILLIST_HEADER , hint_text );
416+ View lv = findViewById (R .id .CTL_DEBTDETAILLIST_LIST );
417+ if (lv != null && lv instanceof RecyclerView ) {
418+ ((RecyclerView )lv ).setLayoutManager (new LinearLayoutManager (ActivityCtx ));
419+ SLib .RecyclerListAdapter adapter = new SLib .RecyclerListAdapter (ActivityCtx , this , R .id .CTL_DEBTDETAILLIST_LIST , R .layout .li_debtdetaillist );
420+ ((RecyclerView ) lv ).setAdapter (adapter );
421+ }
422+ }
423+ }
424+ return ok ;
425+ }
426+ Object GetDTS ()
427+ {
428+ Object result = Data ;
429+ return result ;
430+ }
431+ }
341432 int FindClientItemIndexByID (int id )
342433 {
343434 int result = -1 ;
@@ -907,20 +998,36 @@ else if(vg_id == R.id.LAYOUT_ORDERPREPREQ_ORDR) {
907998 CommonPrereqModule .CliEntry cur_entry = (CommonPrereqModule .CliEntry )CPM .CliListData .get (ev_subj .ItemIdx );
908999 final int cur_cli_id = cur_entry .JsItem .optInt ("id" , 0 );
9091000 SLib .SetCtrlString (iv , R .id .LVITEM_GENERICNAME , cur_entry .JsItem .optString ("nm" , "" ));
910- if (DbtL != null ) {
911- SLib .SetCtrlVisibility (iv , R .id .LAYOUT_ORDERPREREQ_CLI_DEBT , View .VISIBLE );
912- BusinessEntity .DebtList .ShortReplyEntry de = DbtL .GetDebt (cur_cli_id );
913- String text ;
914- if (de != null ) {
915- text = "debt" + ": " + SLib .formatdouble (de .Debt , 2 );
1001+ {
1002+ View v_debt_text = iv .findViewById (R .id .CTL_ORDERPREREQ_CLI_DEBT );
1003+ if (DbtL != null ) {
1004+ SLib .SetCtrlVisibility (iv , R .id .LAYOUT_ORDERPREREQ_CLI_DEBT , View .VISIBLE );
1005+ BusinessEntity .DebtList .ShortReplyEntry de = DbtL .GetDebt (cur_cli_id );
1006+ if (v_debt_text != null ) {
1007+ String text ;
1008+ int shaperc = 0 ;
1009+ if (de != null ) {
1010+ final boolean is_expired = de .IsExpired (CmdQueryDebt );
1011+ if (de .Debt > 0 ) {
1012+ shaperc = is_expired ? R .drawable .shape_debtvalue_undef : R .drawable .shape_debtvalue_positive ;
1013+ text = SLib .formatdouble (de .Debt , 2 );
1014+ }
1015+ else {
1016+ shaperc = is_expired ? R .drawable .shape_debtvalue_undef : R .drawable .shape_debtvalue_zero ;
1017+ text = is_expired ? "0" : "" ;
1018+ }
1019+ }
1020+ else {
1021+ shaperc = R .drawable .shape_debtvalue_undef ;
1022+ text = "" ;
1023+ }
1024+ v_debt_text .setBackground (getResources ().getDrawable (shaperc , getTheme ()));
1025+ SLib .SetCtrlString (iv , R .id .CTL_ORDERPREREQ_CLI_DEBT , text );
1026+ }
9161027 }
9171028 else {
918- text = "???" ;
1029+ SLib . SetCtrlVisibility ( iv , R . id . LAYOUT_ORDERPREREQ_CLI_DEBT , View . GONE ) ;
9191030 }
920- SLib .SetCtrlString (iv , R .id .CTL_ORDERPREREQ_CLI_DEBT , text );
921- }
922- else {
923- SLib .SetCtrlVisibility (iv , R .id .LAYOUT_ORDERPREREQ_CLI_DEBT , View .GONE );
9241031 }
9251032 SetListBackground (iv , a , ev_subj .ItemIdx , SLib .PPOBJ_PERSON , cur_cli_id );
9261033 {
@@ -1383,7 +1490,7 @@ else if(ev_subj.ItemView.getId() == R.id.CTL_ORDERPREREQ_CLI_DEBT) {
13831490 final int cur_cli_id = item .JsItem .optInt ("id" , 0 );
13841491 if (cur_cli_id > 0 ) {
13851492 BusinessEntity .DebtList .ShortReplyEntry de = DbtL .GetDebt (cur_cli_id );
1386- if (de == null ) {
1493+ if (de == null || de . IsExpired ( CmdQueryDebt ) ) {
13871494 if (CmdQueryDebt != null ) {
13881495 // query
13891496 boolean force_query = true ;
@@ -1401,6 +1508,13 @@ else if(ev_subj.ItemView.getId() == R.id.CTL_ORDERPREREQ_CLI_DEBT) {
14011508 }
14021509 else {
14031510 // detail
1511+ if (de .Debt > 0.0 ) {
1512+ BusinessEntity .ArDebtList debt_detail = DbtL .GetDebtDetail (cur_cli_id );
1513+ if (debt_detail != null ) {
1514+ DebtDetailDialog dialog = new DebtDetailDialog (this , debt_detail );
1515+ dialog .show ();
1516+ }
1517+ }
14041518 }
14051519 }
14061520 }
@@ -1724,7 +1838,25 @@ else if(srcObj instanceof CommonPrereqModule.RegistryFiltDialog) {
17241838 StyloQApp .InterchangeResult ir = (StyloQApp .InterchangeResult )subj ;
17251839 StyloQApp app_ctx = GetAppCtx ();
17261840 if (ir .OriginalCmdItem != null ) {
1727- if (ir .OriginalCmdItem .Name .equalsIgnoreCase ("PostDocument" )) {
1841+ if (ir .OriginalCmdItem .BaseCmdId == StyloQCommand .sqbcDebtList ) {
1842+ if (ir .ResultTag == StyloQApp .SvcQueryResult .SUCCESS ) {
1843+ if (ir .InfoReply != null && ir .InfoReply instanceof SecretTagPool ) {
1844+ JSONObject js_reply = ((SecretTagPool )ir .InfoReply ).GetJsonObject (SecretTagPool .tagRawData );
1845+ BusinessEntity .ArDebtList ard_list = new BusinessEntity .ArDebtList ();
1846+ if (ard_list .FromJson (js_reply )) {
1847+ if (DbtL .Include (ard_list ) >= 0 ) {
1848+ app_ctx .StoreDebtList (CPM .SvcIdent , DbtL );
1849+ // @todo Здесь достаточно обновить только одну позицию списка, а не весь список!
1850+ NotifyTabContentChanged (CommonPrereqModule .Tab .tabClients , R .id .orderPrereqClientsListView );
1851+ }
1852+ }
1853+ }
1854+ }
1855+ else {
1856+ // @todo
1857+ }
1858+ }
1859+ else if (ir .OriginalCmdItem .Name .equalsIgnoreCase ("PostDocument" )) {
17281860 CPM .CurrentDocument_RemoteOp_Finish ();
17291861 ScheduleRTmr (null , 0 , 0 );
17301862 if (ir .ResultTag == StyloQApp .SvcQueryResult .SUCCESS ) {
0 commit comments