Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM- 20552 #10360

Merged
merged 2 commits into from
Jun 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 4 additions & 61 deletions CRM/Contact/Form/Task/AddToHousehold.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,73 +34,16 @@ class CRM_Contact_Form_Task_AddToHousehold extends CRM_Contact_Form_Task_AddToPa
* Build the form object.
*/
public function buildQuickForm() {

CRM_Utils_System::setTitle(ts('Add Members to Household'));
$this->addElement('text', 'name', ts('Find Target Household'));

$this->add('select', 'relationship_type_id', ts('Relationship Type'),
array(
'' => ts('- select -'),
) +
CRM_Contact_BAO_Relationship::getRelationType("Household"), TRUE
);

$searchRows = $this->get('searchRows');
$searchCount = $this->get('searchCount');
if ($searchRows) {
$checkBoxes = array();
$checkFlag = 0;
foreach ($searchRows as $id => $row) {
if (!$checkFlag) {
$checkFlag = $id;
}
$checkBoxes[$id] = $this->createElement('radio', NULL, NULL, NULL, $id);
}
$this->addGroup($checkBoxes, 'contact_check');
if ($checkFlag) {
$checkBoxes[$checkFlag]->setChecked(TRUE);
}
$this->assign('searchRows', $searchRows);
}

$this->assign('searchCount', $searchCount);
$this->assign('searchDone', $this->get('searchDone'));
$this->assign('contact_type_display', ts('Household'));
$this->addElement('submit', $this->getButtonName('refresh'), ts('Search'), array('class' => 'crm-form-submit'));
$this->addElement('submit', $this->getButtonName('cancel'), ts('Cancel'), array('class' => 'crm-form-submit'));

$this->addButtons(array(
array(
'type' => 'next',
'name' => ts('Add to Household'),
'isDefault' => TRUE,
),
array(
'type' => 'cancel',
'name' => ts('Cancel'),
),
)
);
$this->set('contactType', 'Household');
$this->assign('contactType', 'Household');
parent::buildQuickForm();
}

/**
* Process the form after the input has been submitted and validated.
*/
public function postProcess() {

// store the submitted values in an array
$this->params = $this->controller->exportValues($this->_name);

$this->set('searchDone', 0);
if (!empty($_POST['_qf_AddToHousehold_refresh'])) {
$searchParams['contact_type'] = 'Household';
$searchParams['rel_contact'] = $this->params['name'];
$this->search($this, $searchParams);
$this->set('searchDone', 1);
return;
}

$this->addRelationships();
parent::postProcess();
}

}
66 changes: 4 additions & 62 deletions CRM/Contact/Form/Task/AddToIndividual.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,74 +40,16 @@ class CRM_Contact_Form_Task_AddToIndividual extends CRM_Contact_Form_Task_AddToP
* Build the form object.
*/
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Add Contacts to Individual'));
$this->addElement('text', 'name', ts('Find Target Individual'));

$this->add('select',
'relationship_type_id',
ts('Relationship Type'),
array(
'' => ts('- select -'),
) +
CRM_Contact_BAO_Relationship::getRelationType("Individual"), TRUE
);

$searchRows = $this->get('searchRows');
$searchCount = $this->get('searchCount');
if ($searchRows) {
$checkBoxes = array();
$chekFlag = 0;
foreach ($searchRows as $id => $row) {
if (!$chekFlag) {
$chekFlag = $id;
}

$checkBoxes[$id] = $this->createElement('radio', NULL, NULL, NULL, $id);
}

$this->addGroup($checkBoxes, 'contact_check');
if ($chekFlag) {
$checkBoxes[$chekFlag]->setChecked(TRUE);
}
$this->assign('searchRows', $searchRows);
}

$this->assign('searchCount', $searchCount);
$this->assign('searchDone', $this->get('searchDone'));
$this->assign('contact_type_display', ts('Individual'));
$this->addElement('submit', $this->getButtonName('refresh'), ts('Search'), array('class' => 'crm-form-submit'));
$this->addElement('submit', $this->getButtonName('cancel'), ts('Cancel'), array('class' => 'crm-form-submit'));
$this->addButtons(array(
array(
'type' => 'next',
'name' => ts('Add to Individual'),
'isDefault' => TRUE,
),
array(
'type' => 'cancel',
'name' => ts('Cancel'),
),
)
);
$this->set('contactType', 'Individual');
$this->assign('contactType', 'Individual');
parent::buildQuickForm();
}

/**
* Process the form after the input has been submitted and validated.
*/
public function postProcess() {
// store the submitted values in an array
$this->params = $this->controller->exportValues($this->_name);

$this->set('searchDone', 0);
if (!empty($_POST['_qf_AddToIndividual_refresh'])) {
$searchParams['contact_type'] = 'Individual';
$searchParams['rel_contact'] = $this->params['name'];
$this->search($this, $searchParams);
$this->set('searchDone', 1);
return;
}

$this->addRelationships();
parent::postProcess();
}

}
67 changes: 4 additions & 63 deletions CRM/Contact/Form/Task/AddToOrganization.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,75 +40,16 @@ class CRM_Contact_Form_Task_AddToOrganization extends CRM_Contact_Form_Task_AddT
* Build the form object.
*/
public function buildQuickForm() {
CRM_Utils_System::setTitle(ts('Add Contacts to Organization'));
$this->addElement('text', 'name', ts('Find Target Organization'));

$this->add('select',
'relationship_type_id',
ts('Relationship Type'),
array(
'' => ts('- select -'),
) +
CRM_Contact_BAO_Relationship::getRelationType("Organization"), TRUE
);

$searchRows = $this->get('searchRows');
$searchCount = $this->get('searchCount');
if ($searchRows) {
$checkBoxes = array();
$chekFlag = 0;
foreach ($searchRows as $id => $row) {
if (!$chekFlag) {
$chekFlag = $id;
}

$checkBoxes[$id] = $this->createElement('radio', NULL, NULL, NULL, $id);
}

$this->addGroup($checkBoxes, 'contact_check');
if ($chekFlag) {
$checkBoxes[$chekFlag]->setChecked(TRUE);
}
$this->assign('searchRows', $searchRows);
}

$this->assign('searchCount', $searchCount);
$this->assign('searchDone', $this->get('searchDone'));
$this->assign('contact_type_display', ts('Organization'));
$this->addElement('submit', $this->getButtonName('refresh'), ts('Search'), array('class' => 'crm-form-submit'));
$this->addElement('submit', $this->getButtonName('cancel'), ts('Cancel'), array('class' => 'crm-form-submit'));

$this->addButtons(array(
array(
'type' => 'next',
'name' => ts('Add to Organization'),
'isDefault' => TRUE,
),
array(
'type' => 'cancel',
'name' => ts('Cancel'),
),
)
);
$this->set('contactType', 'Organization');
$this->assign('contactType', 'Organization');
parent::buildQuickForm();
}

/**
* Process the form after the input has been submitted and validated.
*/
public function postProcess() {
// store the submitted values in an array
$this->params = $this->controller->exportValues($this->_name);

$this->set('searchDone', 0);
if (!empty($_POST['_qf_AddToOrganization_refresh'])) {
$searchParams['contact_type'] = 'Organization';
$searchParams['rel_contact'] = $this->params['name'];
$this->search($this, $searchParams);
$this->set('searchDone', 1);
return;
}

$this->addRelationships();
parent::postProcess();
}

}
71 changes: 71 additions & 0 deletions CRM/Contact/Form/Task/AddToParentClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,58 @@ public function preProcess() {
parent::preProcess();
}

public function buildQuickForm() {
$contactType = $this->get('contactType');
CRM_Utils_System::setTitle(ts('Add Contacts to %1', array(1 => $contactType)));
$this->addElement('text', 'name', ts('Find Target %1', array(1 => $contactType)));

$this->add('select',
'relationship_type_id',
ts('Relationship Type'),
array(
'' => ts('- select -'),
) +
CRM_Contact_BAO_Relationship::getRelationType($contactType), TRUE
);

$searchRows = $this->get('searchRows');
$searchCount = $this->get('searchCount');
if ($searchRows) {
$checkBoxes = array();
$chekFlag = 0;
foreach ($searchRows as $id => $row) {
if (!$chekFlag) {
$chekFlag = $id;
}

$checkBoxes[$id] = $this->createElement('radio', NULL, NULL, NULL, $id);
}

$this->addGroup($checkBoxes, 'contact_check');
if ($chekFlag) {
$checkBoxes[$chekFlag]->setChecked(TRUE);
}
$this->assign('searchRows', $searchRows);
}

$this->assign('searchCount', $searchCount);
$this->assign('searchDone', $this->get('searchDone'));
$this->assign('contact_type_display', ts($contactType));
$this->addElement('submit', $this->getButtonName('refresh'), ts('Search'), array('class' => 'crm-form-submit'));
$this->addElement('submit', $this->getButtonName('cancel'), ts('Cancel'), array('class' => 'crm-form-submit'));
$this->addButtons(array(
array(
'type' => 'next',
'name' => ts('Add to %1', array(1 => $contactType)),
'isDefault' => TRUE,
),
array(
'type' => 'cancel',
'name' => ts('Cancel'),
),
)
);
}
/**
* Add relationships from form.
*/
Expand Down Expand Up @@ -210,4 +262,23 @@ public function search(&$form, &$params) {
}
}

/**
* Process the form after the input has been submitted and validated.
*/
public function postProcess() {
// store the submitted values in an array
$this->params = $this->controller->exportValues($this->_name);
$this->set('searchDone', 0);
$contactType = $this->get('contactType');

if (!empty($_POST["_qf_AddTo{$contactType}_refresh"])) {
$searchParams['contact_type'] = $contactType;
$searchParams['rel_contact'] = $this->params['name'];
$this->search($this, $searchParams);
$this->set('searchDone', 1);
return;
}
$this->addRelationships();
}

}
Loading