Execute (TSearchAction)

De Wiki1000

<source lang='delphi'>Function Execute(action:TjsonStruct; resp:TJson):boolean;</source>

Cette fonction exécute l'action et peut retourner une facet qui sera affichée dans le panneau ouvert par l'action.


Paramètre Usage
action Une structure json qui comprend les paramètres du résultat de la recherche
resp Une structure json en réponse
Result True si l'action a été exécutée

Exemple :

<source lang="delphi"> //function Action_piece_ecritures.Execute(action:TjsonStruct; resp:TJson):boolean; Type

 vueEcriture = viewOf(TEcriture)
  oidPiece:TOID = oidPiece;
  numero:Integer = numero; 
  // 
  codeCompte:string = compteGeneral.codeCompte; 
  libelleCompte:string = compteGeneral.Caption;
  idCompteGeneral:TOID = oidCompteGeneral;
  // 
  codeTiers:string = roleTiers.+Tiers.+Code; 
  libelleTiers:string = roleTiers.+Tiers.+Caption;
  idRoleTiers:TOID = oidRoleTiers;
  idTiers:TOID = roleTiers.+oidTiers; 
  //
  libelleEcriture:String = Caption; 
  debit:TMoneyDT = debit;
  credit:TMoneyDT = credit; 
  //
  dateLettrage:TDatetime = dateLettrage; 
  lettre:String = lettrageEcriture.+lettre; 
  //
  profilTVA:String = ProfilTVA.+Caption; 
  dateDeclarationTVA:TDatetime = DeclarationTVALigne.+DeclarationTVA.+dDate; 
 end;
function _GetTitle():string;
begin
  Result := Format(_TP('Ecritures pour la pièce %s'),[
    action.param.KeyValue['numero'],
  ]); 
end; 

var itemId:string; vSel:TSelector; inst:vueEcriture;

   idx,idv,idr,limits:Integer; SF,ST,SR:TjsonStruct; SA:TjsonArray;

begin

 Result := FALSE;
 // This is TPiece oid 
 if action.Exists('param.itemId') 
  then itemId := action.param.itemId
  else itemId := ; 
 if itemId= then Exit; 
 SR := resp.AddStruct('panel','{panelId:"ecritures-'+itemId+'", title:"'+_GetTitle+'"}');
 /////////////////////////////////////
 SR.addStruct('layout','{ name:"body" }');
 SF := FacetBuilder.AddFacet(SR,'body','list',);
 ST := FacetBuilder.AddValueTable(SF,_GetTitle,); 
 SA := ST.table.columnDefs; 
 SA.AddStruct('{field:"n", headerName:"'+_TP('Numéro')+'", width:100}'); 
 SA.AddStruct('{field:"a", headerName:"'+_TP('Compte')+'", cellRenderer: "linkRenderer" }'); 
 SA.AddStruct('{field:"b", headerName:"'+_TP('Tiers')+'", cellRenderer: "linkRenderer" }'); 
 SA.AddStruct('{field:"c", headerName:"'+_TP('Débit')+'", width:160}'); 
 SA.AddStruct('{field:"d", headerName:"'+_TP('Crédit')+'", width:160}');
 SA.AddStruct('{field:"e", headerName:"'+_TP('Libellé')+'"}');
 SA.AddStruct('{field:"f", headerName:"'+_TP('Date lettrage')+'", width:132}');
 SA.AddStruct('{field:"g", headerName:"'+_TP('Lettrage')+'", width:100}');
 SA.AddStruct('{field:"h", headerName:"'+_TP('Profil de TVA')+'"}');
 SA.AddStruct('{field:"i", headerName:"'+_TP('Déclaration TVA')+'"}');
 SA := ST.table.rows; 
  
 idr := 0; limits := -1;
 vSel := vueEcriture.CreateSelector('(oidPiece=%1)', , false, [itemId]);
 foreach inst in vSel.AsCursor do
  begin
    SA.addDatum('id',,opeDatumSet,['id','n','a','b','c','d','e','f','g','h','i'],[
     inst.oid, 
     inst.numero, 
     _FormatLinkObject(_FormatTitle(inst.codeCompte,inst.libelleCompte),Format(_TP('Compte géénrale %s'),[inst.codeCompte]),inst.idCompteGeneral), 
     _FormatLinkObject(_FormatTitle(inst.codeTiers,inst.libelleTiers),Format(_TP('Tiers %s'),[inst.codeTiers]),inst.idTiers), 
     _FormatMontant(inst.debit),
     _FormatMontant(inst.credit),
     inst.libelleEcriture, 
     _FormatDateObject(inst.dateLettrage),
     inst.lettre, 
     inst.profilTVA, 
     _FormatDate(inst.dateDeclarationTVA)
    ]);
    idr := idr+1; 
    if idr=limits then break; 
  end; 


 Result := True;

end; </source>

Voir aussi :

{{#if:TSearchAction (class)|

{{#if:TSearchAction (class)|— TSearchAction (class) |}} — Développement DSM

|

{{#if:|— [[{{{1}}}]] |}} — Développement DSM

}}