Line 88:
Line 88:
= Conditions on fields selection =
= Conditions on fields selection =
−
Conditions can be categorized into 3 types:
+
Sometimes you may want to show a DropdownBox or Constraint (or another multi-choice type), but you may want to show or hide choices based on conditions (eg: only if it's a prospect, only if this zone was selected, only if this category was selected, etc..).
−
* static (view on only prospect)
+
To know which is the best solution you should choose to implement your condition, you should first know in which category your condition falls in.
−
* semi-dynamic (static table but based on the value of another field/customfield, like manub/rossy)
+
−
* dynamic (based on another subfield of a field of the current module, like mermoz)
+
== Conditions categories ==
+
+
Conditions can be categorized into 4 types:
+
+
* static condition: choices are restrained on a condition that never changes (eg: only show third-parties that are suppliers, or lowercase all data on sql insertion, or check that a field is above a certain number, etc.).
+
* semi-dynamic condition: choices that are constrained on a static table but based on the value of another field/customfield.
+
* dynamic: everything is dynamic: choices are based on a subfield of a field of the current module, so that there's no material table and it's impossible to create a view (because you would need to create one view per id) (eg: show only the contacts attached to the third-party being accessed)
+
* timed condition: a condition that is based on time or recurrence (eg: at 5:00 AM delete old records, etc..)
+
+
== Conditions solutions ==
+
+
Now that you know what kind of condition you want to set, you can choose one of the following solutions depending on your preferences and knowledge:
+
+
=== Static condition ===
+
+
* View: create a view on the table based on the condition, and then create a custom field constrained on this view (which is just like any table), eg: only show third-parties that are suppliers:
+
<source lang="php">
+
CREATE VIEW llx_societe_supplier_view AS
+
SELECT *
+
FROM llx_societe
+
WHERE fournisseur=1;
+
</source>
+
* Check
+
* Trigger
+
* SQL Transformations
+
+
=== Semi-dynamic condition ===
+
+
* View
+
* Check
+
* Trigger
+
* Overload functions
+
+
=== Dynamic condition ===
+
+
* Overload functions
+
* Making your own module, which calls the CustomFields class
+
+
=== Timed condition ===
+
+
* SQL scheduled events
+
* Cron job
+
* CustomFields's Overload functions
= Overloading functions =
= Overloading functions =