Page 1 of 1

Plugin enabling

PostPosted: Fri Dec 16, 2016 11:49 am
by Professional
Hi,
Is there a simple way to not execute a plugin under certain circumstances or is it a matter of checking for that somewhere in the code?
For example say the Sales Order Customer Panel Plugin and you don't want that to appear for Cash Only customers but do for account customers.
Thanks,
Jeff

Re: Plugin enabling  Topic is solved

PostPosted: Sat Dec 17, 2016 12:05 pm
by Mike.Sheen
Hi Jeff,

You would need to modify the plugin to hide or show the panel based on the debtor.

By adding a handler in the ReadEnd and CreateEnd events you can examine the debtor and then set the splitter control for the customer panel to be expanded or not.

With our current plugin we already do listen to the ReadEnd and CreateEnd events, so you can just modify that - so for example in the ReadEnd it currently looks like this:
Code: Select all
Public Sub SalesOrder_ReadCompleted(sender As Object, e As System.EventArgs)
   ReadCustomerSalesHistory()
   DisplayProductDetailsForRow(0)             
End Sub


Changing it to the below will hide the panel when the AccountNo is "1001":
Code: Select all
Public Sub SalesOrder_ReadCompleted(sender As Object, e As System.EventArgs)
   ReadCustomerSalesHistory()
   DisplayProductDetailsForRow(0)
      
   Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = sender
   If salesOrder.Debtor.AccountNo = "1001" Then
      Splitter.Collapsed = True
   Else
      Splitter.Collapsed = False         
   End If                
End Sub


Attached is a plugin demonstrating this. Disable the standard Customer Panel plugin, import the attached and search for "1001" and change that to be the account no you're using for cash sales (there will be two places "1001" occurs - the methods SalesOrder_ReadCompleted and SalesOrder_Created), then save and log out and log back in.

Mike

Re: Plugin enabling

PostPosted: Mon Dec 19, 2016 3:25 pm
by Professional
Thanks Mike That's a big help Cheers