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) »
  • General Discussion (please no support requests here!) (Moderator: Michał Mach) »
  • Work flow advice
Pages: [1]

Author Topic: Work flow advice  (Read 3372 times)

alfred_nutile

  • Ask me questions
  • ****
  • Posts: 464
  • Karma: 14
    • River Valley Tech Collective
Work flow advice
October 04, 2007, 09:28:18 am
The goal is this.
The user wants to enter a new person.
First they look to see if the Org that person is related to is already in our DB.
If it is then from there they should be able to click Add New Person which brings over the Orgs Phone and Address while at the same time the Org Name/ID so when the person is created that person also has this data and relationship.

Any thoughts on the best way to do this?
Profiles with a redirect?

I am using drupal.

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: Work flow advice
October 04, 2007, 01:21:42 pm

I suspect u'll need to add some custom code to do this. For a profile redirect, you'll need to figure out how to retrieve the orgs values and send them as part of the the profile request. Profile forms can accept default values via the GET params

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

alfred_nutile

  • Ask me questions
  • ****
  • Posts: 464
  • Karma: 14
    • River Valley Tech Collective
Re: Work flow advice
October 04, 2007, 04:14:12 pm
So will will try doing what I can in drupal and then if need be work into Civicrm.
Step one
Search via civicrm for Org
Person finds Org
Clicks on Org
The next page, ie civicrm contact page then has a block on the right (drupal)
that takes the CID and gets the needed information.
Then there is a link that says click here to add person.
This sends them to the profile page with the matching info
Org Name --> Populates the Profile -> Indiviudal Current Employer
Org Address --> Populates the profile field for Work address
Org Phone --> Populates the profiles field for Work phone
???
Any thoughts

alfred_nutile

  • Ask me questions
  • ****
  • Posts: 464
  • Karma: 14
    • River Valley Tech Collective
Re: Work flow advice
October 09, 2007, 05:48:33 am
Things are working good with this work flow. 
But if a Required field is left blank, instead of coming back and outlining the field or going to the real profile page and outlining in red what is missed it logs me out of drupal.
Now I know I am missing something.
I took the profile stand alone text and made a block with it that has this code.  It makes a form in a block that dynamically pulls in the menus for Custom Data and Groups.  I would guess this is my problem?
The goal is that they get data pre-filled in the form to carry over the orgs State, Phone etc.
Also creating a simplified way to enter the data.
I assume overall I need to create the form properly using the Drupal form method then use it's validation to make this happen?
Thanks
Code: [Select]
<?php
/**
* @file
* Make a block on the right so if people are looking at an org
* they can quick add a person
*/

/**
* This will create the main block 
*/

function quickaddindividual_block($op = 'list', $delta = 0, $edit = array()){
switch ($op) {
case 'list':
$blocks[0]['info'] = t('Quick Add CiviCRM Individual');
return $blocks;


case 'view':
//if org then show this
if($delta == 0) {
$this_page = drupal_get_path_alias($_GET['q']);
//first make sure it is not a non-session setting page
//node 5 6 9 and contact/
$url_parts = split("/", $this_page);
$dashboard = $url_parts[$num_parts-1];
$civicrm = $url_parts[$num_parts-0];
//if( ($civicrm == 'civicrm') && ($dashboard != 'dashboard') ) 
//if( (isset($_GET[cid])) && (!isset($_GET[action])) || (isset($_GET[cid])) && ($_GET[action] == view) ) {
if( (isset($_GET[cid])) && ($_GET[action] != update) ) {
//find out if cid is an org
$cid = $_GET[cid];
$sql = get_org();
$result = db_query($sql, $cid);
while ($data = db_fetch_object($result)){
$orgname = $data->organization_name;
}
$total = db_num_rows($result);
//echo "$total of prod";
if($total != 0) { 
//echo "<br>This is an Org<br>"; 
$org_status = true;
//$results = db_result(db_query($sql, $civiid));
$sql = "
SELECT l. * , o.organization_name AS Orgname, a.street_address AS Steet, a.supplemental_address_1 AS SuppOne, a.city AS City, s.name AS State, a.state_province_id AS state_id, phone.phone AS Phone, a.id as AddressID
FROM civi_crm18.civicrm_location AS l
LEFT JOIN civi_crm18.civicrm_address AS a ON a.location_id = l.id
LEFT JOIN civi_crm18.civicrm_organization AS o ON o.contact_id = l.entity_id
LEFT JOIN civi_crm18.civicrm_state_province AS s ON s.id = a.state_province_id
LEFT JOIN civi_crm18.civicrm_phone AS phone ON phone.location_id = l.id
WHERE l.entity_id = %d AND state_province_id IS NOT NULL"
;
//TODO LIST
//need to make it so null still gets name
//get phone
//
$result = db_query($sql, $cid);
while ($data = db_fetch_object($result)){
$orgname = $data->Orgname;
$street = $data->Steet;
$supp = $data->SuppOne;
$city = $data->City;
$state = $data->State;
$state_id = $data->state_id;
$phone = $data->Phone;
//$last_name = $data->last_name;
//echo "<br>$organization_name<br>";
}

$output = "
<form  action=\"http://nationalpriorities.org/cms/civicrm/profile/create&amp;gid=10&amp;reset=1\" method=\"post\" name=\"Edit\" id=\"Edit\" >
<input name=\"postURL\" type=\"hidden\" value=\"\" />
<input name=\"cancelURL\" type=\"hidden\" value=\"http://nationalpriorities.org/cms/civicrm/profile?reset=1&amp;gid=10\" />
First Name<br>
<input maxlength=\"64\" size=\"30\" name=\"first_name\" type=\"text\" id=\"first_name\" class=\"form-text big\" />
<br>Last Name<br>
<input maxlength=\"64\" size=\"30\" name=\"last_name\" type=\"text\" id=\"last_name\" class=\"form-text big\" /><br>Email<br><input maxlength=\"64\" size=\"30\" name=\"email-Primary\" type=\"text\" id=\"email-Primary\" class=\"form-text big\" /><br>
Job Title<br><input maxlength=\"64\" size=\"30\" name=\"job_title\" type=\"text\" id=\"job_title\" class=\"form-text big\" /><br>

Phone<br>
<input value=\"
$phone\"maxlength=\"32\" size=\"20\" name=\"phone-Primary-Phone\" type=\"text\" id=\"phone-Primary-Phone\" class=\"form-text medium\" /><br>
Current Employer<br>
<input maxlength=\"125\" size=\"30\" name=\"organization_name\" type=\"text\" id=\"organization_name\" class=\"form-text huge\" value=\"
$orgname\"/><br>
  Street Address<br><input maxlength=\"96\" size=\"30\" name=\"street_address-Primary\" type=\"text\" id=\"street_address-Primary\" class=\"form-text huge\" value=\"
$street\"/><br>Supplemental Address 1<br><input maxlength=\"96\" size=\"30\" name=\"supplemental_address_1-Primary\" type=\"text\" id=\"supplemental_address_1-Primary\" class=\"form-text huge\" value=\"$supp\" /><br>City<br><input maxlength=\"64\" size=\"30\" name=\"city-Primary\" type=\"text\" id=\"city-Primary\" class=\"form-text big\" value=\"$city\"/ /><br>State <br><select name=\"state_province-Primary\" id=\"state_province-Primary\" class=\"form-select\">
<option value=\"\">- select -</option>"
;

//get the state and match to the org state_id
$sql = "
SELECT id, name
FROM civi_crm18.civicrm_state_province
WHERE country_id = 1228
"
;
$result = db_query($sql);
while ($data = db_fetch_object($result)){
$id = $data->id;
$state = $data->name;
if($id == $state_id){
$output .= "<option selected value=\"$id\">$state</option>";
} else {
$output .= "<option value=\"$id\">$state</option>";
}
}

//end state area

$output .= "</select>
<!-- end the personal info area -->
<br>PersonType
<span class=\"marker\" title=\"This field is required.\">*</span><br><select name=\"custom_10\" id=\"custom_10\" class=\"form-select required\"><option value=\"\">- select -</option>"
;
$output .= civicrm_type();
$output .= "
</select>
<br>Interests<span class=\"marker\" title=\"This field is required.\">*</span><br>"
;
$output .= civicrm_interests();
$output .= "
<br>
 Mailing Lists<span class=\"marker\" title=\"This field is required\".>*</span><br>"
;
//now make the pulldown for group

//get the state and match to the org state_id
$sql = "
SELECT id, name
FROM civi_crm18.civicrm_group
WHERE name LIKE 'General%'
OR name LIKE 'Media%'
"
;
$result = db_query($sql);
while ($data = db_fetch_object($result)){
$id = $data->id;
$group = $data->name;
$output .= "<input name=\"group[$id]\" type=\"checkbox\" value=\"1\" id=\"qf_ea7357\" class=\"form-checkbox\" /> $group<br>
"
;
}

//end state area


$output .="
<div class=\"crm-submit-buttons\"><input class=\"form-submit default\" name=\"_qf_Edit_next\" value=\"Save\" type=\"submit\" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input class=\"form-submit default\" name=\"_qf_Edit_cancel\" value=\"Cancel\" type=\"submit\" /> 
</form>
"
;
} else { 
//echo "<br>This is an Individual<br>" ; 
$org_status = false;
}
$block['title'] = t('Quick Add CiviCRM Individual');
$block['content'] = $output;
}
}
return $block;
} //end switch
} //end function module
?>


« Last Edit: October 09, 2007, 06:01:41 am by alfred_nutile »

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • General Discussion (please no support requests here!) (Moderator: Michał Mach) »
  • Work flow advice

This forum was archived on 2017-11-26.