Skip to content

Commit

Permalink
Merge pull request #1058 from civicrm/staging
Browse files Browse the repository at this point in the history
Sync master with integration
  • Loading branch information
AkA84 authored Aug 8, 2016
2 parents 79d617f + 3804c7b commit 9c64032
Show file tree
Hide file tree
Showing 25 changed files with 2,438 additions and 1,310 deletions.
10 changes: 8 additions & 2 deletions bin/drush-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ org.civicrm.hrmed,\
org.civicrm.hrqual,\
org.civicrm.hrvisa,\
org.civicrm.hremergency,\
org.civicrm.hrcareer
org.civicrm.hrcareer,\
uk.co.compucorp.contactaccessrights,\
uk.co.compucorp.civicrm.tasksassignments

## List of extensions defining applications/UIs on top of the basic entity types
APP_EXTS=\
Expand All @@ -32,7 +34,11 @@ org.civicrm.hrim,\
org.civicrm.hrprofile,\
org.civicrm.hrcaseutils,\
org.civicrm.hrrecruitment,\
org.civicrm.reqangular
org.civicrm.reqangular,\
org.civicrm.contactsummary,\
org.civicrm.bootstrapcivicrm,\
org.civicrm.bootstrapcivihr,\
uk.co.compucorp.civicrm.hrnavigation

##################################
## Main
Expand Down
38 changes: 19 additions & 19 deletions com.civicrm.hrjobroles/CRM/Hrjobroles/BAO/HrJobRoles.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,39 +47,39 @@ public static function getContactRoles($cuid) {
}

/**
* Get options for a given job roles field along with their database IDs.
* Check Contact if exist .
*
* @param String $searchValue
* @param String $searchField
* @return Integer ( Contact ID or 0 if not exist)
*/
public static function contactExists($searchValue, $searchField) {
$queryParam = array(1 => array($searchValue, 'String'));
$query = "SELECT id from civicrm_contact where ".$searchField." = %1";
$result = CRM_Core_DAO::executeQuery($query, $queryParam);
return $result->fetch() ? $result->id : 0;
}

/**
* Get option values for specific option group.
*
* @param String $fieldName
*
* @return Array
* @return array
*/
public static function buildDbOptions($fieldName) {
$queryParam = array(1 => array($fieldName, 'String'));
$query = "SELECT cpv.id, cpv.label from civicrm_option_value cpv
$query = "SELECT cpv.value, cpv.label from civicrm_option_value cpv
LEFT JOIN civicrm_option_group cpg on cpv.option_group_id = cpg.id
WHERE cpg.name = %1";
$options = array();
$options = [];
$result = CRM_Core_DAO::executeQuery($query, $queryParam);
while ($result->fetch()) {
$options[] = array( 'id'=>$result->id, 'label'=>strtolower($result->label) );
$options[$result->value] = strtolower($result->label);
}
return $options;
}

/**
* Check Contact if exist .
*
* @param String $searchValue
* @param String $searchField
* @return Integer ( Contact ID or 0 if not exist)
*/
public static function checkContact($searchValue, $searchField) {
$queryParam = array(1 => array($searchValue, 'String'));
$query = "SELECT id from civicrm_contact where ".$searchField." = %1";
$result = CRM_Core_DAO::executeQuery($query, $queryParam);
return $result->fetch() ? $result->id : 0;
}

public static function importableFields() {
$fields = array('' => array('title' => ts('- do not import -')));
return array_merge($fields, static::import());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ class CRM_Hrjobroles_Import_Form_DataSource extends CRM_Core_Form {
public function preProcess() {
$session = CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url('civicrm/jobroles/import'));
// check for post max size
CRM_Core_Config_Defaults::formatUnitSize(ini_get('post_max_size'), TRUE);
}

/**
Expand All @@ -60,8 +58,7 @@ public function preProcess() {
public function buildQuickForm() {
//Setting Upload File Size
$config = CRM_Core_Config::singleton();

$uploadFileSize = CRM_Core_Config_Defaults::formatUnitSize($config->maxFileSize.'m');
$uploadFileSize = $config->maxImportFileSize;
$uploadSize = round(($uploadFileSize / (1024 * 1024)), 2);

$this->assign('uploadSize', $uploadSize);
Expand Down
137 changes: 69 additions & 68 deletions com.civicrm.hrjobroles/CRM/Hrjobroles/Import/Parser/HrJobRoles.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,11 @@ function summary(&$values) {
$session = CRM_Core_Session::singleton();
$dateType = $session->get('dateTypes');

$contractDetails = CRM_Hrjobcontract_BAO_HRJobContract::checkContract($params['job_contract_id']);
$contractDetails = NULL;
if (!empty($params['job_contract_id'])) {
$contractDetails = CRM_Hrjobcontract_BAO_HRJobContract::checkContract($params['job_contract_id']);
}

if (empty($contractDetails)) {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('job contract ID is not found', $errorMessage);
}
Expand All @@ -166,7 +170,7 @@ function summary(&$values) {
foreach($optionValues as $key) {
if (!empty($params[$key])) {
$optionID = $this->getOptionKey($key, $params[$key]);
if ($optionID !== 0) {
if ($optionID !== NULL) {
$params[$key] = $optionID;
} else {
CRM_Contact_Import_Parser_Contact::addToErrorMsg($fields[$key]['title'].' is not found', $errorMessage);
Expand All @@ -177,7 +181,7 @@ function summary(&$values) {
$cost_center_error = FALSE;
if (!empty($params['hrjc_cost_center'])) {
$optionID = $this->getOptionKey('hrjc_cost_center', $params['hrjc_cost_center']);
if ($optionID !== 0) {
if ($optionID !== NULL) {
$params['hrjc_cost_center'] = $optionID;
if (!empty($params['hrjc_cost_center_val_type'])) {
$val = strtolower($params['hrjc_cost_center_val_type']);
Expand Down Expand Up @@ -205,33 +209,35 @@ function summary(&$values) {
$cost_center_error = TRUE;
}

if ($params['hrjc_cost_center_val_type'] === 0 && !$cost_center_error) {
if (!empty($params['hrjc_role_amount_pay_cost_center']) && !empty($params['hrjc_role_percent_pay_cost_center'])) {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('cost center percent amount should be removed', $errorMessage);
}
elseif (!empty($params['hrjc_role_amount_pay_cost_center'])) {
if ( !filter_var($params['hrjc_role_amount_pay_cost_center'], FILTER_VALIDATE_FLOAT) || $params['hrjc_role_amount_pay_cost_center'] < 0) {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('Amount of Pay Assigned to cost center should be positive number', $errorMessage);
if (isset($params['hrjc_cost_center_val_type'])) {
if ($params['hrjc_cost_center_val_type'] === 0 && !$cost_center_error) {
if (!empty($params['hrjc_role_amount_pay_cost_center']) && !empty($params['hrjc_role_percent_pay_cost_center'])) {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('cost center percent amount should be removed', $errorMessage);
}
}
else {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('cost center absolute amount is not set', $errorMessage);
}
$params['hrjc_role_percent_pay_cost_center'] = 0;
}
elseif ($params['hrjc_cost_center_val_type'] === 1 && !$cost_center_error) {
if (!empty($params['hrjc_role_amount_pay_cost_center']) && !empty($params['hrjc_role_percent_pay_cost_center'])) {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('cost center absolute amount should be removed', $errorMessage);
}
elseif (!empty($params['hrjc_role_percent_pay_cost_center'])) {
if ( !filter_var($params['hrjc_role_percent_pay_cost_center'], FILTER_VALIDATE_FLOAT) || $params['hrjc_role_percent_pay_cost_center'] < 0) {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('Percent of Pay Assigned to cost center should be positive number', $errorMessage);
elseif (!empty($params['hrjc_role_amount_pay_cost_center'])) {
if ( !filter_var($params['hrjc_role_amount_pay_cost_center'], FILTER_VALIDATE_FLOAT) || $params['hrjc_role_amount_pay_cost_center'] < 0) {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('Amount of Pay Assigned to cost center should be positive number', $errorMessage);
}
}
else {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('cost center absolute amount is not set', $errorMessage);
}
$params['hrjc_role_percent_pay_cost_center'] = 0;
}
else {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('cost center percent amount is not set', $errorMessage);
elseif ($params['hrjc_cost_center_val_type'] === 1 && !$cost_center_error) {
if (!empty($params['hrjc_role_amount_pay_cost_center']) && !empty($params['hrjc_role_percent_pay_cost_center'])) {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('cost center absolute amount should be removed', $errorMessage);
}
elseif (!empty($params['hrjc_role_percent_pay_cost_center'])) {
if ( !filter_var($params['hrjc_role_percent_pay_cost_center'], FILTER_VALIDATE_FLOAT) || $params['hrjc_role_percent_pay_cost_center'] < 0) {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('Percent of Pay Assigned to cost center should be positive number', $errorMessage);
}
}
else {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('cost center percent amount is not set', $errorMessage);
}
$params['hrjc_role_amount_pay_cost_center'] = 0;
}
$params['hrjc_role_amount_pay_cost_center'] = 0;
}

if ($cost_center_error) {
Expand All @@ -251,7 +257,7 @@ function summary(&$values) {
else {
$search_field = 'display_name';
}
$result = CRM_Hrjobroles_BAO_HrJobRoles::checkContact($funder_value, $search_field);
$result = CRM_Hrjobroles_BAO_HrJobRoles::contactExists($funder_value, $search_field);
if ($result !== 0) {
$params['funder'] = $result;
if (!empty($params['hrjc_funder_val_type'])) {
Expand Down Expand Up @@ -280,33 +286,35 @@ function summary(&$values) {
$funder_error = TRUE;
}

if ($params['hrjc_funder_val_type'] === 0 && !$funder_error) {
if (!empty($params['hrjc_role_amount_pay_funder']) && !empty($params['hrjc_role_percent_pay_funder'])) {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('funder percent amount should be removed', $errorMessage);
}
elseif (!empty($params['hrjc_role_amount_pay_funder'])) {
if ( !filter_var($params['hrjc_role_amount_pay_funder'], FILTER_VALIDATE_FLOAT) || $params['hrjc_role_amount_pay_funder'] < 0) {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('Amount of Pay Assigned to funder should be positive number', $errorMessage);
if (isset($params['hrjc_funder_val_type'])) {
if ($params['hrjc_funder_val_type'] === 0 && !$funder_error) {
if (!empty($params['hrjc_role_amount_pay_funder']) && !empty($params['hrjc_role_percent_pay_funder'])) {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('funder percent amount should be removed', $errorMessage);
}
}
else {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('funder absolute amount is not set', $errorMessage);
}
$params['hrjc_role_percent_pay_funder'] = 0;
}
elseif ($params['hrjc_funder_val_type'] === 1 && !$funder_error) {
if (!empty($params['hrjc_role_amount_pay_funder']) && !empty($params['hrjc_role_percent_pay_funder'])) {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('funder absolute amount should be removed', $errorMessage);
}
elseif (!empty($params['hrjc_role_percent_pay_funder'])) {
if ( !filter_var($params['hrjc_role_percent_pay_funder'], FILTER_VALIDATE_FLOAT) || $params['hrjc_role_percent_pay_funder'] < 0) {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('Percent of Pay Assigned to funder should be positive number', $errorMessage);
elseif (!empty($params['hrjc_role_amount_pay_funder'])) {
if ( !filter_var($params['hrjc_role_amount_pay_funder'], FILTER_VALIDATE_FLOAT) || $params['hrjc_role_amount_pay_funder'] < 0) {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('Amount of Pay Assigned to funder should be positive number', $errorMessage);
}
}
else {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('funder absolute amount is not set', $errorMessage);
}
$params['hrjc_role_percent_pay_funder'] = 0;
}
else {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('funder percent amount is not set', $errorMessage);
elseif ($params['hrjc_funder_val_type'] === 1 && !$funder_error) {
if (!empty($params['hrjc_role_amount_pay_funder']) && !empty($params['hrjc_role_percent_pay_funder'])) {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('funder absolute amount should be removed', $errorMessage);
}
elseif (!empty($params['hrjc_role_percent_pay_funder'])) {
if ( !filter_var($params['hrjc_role_percent_pay_funder'], FILTER_VALIDATE_FLOAT) || $params['hrjc_role_percent_pay_funder'] < 0) {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('Percent of Pay Assigned to funder should be positive number', $errorMessage);
}
}
else {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('funder percent amount is not set', $errorMessage);
}
$params['hrjc_role_amount_pay_funder'] = 0;
}
$params['hrjc_role_amount_pay_funder'] = 0;
}

if ($funder_error) {
Expand Down Expand Up @@ -418,26 +426,19 @@ function fini() {}


/**
* get the option database ID given its label or ID
* @param String|Integer $option
* @param String|Integer $value
* @return Integer
* Get the (Option Value) database value given its
* label or the value itself
*
* @param String| $option
* @param String $value
* @return Integer|String|NULL
* @access private
*/
private function getOptionKey($option, $value) {
if (is_numeric ($value)) {
$search_field = 'id';
}
else {
$search_field = 'label';
}
$index = array_search(strtolower($value), array_column($this->_optionsList[$option], $search_field));
if ($index !== FALSE) {
return (int) $this->_optionsList[$option][$index]['id'];
}
else {
return 0;
}
private function getOptionKey($option, $value) {
if (CRM_Utils_Array::value($value, $this->_optionsList[$option])){
return $value;
}
return CRM_Utils_Array::key(strtolower($value), $this->_optionsList[$option]);
}

}
Expand Down
3 changes: 2 additions & 1 deletion com.civicrm.hrjobroles/js/dist/job-roles.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 9c64032

Please sign in to comment.