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 Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Search by URL
Pages: [1]

Author Topic: Search by URL  (Read 1123 times)

bpmccain

  • I post frequently
  • ***
  • Posts: 255
  • Karma: 5
  • CiviCRM version: 4.1
  • CMS version: Drupal 7.12
  • MySQL version: 5.2
  • PHP version: 5.2
Search by URL
November 28, 2012, 01:09:45 pm
I'm wondering if anyone has done anything with CiviCRM where a search could be conducted by URL, with the search parameters passed as GET variables.

So for example www.example.com/civicrm/search?phone=5551112222

Would return a list of all users with that phone number?

I think I could create it, but I thought I would check to see if it was already done. I'm doing some VOIP integration, and have a pop up browser window that will open to a url with the calling phone number embedded in the url (as above). So when someone calls the office, CiviCRM will pop open and list all the contacts with the phone number so that the answerer can quickly make any necessary changes to their record.

Brian

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Search by URL
November 28, 2012, 01:54:06 pm
You can pretty much do this with a profile-driven search, since profiles can take field=value params in the URL. For example, this URL against profile 1 returns records w/ that phone number (assuming a Searchable "Primary Phone" field in that profile):

civicrm/profile?gid=1&reset=1&force=1&phone-Primary-1=430-2975
Protect your investment in CiviCRM by  becoming a Member!

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Search by URL
November 28, 2012, 11:41:48 pm
Sounds like a cool project. Could you blog about it?

asterisk/voip integration is a question that comes from time to time.

-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

bpmccain

  • I post frequently
  • ***
  • Posts: 255
  • Karma: 5
  • CiviCRM version: 4.1
  • CMS version: Drupal 7.12
  • MySQL version: 5.2
  • PHP version: 5.2
Re: Search by URL
November 29, 2012, 04:41:20 am
I will when I get it all finished. It will include Click to Call integration - not just with Asterisk, but also with Twilio (for anyone who is on a POTS).

Going to include a phone version of CiviMail and CiviSMS as well.

Brian

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Search by URL
November 29, 2012, 09:42:39 am
Sounds even nicer ;)

You seem to be on a more broad scope than when Dave suggested you the profile tip.

Another option that needs a bit more dev but brings potentially better UI is to use the api over ajax. You can get (as  json) pretty much any data that you can search on the advanced search, eg search based on the phone number or log a call on a new interface, more focused on your workflow.

I might have a project than involves custom features like normalisation of the phone number (ie be sure it contains the prefix and that the format is correct. Is this something that you have already implemented or plan to?

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Search by URL
November 29, 2012, 10:48:53 am
Xavier - In case you missed this, Coleman has been doing some work towards phone number normalisation for 4.3 (step 1 being to strip out all non-numeric chars and spaces and store in a new column). He also has been 'thinking' about next steps in support of SMS features - so good for you 2 to put heads together as well.
Protect your investment in CiviCRM by  becoming a Member!

bpmccain

  • I post frequently
  • ***
  • Posts: 255
  • Karma: 5
  • CiviCRM version: 4.1
  • CMS version: Drupal 7.12
  • MySQL version: 5.2
  • PHP version: 5.2
Re: Search by URL
November 29, 2012, 04:58:26 pm
That Phone Number normalisation would be something I might be interested in as well. For the click to dial implementation, it is going to be necessary to 'format' all phone numbers in the database with an <a href></a> tag. Could all be tied into that potentially.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Search by URL
November 29, 2012, 07:03:25 pm

Note that the phone number normalization in 4.3 is fairly primitive and basically removed all non-numeric characters from the phone entry, thus allowing an efficient phone search

In future versions, we would like to integrate the phone number library: http://code.google.com/p/libphonenumber/

would be great if you could start looking into and work on this integration

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Search by URL
November 30, 2012, 12:05:33 am
Quote from: bpmccain on November 29, 2012, 04:58:26 pm
That Phone Number normalisation would be something I might be interested in as well. For the click to dial implementation, it is going to be necessary to 'format' all phone numbers in the database with an <a href></a> tag. Could all be tied into that potentially.

For the click to dial on a client, what we did was to do it at the js level on a .extra: find all the dom with a phone class and wrap it with a number. We did a bit of formating too (if the number was without the prefix, add a default country prefix.

Probably not super useful as was specific, but can share the code as example
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Search by URL
November 30, 2012, 12:12:12 am
Quote from: Donald Lobo on November 29, 2012, 07:03:25 pm

In future versions, we would like to integrate the phone number library: http://code.google.com/p/libphonenumber/


Interesting. Maintaining that db is probably quite a task.

It doesn't seem to have a php port yet. The js version could be enough.

For the db model, the phone isn't linked to the address. might be an issue with multiple addresses in multiple locations to normalise the phone numbers.

Anyway, probably covering most of the cases to use the main location to pickup the country and therefore the format
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Search by URL
November 30, 2012, 12:13:42 am

https://github.com/davideme/libphonenumber-for-PHP
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

bpmccain

  • I post frequently
  • ***
  • Posts: 255
  • Karma: 5
  • CiviCRM version: 4.1
  • CMS version: Drupal 7.12
  • MySQL version: 5.2
  • PHP version: 5.2
Re: Search by URL
November 30, 2012, 06:34:18 pm
Xavier - if you could share that code, I would really appreciate it.

Brian

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Search by URL
December 01, 2012, 01:39:25 am
That's the Summary.extra.tpl
You will need to adjust it. As you can see, they have special cases, like internal phone numbers on 3 digit being skipped.

Code: [Select]
<script>
{literal}
cj(function($){
  function normalizePhone(phone) {
    var t= phone.replace(/[^\d.]/g, "");
    if (t.length == 3) {
      return t;
    }
    if (t[0] != "0")
      t = "00" + t;
    return "0"+t;
  }

  $(".crmf-1-phone-1,.crm-contact_phone span").click(function(){
   $("body").append("<iframe id='calling' src='http://asterisk.box/civiCRM/click2dial.php?to="+normalizePhone($(this).text())+"'></iframe>");
  }).attr("title","Click to dial").css( 'cursor', 'pointer' );
});
{/literal}
</script>
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

bpmccain

  • I post frequently
  • ***
  • Posts: 255
  • Karma: 5
  • CiviCRM version: 4.1
  • CMS version: Drupal 7.12
  • MySQL version: 5.2
  • PHP version: 5.2
Re: Search by URL
December 02, 2012, 09:46:35 am
Awesome. I didn't know about the .extra.tpl feature - so I learned two things from this!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Search by URL

This forum was archived on 2017-11-26.