Example #1
0
 public static function create($params)
 {
     $entityName = 'PayScale';
     $hook = empty($params['id']) ? 'create' : 'edit';
     CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
     $instance = new self();
     $instance->copyValues($params);
     $instance->save();
     CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance);
     return $instance;
 }
Example #2
0
 public static function create($params)
 {
     $entityName = 'HoursLocation';
     $hook = empty($params['id']) ? 'create' : 'edit';
     /*if (!empty($params['id'])) {
         $existing = civicrm_api3('HRHoursLocation', 'getsingle', array('id' => $params['id']));
         $params = array_merge($existing, $params);
       }*/
     CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
     $instance = new self();
     $instance->copyValues($params);
     $instance->save();
     CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance);
     return $instance;
 }
Example #3
0
 public static function create($params)
 {
     $entityName = 'HRAbsencePeriod';
     $hook = empty($params['id']) ? 'create' : 'edit';
     CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
     $instance = new self();
     $instance->copyValues($params);
     $instance->save();
     foreach (array('end_date', 'start_date') as $yesReallyIWantToSaveTheDataInsteadOfSilentlyThrowingItAway) {
         if (isset($params[$yesReallyIWantToSaveTheDataInsteadOfSilentlyThrowingItAway])) {
             CRM_Core_DAO::executeQuery("UPDATE civicrm_hrabsence_period SET {$yesReallyIWantToSaveTheDataInsteadOfSilentlyThrowingItAway} = %1 WHERE id = %2", array(1 => array($params[$yesReallyIWantToSaveTheDataInsteadOfSilentlyThrowingItAway], 'String'), 2 => array($instance->id, 'Integer')));
         }
     }
     CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance);
     return $instance;
 }
Example #4
0
 /**
  * Create case contact record.
  *
  * @param array $params
  *   case_id, contact_id
  *
  * @return CRM_Case_BAO_CaseContact
  */
 public static function create($params)
 {
     $caseContact = new self();
     $caseContact->copyValues($params);
     $caseContact->save();
     // add to recently viewed
     $caseType = CRM_Case_BAO_Case::getCaseType($caseContact->case_id);
     $url = CRM_Utils_System::url('civicrm/contact/view/case', "action=view&reset=1&id={$caseContact->case_id}&cid={$caseContact->contact_id}&context=home");
     $title = CRM_Contact_BAO_Contact::displayName($caseContact->contact_id) . ' - ' . $caseType;
     $recentOther = array();
     if (CRM_Core_Permission::checkActionPermission('CiviCase', CRM_Core_Action::DELETE)) {
         $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/case', "action=delete&reset=1&id={$caseContact->case_id}&cid={$caseContact->contact_id}&context=home");
     }
     // add the recently created case
     CRM_Utils_Recent::add($title, $url, $caseContact->case_id, 'Case', $caseContact->contact_id, NULL, $recentOther);
     return $caseContact;
 }
Example #5
0
 public static function create($params)
 {
     $entityName = 'HRAbsenceType';
     $hook = empty($params['id']) ? 'create' : 'edit';
     if (!array_key_exists('name', $params) && !array_key_exists('id', $params)) {
         $params['name'] = CRM_Utils_String::munge($params['title']);
     }
     // If this is an existing type, we'll need to know about previously linked activity-type-ids
     if (!empty($params['id'])) {
         $existing = civicrm_api3('HRAbsenceType', 'getsingle', array('id' => $params['id']));
         $params = array_merge($existing, $params);
     }
     $activityTypesResult = civicrm_api3('activity_type', 'get', array());
     if (CRM_Utils_Array::value('allow_debits', $params) && empty($params['debit_activity_type_id'])) {
         $weight = count($activityTypesResult["values"]);
         $debitActivityLabel = $params['name'];
         $debitActivityTypeId = array_search($debitActivityLabel, $activityTypesResult["values"]);
         if (!$debitActivityTypeId) {
             $weight = $weight + 1;
             $paramsCreate = array('weight' => $weight, 'label' => $debitActivityLabel, 'filter' => 1, 'is_active' => 1, 'is_optgroup' => 0, 'is_default' => 0, 'grouping' => 'Timesheet');
             $resultCreateActivityType = civicrm_api3('activity_type', 'create', $paramsCreate);
             $debitActivityTypeId = $resultCreateActivityType['values'][$resultCreateActivityType["id"]]['value'];
         }
         $params["debit_activity_type_id"] = $debitActivityTypeId;
     }
     if (CRM_Utils_Array::value('allow_credits', $params) && empty($params["credit_activity_type_id"])) {
         $weight = count($activityTypesResult["values"]);
         $creditActivityLabel = ts('%1 (Credit)', array(1 => $params["name"]));
         $creditActivityTypeId = array_search($creditActivityLabel, $activityTypesResult["values"]);
         if (!$creditActivityTypeId) {
             $weight = $weight + 1;
             $paramsCreate = array('weight' => $weight, 'label' => $creditActivityLabel, 'filter' => 1, 'is_active' => 1, 'is_optgroup' => 0, 'is_default' => 0, 'grouping' => 'Timesheet');
             $resultCreateActivityType = civicrm_api3('activity_type', 'create', $paramsCreate);
             $creditActivityTypeId = $resultCreateActivityType['values'][$resultCreateActivityType["id"]]['value'];
             $params["credit_activity_type_id"] = $creditActivityTypeId;
         }
     }
     CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
     $instance = new self();
     $instance->copyValues($params);
     $instance->save();
     CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance);
     return $instance;
 }
Example #6
0
 public static function create($params)
 {
     $entityName = 'HRJob';
     $hook = empty($params['id']) ? 'create' : 'edit';
     if (is_numeric(CRM_Utils_Array::value('is_primary', $params)) || empty($params['id'])) {
         CRM_Core_BAO_Block::handlePrimary($params, get_class());
     }
     CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
     $instance = new self();
     $instance->copyValues($params);
     $instance->save();
     $resultRoleGet = civicrm_api3('HRJobRole', 'get', array('job_id' => $instance->id, 'title' => $instance->title));
     $duplicate = CRM_Utils_Array::value('action', $params, $hook);
     if ($hook == 'create' && $resultRoleGet['count'] == 0 && $duplicate != 'duplicate') {
         civicrm_api3('HRJobRole', 'create', array('job_id' => $instance->id, 'title' => $instance->title, 'location' => $instance->location, 'percent_pay_role' => 100));
     }
     CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance);
     return $instance;
 }
Example #7
0
 /**
  * Create a new HRJobContract based on array-data
  *
  * @param array $params key-value pairs
  * @return CRM_HRJob_DAO_HRJobContract|NULL
  *
  */
 public static function create($params)
 {
     $className = 'CRM_HRJobContract_DAO_HRJobContract';
     $entityName = 'HRJobContract';
     $hook = empty($params['id']) ? 'create' : 'edit';
     CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
     $instance = new self();
     $instance->copyValues($params);
     $instance->save();
     CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance);
     if ((is_numeric(CRM_Utils_Array::value('is_primary', $params)) || $hook === 'create') && empty($params['import'])) {
         CRM_Hrjobcontract_DAO_HRJobContract::handlePrimary($instance, $params);
     }
     $deleted = isset($params['deleted']) ? $params['deleted'] : 0;
     if ($deleted) {
         CRM_Hrjobcontract_JobContractDates::removeDates($instance->id);
     }
     if (module_exists('rules')) {
         rules_invoke_event('hrjobcontract_after_create', $instance);
     }
     return $instance;
 }
Example #8
0
 /**
  * Given the list of params in the params array, fetch the object
  * and store the values in the values array
  *
  * @param array $params input parameters to find object
  * @param array $values output values of the object
  *
  * @return CRM_HRRecruitment_DAO_HRVacancy|null the found object or null
  * @access public
  * @static
  */
 static function retrieve(&$params, &$defaults)
 {
     $vacancy = new self();
     $vacancy->copyValues($params);
     if ($vacancy->find(TRUE)) {
         CRM_Core_DAO::storeValues($vacancy, $defaults);
         $stage = new CRM_HRRecruitment_DAO_HRVacancyStage();
         $stage->vacancy_id = $vacancy->id;
         $stage->find();
         while ($stage->fetch()) {
             $defaults['stages'][$stage->weight] = $stage->case_status_id;
         }
         $permission = new CRM_HRRecruitment_DAO_HRVacancyPermission();
         $permission->vacancy_id = $vacancy->id;
         $permission->find();
         $count = 1;
         while ($permission->fetch()) {
             $defaults['permission'][$count] = $permission->permission;
             $defaults['permission_contact_id'][$count] = $permission->contact_id;
             $count++;
         }
         foreach (array('application_profile', 'evaluation_profile') as $profileName) {
             $ufJoin = new CRM_Core_DAO_UFJoin();
             $ufJoin->module = 'Vacancy';
             $ufJoin->entity_id = $vacancy->id;
             $ufJoin->module_data = $profileName;
             $ufJoin->find(TRUE);
             $defaults[$profileName] = $ufJoin->uf_group_id;
         }
     }
 }