CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMember (Moderator: Deepak Srivastava) »
  • How to create calculated field values - Newbie Q
Pages: [1]

Author Topic: How to create calculated field values - Newbie Q  (Read 1469 times)

macsmith

  • I’m new here
  • *
  • Posts: 3
  • Karma: 0
  • CiviCRM version: 4.3.2
  • CMS version: joomla 3.1.1
  • MySQL version: 14.4
  • PHP version: 5.3.5-1
How to create calculated field values - Newbie Q
May 09, 2013, 06:32:16 am
Totally new to CiviCRM.  We are a Co-operative and are preparing for a public share offer.  I see CiviCRM as a way to manage subsequent shareholding members of our co-op.  I have installed it on joomla.

The first puzzle, for me, is how to control the share certificate numbering.  I imagine that somewhere in Mysql, there will be a value for the next available share number.  When adding a new member to Civi, I would like to include the number of shares bought (for example 10).  As part of the process of Civi adding the member, it should get the value for the next available share (for example, 42), calculate the new share number range (for example, 42 to 51) and adjust the value of next available share number in the DB (for example 52).

Any pointers would be very useful.

Thanks

macsmith

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: How to create calculated field values - Newbie Q
May 09, 2013, 05:44:19 pm
Interesting.  Out of the box, CiviCRM does not have the concept of shares or the concept of a general entity that you could define as a share, so if you requirement is to have shares with autogenerated consecutive numbers that you can assign to people, that won't be possible out of the box.

If you can code, you could write some custom code that hooked into the membership process and assigned specific shares to people as per your requirements.  You would also want to code the interface that exposes that to admins and front end users, etc.  I don't think it would be a trivial undertaking.

There might be another way you could consider going about this using already existing CiviCRM objects, but off the top of my head, I can't think of a way to do this that would meet your needs - someone else might have a better idea.
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

nicolas

  • I post occasionally
  • **
  • Posts: 92
  • Karma: 6
    • cividesk
  • CiviCRM version: 4.4 LTS
  • CMS version: Standalone (yep)
  • MySQL version: 5.1
  • PHP version: 5.3
Re: How to create calculated field values - Newbie Q
May 09, 2013, 08:40:08 pm
If you are not adverse to programing you could easily write an extension that leverages the 'civicrm_pre' hook to calculate the value of the share numbers. See: http://wiki.civicrm.org/confluence/display/CRMDOC43/hook_civicrm_pre
cividesk -- CiviCRM delivered ... your way!

macsmith

  • I’m new here
  • *
  • Posts: 3
  • Karma: 0
  • CiviCRM version: 4.3.2
  • CMS version: joomla 3.1.1
  • MySQL version: 14.4
  • PHP version: 5.3.5-1
Re: How to create calculated field values - Newbie Q
May 09, 2013, 11:59:44 pm
I can program and can see an example for civicrm_post which helps.  I'll have a play around with these. 

How do you ensure that the field calls the hook which calls your code?

Thanks

Macsmith

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: How to create calculated field values - Newbie Q
May 10, 2013, 05:20:06 am
It's not the "field" that calls the hook, rather the system. When a page is saved or rendered (depending on which hook) then the hook is called and all fields are passed.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

macsmith

  • I’m new here
  • *
  • Posts: 3
  • Karma: 0
  • CiviCRM version: 4.3.2
  • CMS version: joomla 3.1.1
  • MySQL version: 14.4
  • PHP version: 5.3.5-1
Re: How to create calculated field values - Newbie Q
May 10, 2013, 05:36:11 am
ok, thanks.  How then do I "register" my code with the hook.  Presumably this is covered somewhere in the documentation...

Thanks

Macsmith

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: How to create calculated field values - Newbie Q
May 10, 2013, 05:39:04 am
http://wiki.civicrm.org/confluence/display/CRMDOC43/Example+Joomla+Plugin+for+implementing+hooks
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMember (Moderator: Deepak Srivastava) »
  • How to create calculated field values - Newbie Q

This forum was archived on 2017-11-26.