Beispiel #1
0
/**
 * HRJobPay.create API
 *
 * @param array $params
 * @return array API result descriptor
 * @throws API_Exception
 */
function civicrm_api3_h_r_job_pay_create($params)
{
    $result = _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
    if (empty($result['is_error'])) {
        if (empty($result['id'])) {
            throw new API_Exception("Cannot update estimates: missing job id");
        }
        $job_id = CRM_Core_DAO::singleValueQuery('SELECT job_id FROM civicrm_hrjob_pay WHERE id = %1', array(1 => array($result['id'], 'Positive')));
        CRM_HRJob_Estimator::updateEstimatesByJob($job_id);
    }
    return $result;
}
Beispiel #2
0
 /**
  * Public wrapper for calling private "add" functions
  * Provides user feedback
  */
 public function generate()
 {
     $enabledExtensions = array();
     $dao = CRM_Core_DAO::executeQuery("SELECT full_name FROM civicrm_extension WHERE is_active = 1");
     while ($dao->fetch()) {
         $enabledExtensions[] = $dao->full_name;
     }
     foreach (array('Organization', 'Individual') as $cType) {
         echo "Adding {$cType}\n";
         $count = 1;
         foreach ($this->{$cType} as $cid) {
             if ($cType == 'Organizatifon') {
                 $org = $this->addOrganization($cid);
                 $this->_update($org);
                 foreach ($enabledExtensions as $extension) {
                     switch ($extension) {
                         case 'org.civicrm.hrabsence':
                             //if Absence (CiviHR) extension is enabled, add the sample data
                             $this->addAbsencePeriods();
                             break;
                     }
                 }
             } else {
                 $this->addIndividual($cid);
                 foreach ($enabledExtensions as $extension) {
                     switch ($extension) {
                         case 'org.civicrm.hrjob':
                             //if Job(CiviHR) extension is enabled, add the sample data
                             $this->addJobData($cid);
                             $this->addJobSummaryData($cid);
                             break;
                         case 'org.civicrm.hrident':
                             //if Identification (CiviHR) extension is enabled, add the sample data
                             $this->addIdentificationData($cid);
                             break;
                         case 'org.civicrm.hrmed':
                             //if Medical and Disability (CiviHR) extension is enabled, add the sample data
                             $this->addMedicalData($cid);
                             break;
                         case 'org.civicrm.hrqual':
                             //if Qualifications (CiviHR) extension is enabled, add the sample data
                             $this->addQualifications($cid);
                             break;
                         case 'org.civicrm.hrvisa':
                             //if Immigration / Visas (CiviHR) extension is enabled, add the sample data
                             $this->addVisaDetails($cid);
                             break;
                         case 'org.civicrm.hremerg':
                             //if Emergency Contacts (CiviHR) extension is enabled, add the sample data
                             $this->addEmergencyContact($cid);
                             break;
                         case 'org.civicrm.hrcareer':
                             //if Career (CiviHR) extension is enabled, add the sample data
                             $this->addCareerData($cid);
                             break;
                         case 'org.civicrm.hrabsence':
                             //if Absence (CiviHR) extension in enabled, add the sample data
                             $this->addAbsenceEntitlements($cid);
                             break;
                         case 'org.civicrm.hrrecruitment':
                             //if Recruitment (CiviHR) extension in enabled, add the sample data
                             if ($count == 1) {
                                 $this->addVacancies($cid);
                             }
                             break;
                         default:
                             $this->addHolidays($cid);
                             break;
                     }
                 }
                 $count++;
             }
         }
     }
     if (in_array('org.civicrm.hrjob', $enabledExtensions)) {
         CRM_HRJob_Estimator::updateEstimates();
     }
 }