diff --git a/CRM/Tieredpricingformembership/Form/TierPrice.php b/CRM/Tieredpricingformembership/Form/TierPrice.php index 5ce8500bdc6e19ba38d692de22fd2f3a1fa529da..a2cbe32e9320300b643b00497d22a5e995b57103 100644 --- a/CRM/Tieredpricingformembership/Form/TierPrice.php +++ b/CRM/Tieredpricingformembership/Form/TierPrice.php @@ -19,13 +19,16 @@ class CRM_Tieredpricingformembership_Form_TierPrice extends CRM_Core_Form { * Basic setup. */ public function preProcess() { - $this->_id = $this->get('id'); + parent::preProcess(); + $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE); $this->_BAOName = $this->get('BAOName'); } public function buildQuickForm() { $this->buildQuickEntityForm(); - $this->addEntityRef('membership_type_id', E::ts('Membership Type'), ['entity' => 'Membership Type', 'placeholder' => E::ts('- Select Membership Type -')], TRUE); + if ($this->_action != CRM_Core_Action::DELETE) { + $this->addEntityRef('membership_type_id', E::ts('Membership Type'), ['entity' => 'Membership Type', 'placeholder' => E::ts('- Select Membership Type -')], TRUE); + } } public function setEntityFields() { @@ -48,29 +51,40 @@ class CRM_Tieredpricingformembership_Form_TierPrice extends CRM_Core_Form { public static function formRule($fields) { $errors = []; + if (!empty($fields['min_staff_tier_level']) && !empty($fields['max_staff_tier_level']) && $fields['min_staff_tier_level'] >= $fields['max_staff_tier_level']) { + $errors['min_staff_tier_level'] = E::ts('The minimum staff tier level should be greater then max tier level.'); + } $tierPrices = TierPrice::get() ->addWhere('membership_type_id', '=', $fields['membership_type_id']) ->addWhere('min_staff_tier_level', '=', $fields['min_staff_tier_level']) ->execute(); + if (count($tierPrices) > 0) { $errors['min_staff_tier_level'] = E::ts('There is already a tier price for this level'); } + $tierPrices = TierPrice::get() ->addWhere('membership_type_id', '=', $fields['membership_type_id']) - ->addWhere('min_staff_tier_level', '>', $fields['min_staff_tier_level']) - ->addWhere('max_staff_tier_level', '<', $fields['min_staff_tier_level']) - ->execute(); - if (count($tierPrices) > 0) { + ->addWhere('min_staff_tier_level', '>=', $fields['min_staff_tier_level']) + ->execute()->count(); + if ($tierPrices > 0) { $errors['min_staff_tier_level'] = E::ts('There is already a tier price that exists that covers this minimum staff level'); } + $tierPrices = TierPrice::get() + ->addWhere('membership_type_id', '=', $fields['membership_type_id']) + ->addWhere('max_staff_tier_level', '=', $fields['min_staff_tier_level']) + ->execute()->count(); + if ($tierPrices > 0) { + $errors['min_staff_tier_level'] = E::ts('There is already a tier price that exists that exists as maximum staff level.'); + } + if (!empty($fields['max_staff_tier_level'])) { $tierPrices = TierPrice::get() ->addWhere('membership_type_id', '=', $fields['membership_type_id']) - ->addWhere('min_staff_tier_level', '>', $fields['max_staff_tier_level']) - ->addClause('OR', ['max_staff_tier_level', 'IS NULL', ''], ['max_staff_tier_level', '<', $fields['max_staff_tier_level']]) + ->addWhere('max_staff_tier_level', '>=', $fields['max_staff_tier_level']) ->execute(); if (count($tierPrices) > 0) { - $errors['max_staff_tier_level'] = E::ts('There is already a tier price that exists that covrers this maximum staff level'); + $errors['max_staff_tier_level'] = E::ts('There is already a tier price that exists that covers this maximum staff level'); } } else { diff --git a/CRM/Tieredpricingformembership/Page/TierPrice.php b/CRM/Tieredpricingformembership/Page/TierPrice.php deleted file mode 100644 index e871b4253ad301e08226397d30f878cf48347cf9..0000000000000000000000000000000000000000 --- a/CRM/Tieredpricingformembership/Page/TierPrice.php +++ /dev/null @@ -1,109 +0,0 @@ -<?php -use CRM_Tieredpricingformembership_ExtensionUtil as E; -use Civi\Api4\TierPrice; - -class CRM_Tieredpricingformembership_Page_TierPrice extends CRM_Core_Page_Basic { - - /** - * The action links that we need to display for the browse screen. - * - * @var array - */ - public static $_links = []; - - /** - * Get name of edit form. - * - * @return string - * Classname of edit form. - */ - public function editForm() { - return 'CRM_Tieredpricingformembership_Form_TierPrice'; - } - - /** - * Get edit form name. - * - * @return string - * name of this page. - */ - public function editName() { - return 'Tiered Membership Prices'; - } - - /** - * Get action Links. - * - * @return array - * (reference) of action links - */ - public function &links() { - if (empty(self::$_links)) { - self::$_links = [ - CRM_Core_Action::UPDATE => [ - 'name' => ts('Edit'), - 'url' => 'civicrm/admin/tierprice', - 'qs' => 'action=update&id=%%id%%&reset=1', - 'title' => ts('Edit Payment Processor'), - ], - CRM_Core_Action::DELETE => [ - 'name' => ts('Delete'), - 'url' => 'civicrm/admin/tierprice', - 'qs' => 'action=delete&id=%%id%%', - 'title' => ts('Delete Payment Processor'), - ], - ]; - } - return self::$_links; - } - - public function run() { - // Example: Set the page-title dynamically; alternatively, declare a static title in xml/Menu/*.xml - CRM_Utils_System::setTitle(E::ts('Tier Prices')); - parent::run(); - } - - public function browse() { - $tierPrices = TierPrice::get()->addSelect('*', 'membership_type_id.name')->execute(); - var_dump($tierPrices); - foreach ($tierPrices as $tierPriceID => $tierPrice) { - // Annoyingly Smarty can't handle the colon syntax (or a .) - $tierPrices[$tierPriceID]['membership_type_id'] = $tierPrice['membership_type_id.name']; - - // form all action links - $action = array_sum(array_keys($this->links())); - $tierPrices[$tierPriceID]['action'] = CRM_Core_Action::formLink($this->links(), $action, - ['id' => $tierPrice['id']], - ts('more'), - FALSE, - 'tierPrice.manage.action', - 'tierPrice', - $tierPrice['id'] - ); - } - - $this->assign('tierPrices', $tierPrices); - } - - /** - * UserContext to pop back to. - * - * @param int $mode - * Mode that we are in. - * - * @return string - */ - public function userContext($mode = NULL) { - return 'civicrm/admin/tierprice'; - } - - /** - * Name of the BAO to perform various DB manipulations. - * - * @return string - */ - public function getBAOName() { - return 'CRM_Tieredpricingformembership_BAO_TierPrice'; - } - -} diff --git a/CRM/Tieredpricingformembership/Upgrader.php b/CRM/Tieredpricingformembership/Upgrader.php index 348ecbf58ae5de166a362f55429ffbdc8a22b3f5..e6a9a3a7eaf10588eb53655a5efaf1fcf98a06c0 100644 --- a/CRM/Tieredpricingformembership/Upgrader.php +++ b/CRM/Tieredpricingformembership/Upgrader.php @@ -63,10 +63,12 @@ class CRM_Tieredpricingformembership_Upgrader extends CRM_Tieredpricingformember */ public function upgrade_1100(): bool { $this->ctx->log->info('Applying update 1100 Adding in Max field and renaming tier_level to be minimum'); + CRM_Core_DAO::executeQuery("SET FOREIGN_KEY_CHECKS = 0"); CRM_Core_BAO_SchemaHandler::dropIndexIfExists('civicrm_tier_price', 'UI_membership_type_id_tier_level'); - CRM_Core_DAO::executeQuery('ALTER TABLE civicrm_tier_price CHANGE tier_price min_staff_tier_level INT NOT NULL DEFAULT 0 COMMENT \'min number of staff that this tier applies to\''); + CRM_Core_DAO::executeQuery('ALTER TABLE civicrm_tier_price CHANGE tier_level min_staff_tier_level INT NOT NULL DEFAULT 0 COMMENT \'min number of staff that this tier applies to\''); CRM_Core_DAO::executeQuery('ALTER TABLE civicrm_tier_price ADD COLUMN max_staff_tier_level INT DEFAULT NULL COMMENT \'min number of staff that this tier applies to\''); CRM_Core_DAO::executeQuery('ALTER TABLE civicrm_tier_price ADD UNIQUE INDEX UI_membership_type_id_tier_level(`membership_type_id`,`min_staff_tier_level`)'); + CRM_Core_DAO::executeQuery("SET FOREIGN_KEY_CHECKS = 1"); return TRUE; } diff --git a/CRM/Tieredpricingformembership/Utils.php b/CRM/Tieredpricingformembership/Utils.php new file mode 100644 index 0000000000000000000000000000000000000000..899476e5cd30a7b9800f574687df2ac3a36fde09 --- /dev/null +++ b/CRM/Tieredpricingformembership/Utils.php @@ -0,0 +1,123 @@ +<?php + +use \Civi\Api4\CustomField; +use \Civi\Api4\Relationship; +use \Civi\Api4\Contact; +use \Civi\Api4\PriceFieldValue; + +class CRM_Tieredpricingformembership_Utils { + + /** + * Get custom field ID by name + * @param string $fieldName Custom field name + * @param string $cgName Custom group name + * + * @return int custom field ID + */ + public static function getCustomFieldIDByName($fieldName, $cgName) { + return CustomField::get(FALSE) + ->addSelect('id') + ->addWhere('custom_group_id:name', '=', $cgName) + ->addWhere('name', '=', $fieldName) + ->execute()->first()['id']; + } + + /** + * Update organization employee count + * + * @param int $cid contact ID + * @param int|void $count Custom group name + * + * @return void + */ + public static function updateEmployeeCount($cid, $count = NULL) { + $cfID = self::getCustomFieldIDByName('Employee_count_including_subsidiaries', 'Employee_count'); + // Check if the contact ID $cid has a relalionship of type 'Has Subsidiary' + $subsdiaryOrgs = Relationship::get(FALSE) + ->addWhere('relationship_type_id:name', '=', 'Has Subsidiary') + ->addWhere('contact_id_a', '=', $cid) + ->execute(); + // get the employee count of each related subsidiary organization + if (!empty($subsdiaryOrgs)) { + $subcount = 0; + // Get the employee count of given contact ID $cid + $count = $count ?: Contact::get(FALSE)->addSelect('Employee_count.Employee_count')->addWhere('id', '=', $cid)->execute()->first()['Employee_count.Employee_count'] ?? 0; + foreach ($subsdiaryOrgs as $org) { + $subcount += Contact::get(FALSE)->addSelect('Employee_count.Employee_count')->addWhere('id', '=', $org['contact_id_b'])->execute()->first()['Employee_count.Employee_count'] ?? 0; + } + // the final count of the contact ID $cid will be sum of employee count of all related subsidiary organizations and itself + $subcount += $count; + + // Update the 'Employee count including subsidiary' + civicrm_api3('CustomValue', 'create', [ + 'entity_id' => $cid, + 'custom_' . $cfID => $subcount, + ]); + } + // if the $cid is a child subsidiary organization + else { + $subsdiaryOrgs = Relationship::get(FALSE) + ->addWhere('relationship_type_id:name', '=', 'Has Subsidiary') + ->addWhere('contact_id_b', '=', $cid) + ->execute(); + + if (!empty($subsdiaryOrgs)) { + foreach ($subsdiaryOrgs as $org) { + $count = Contact::get(FALSE)->addSelect('Employee_count.Employee_count')->addWhere('id', '=', $org['contact_id_a'])->execute()->first()['Employee_count.Employee_count'] ?? 0; + $count += Contact::get(FALSE)->addSelect('Employee_count.Employee_count')->addWhere('id', '=', $org['contact_id_b'])->execute()->first()['Employee_count.Employee_count'] ?? 0; + // Update the 'Employee count including subsidiary' + civicrm_api3('CustomValue', 'create', [ + 'entity_id' => $org['contact_id_a'], + 'custom_' . $cfID => $count, + ]); + } + } + } + } + + /** + * Return mapped entries between price_field_value_id (represent each kind of membership type) and organiation type and number of bed fields + * + * @return array + */ + public static function mappedEntries() { + $bednos = CRM_Utils_Array::collect('fieldName', CustomField::get(FALSE) + ->addSelect("CONCAT('custom_', id) AS fieldName") + ->addWhere('custom_group_id:name', '=', 'Number_of_Beds') + ->execute() + ->getArrayCopy()); + $id = CustomField::get(FALSE) + ->addWhere('custom_group_id:name', '=', 'Organization_Type') + ->execute()->first()['id']; + + $mappingRecord = []; + $i = $k = 0; + end($bednos); + $flag = false; + foreach(PriceFieldValue::get(FALSE) + ->addSelect("CONCAT('price_', price_field_id, '_', id) AS fieldName") + ->addWhere('price_field_id.name', '=', 'tiered_membership_prices') + ->execute() + ->getArrayCopy() as $key => $value) { + if ($k == 9 && !$flag) { + $k = key($bednos); + } + $mappingRecord[$value['fieldName']] = [ + 'org_type' => 'custom_' . $id . '_' . ($i + 1), + 'qty' => $bednos[$k], + ]; + $i++; + if ($i == 7) { + if ($k == key($bednos)) { + $k = 8; + $flag = true; + } + $i = 0; + $k++; + } + } + + return $mappingRecord; + } + +} \ No newline at end of file diff --git a/ang/afsearchTieredMembershipPrices.aff.html b/ang/afsearchTieredMembershipPrices.aff.html new file mode 100644 index 0000000000000000000000000000000000000000..02dec8e887253039187ca9fa09271996d3bb0b6b --- /dev/null +++ b/ang/afsearchTieredMembershipPrices.aff.html @@ -0,0 +1,17 @@ +<div class="btn-group"> + + <a class="btn btn-primary crm-popup" ng-href="{{ crmUrl('civicrm/admin/tierprice', {reset: 1, action: 'add', context: 'create'}) }}"> + <i class="crm-i fa-plus-circle"/> + {{:: ts('Add') }} + </a> + +</div> +<div af-fieldset=""> + <af-field name="membership_type_id.name" /> + <af-field name="membership_type_id" /> + <af-field name="min_staff_tier_level" /> + <af-field name="max_staff_tier_level" /> + <af-field name="unit_price" /> + <br /> + <crm-search-display-table search-name="Tiered_membership_prices" display-name="Tiered_membership_prices_Table_1"></crm-search-display-table> +</div> diff --git a/ang/afsearchTieredMembershipPrices.aff.json b/ang/afsearchTieredMembershipPrices.aff.json new file mode 100644 index 0000000000000000000000000000000000000000..7e00089b2bffc471d0b2916472677918f5e605d6 --- /dev/null +++ b/ang/afsearchTieredMembershipPrices.aff.json @@ -0,0 +1,6 @@ +{ + "type": "search", + "title": "Tiered Membership Prices", + "server_route": "civicrm/tiered-membership-prices", + "permission": "access CiviCRM" +} \ No newline at end of file diff --git a/managed/CustomGroup_Employee_count.mgd.php b/managed/CustomGroup_Employee_count.mgd.php new file mode 100644 index 0000000000000000000000000000000000000000..e5981f2d79998e8d31faefe4e90c3c4289711758 --- /dev/null +++ b/managed/CustomGroup_Employee_count.mgd.php @@ -0,0 +1,112 @@ +<?php + +return [ + [ + 'name' => 'CustomGroup_Employee_count', + 'entity' => 'CustomGroup', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'name' => 'Employee_count', + 'title' => 'Employee count', + 'extends' => 'Organization', + 'extends_entity_column_value' => NULL, + 'style' => 'Inline', + 'collapse_display' => FALSE, + 'help_pre' => '', + 'help_post' => '', + 'weight' => 2, + 'is_active' => TRUE, + 'is_multiple' => FALSE, + 'min_multiple' => NULL, + 'max_multiple' => NULL, + 'collapse_adv_display' => TRUE, + 'created_date' => '2022-07-21 14:04:47', + 'is_reserved' => FALSE, + 'is_public' => TRUE, + 'icon' => '', + 'extends_entity_column_id' => NULL, + ], + ], + ], + [ + 'name' => 'CustomGroup_Employee_count_CustomField_Employee_count', + 'entity' => 'CustomField', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'custom_group_id.name' => 'Employee_count', + 'name' => 'Employee_count', + 'label' => 'Employee count', + 'data_type' => 'String', + 'html_type' => 'Text', + 'default_value' => NULL, + 'is_required' => FALSE, + 'is_searchable' => TRUE, + 'is_search_range' => FALSE, + 'help_pre' => NULL, + 'help_post' => NULL, + 'mask' => NULL, + 'attributes' => NULL, + 'javascript' => NULL, + 'is_active' => TRUE, + 'is_view' => FALSE, + 'options_per_line' => NULL, + 'text_length' => 255, + 'start_date_years' => NULL, + 'end_date_years' => NULL, + 'date_format' => NULL, + 'time_format' => NULL, + 'note_columns' => 60, + 'note_rows' => 4, + 'column_name' => 'employee_count_1', + 'serialize' => 0, + 'filter' => NULL, + 'in_selector' => FALSE, + ], + ], + ], + [ + 'name' => 'CustomGroup_Employee_count_CustomField_Employee_count_including_subsidiaries', + 'entity' => 'CustomField', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'custom_group_id.name' => 'Employee_count', + 'name' => 'Employee_count_including_subsidiaries', + 'label' => 'Employee count including subsidiaries', + 'data_type' => 'String', + 'html_type' => 'Text', + 'default_value' => NULL, + 'is_required' => FALSE, + 'is_searchable' => TRUE, + 'is_search_range' => FALSE, + 'help_pre' => NULL, + 'help_post' => NULL, + 'mask' => NULL, + 'attributes' => NULL, + 'javascript' => NULL, + 'is_active' => TRUE, + 'is_view' => TRUE, + 'options_per_line' => NULL, + 'text_length' => 255, + 'start_date_years' => NULL, + 'end_date_years' => NULL, + 'date_format' => NULL, + 'time_format' => NULL, + 'note_columns' => 60, + 'note_rows' => 4, + 'column_name' => 'employee_count_including_subsidi_2', + 'serialize' => 0, + 'filter' => NULL, + 'in_selector' => FALSE, + ], + ], + ], +]; \ No newline at end of file diff --git a/managed/CustomGroup_Number_of_Beds.mgd.php b/managed/CustomGroup_Number_of_Beds.mgd.php new file mode 100644 index 0000000000000000000000000000000000000000..2750cdcdba4ddcc8bda4801ae3acc38ec13cab48 --- /dev/null +++ b/managed/CustomGroup_Number_of_Beds.mgd.php @@ -0,0 +1,619 @@ +<?php + +return [ + [ + 'name' => 'CustomGroup_Number_of_Beds', + 'entity' => 'CustomGroup', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'name' => 'Number_of_Beds', + 'title' => 'Qtes', + 'extends' => 'Membership', + 'extends_entity_column_value' => NULL, + 'style' => 'Inline', + 'collapse_display' => FALSE, + 'help_pre' => '', + 'help_post' => '', + 'weight' => 5, + 'is_active' => TRUE, + 'is_multiple' => FALSE, + 'min_multiple' => NULL, + 'max_multiple' => NULL, + 'collapse_adv_display' => TRUE, + 'created_date' => '2022-09-13 08:16:42', + 'is_reserved' => FALSE, + 'is_public' => TRUE, + 'icon' => '', + 'extends_entity_column_id' => NULL, + ], + ], + ], + [ + 'name' => 'CustomGroup_Number_of_Beds_CustomField_M_dicine', + 'entity' => 'CustomField', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'custom_group_id.name' => 'Number_of_Beds', + 'name' => 'M_dicine', + 'label' => 'Médicine', + 'data_type' => 'Int', + 'html_type' => 'Text', + 'default_value' => NULL, + 'is_required' => FALSE, + 'is_searchable' => FALSE, + 'is_search_range' => FALSE, + 'help_pre' => NULL, + 'help_post' => NULL, + 'mask' => NULL, + 'attributes' => NULL, + 'javascript' => NULL, + 'is_active' => TRUE, + 'is_view' => FALSE, + 'options_per_line' => NULL, + 'text_length' => 255, + 'start_date_years' => NULL, + 'end_date_years' => NULL, + 'date_format' => NULL, + 'time_format' => NULL, + 'note_columns' => 60, + 'note_rows' => 4, + 'column_name' => 'm_dicine_8', + 'serialize' => 0, + 'filter' => NULL, + 'in_selector' => FALSE, + ], + ], + ], + [ + 'name' => 'CustomGroup_Number_of_Beds_CustomField_Chirurgie', + 'entity' => 'CustomField', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'custom_group_id.name' => 'Number_of_Beds', + 'name' => 'Chirurgie', + 'label' => 'Chirurgie', + 'data_type' => 'Int', + 'html_type' => 'Text', + 'default_value' => NULL, + 'is_required' => FALSE, + 'is_searchable' => FALSE, + 'is_search_range' => FALSE, + 'help_pre' => NULL, + 'help_post' => NULL, + 'mask' => NULL, + 'attributes' => NULL, + 'javascript' => NULL, + 'is_active' => TRUE, + 'is_view' => FALSE, + 'options_per_line' => NULL, + 'text_length' => 255, + 'start_date_years' => NULL, + 'end_date_years' => NULL, + 'date_format' => NULL, + 'time_format' => NULL, + 'note_columns' => 60, + 'note_rows' => 4, + 'column_name' => 'chirurgie_9', + 'serialize' => 0, + 'filter' => NULL, + 'in_selector' => FALSE, + ], + ], + ], + [ + 'name' => 'CustomGroup_Number_of_Beds_CustomField_Obst_trique', + 'entity' => 'CustomField', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'custom_group_id.name' => 'Number_of_Beds', + 'name' => 'Obst_trique', + 'label' => 'Obstétrique', + 'data_type' => 'Int', + 'html_type' => 'Text', + 'default_value' => NULL, + 'is_required' => FALSE, + 'is_searchable' => FALSE, + 'is_search_range' => FALSE, + 'help_pre' => NULL, + 'help_post' => NULL, + 'mask' => NULL, + 'attributes' => NULL, + 'javascript' => NULL, + 'is_active' => TRUE, + 'is_view' => FALSE, + 'options_per_line' => NULL, + 'text_length' => 255, + 'start_date_years' => NULL, + 'end_date_years' => NULL, + 'date_format' => NULL, + 'time_format' => NULL, + 'note_columns' => 60, + 'note_rows' => 4, + 'column_name' => 'obst_trique_10', + 'serialize' => 0, + 'filter' => NULL, + 'in_selector' => FALSE, + ], + ], + ], + [ + 'name' => 'CustomGroup_Number_of_Beds_CustomField_Ambulatoire', + 'entity' => 'CustomField', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'custom_group_id.name' => 'Number_of_Beds', + 'name' => 'Ambulatoire', + 'label' => 'Ambulatoire', + 'data_type' => 'Int', + 'html_type' => 'Text', + 'default_value' => NULL, + 'is_required' => FALSE, + 'is_searchable' => FALSE, + 'is_search_range' => FALSE, + 'help_pre' => NULL, + 'help_post' => NULL, + 'mask' => NULL, + 'attributes' => NULL, + 'javascript' => NULL, + 'is_active' => TRUE, + 'is_view' => FALSE, + 'options_per_line' => NULL, + 'text_length' => 255, + 'start_date_years' => NULL, + 'end_date_years' => NULL, + 'date_format' => NULL, + 'time_format' => NULL, + 'note_columns' => 60, + 'note_rows' => 4, + 'column_name' => 'ambulatoire_11', + 'serialize' => 0, + 'filter' => NULL, + 'in_selector' => FALSE, + ], + ], + ], + [ + 'name' => 'CustomGroup_Number_of_Beds_CustomField_HTP', + 'entity' => 'CustomField', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'custom_group_id.name' => 'Number_of_Beds', + 'name' => 'HTP', + 'label' => 'HTP', + 'data_type' => 'Int', + 'html_type' => 'Text', + 'default_value' => NULL, + 'is_required' => FALSE, + 'is_searchable' => FALSE, + 'is_search_range' => FALSE, + 'help_pre' => NULL, + 'help_post' => NULL, + 'mask' => NULL, + 'attributes' => NULL, + 'javascript' => NULL, + 'is_active' => TRUE, + 'is_view' => FALSE, + 'options_per_line' => NULL, + 'text_length' => 255, + 'start_date_years' => NULL, + 'end_date_years' => NULL, + 'date_format' => NULL, + 'time_format' => NULL, + 'note_columns' => 60, + 'note_rows' => 4, + 'column_name' => 'htp_12', + 'serialize' => 0, + 'filter' => NULL, + 'in_selector' => FALSE, + ], + ], + ], + [ + 'name' => 'CustomGroup_Number_of_Beds_CustomField_Poste_dialyse', + 'entity' => 'CustomField', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'custom_group_id.name' => 'Number_of_Beds', + 'name' => 'Poste_dialyse', + 'label' => 'Poste dialyse', + 'data_type' => 'Int', + 'html_type' => 'Text', + 'default_value' => NULL, + 'is_required' => FALSE, + 'is_searchable' => FALSE, + 'is_search_range' => FALSE, + 'help_pre' => NULL, + 'help_post' => NULL, + 'mask' => NULL, + 'attributes' => NULL, + 'javascript' => NULL, + 'is_active' => TRUE, + 'is_view' => FALSE, + 'options_per_line' => NULL, + 'text_length' => 255, + 'start_date_years' => NULL, + 'end_date_years' => NULL, + 'date_format' => NULL, + 'time_format' => NULL, + 'note_columns' => 60, + 'note_rows' => 4, + 'column_name' => 'poste_dialyse_13', + 'serialize' => 0, + 'filter' => NULL, + 'in_selector' => FALSE, + ], + ], + ], + [ + 'name' => 'CustomGroup_Number_of_Beds_CustomField_Forfait_dialyse', + 'entity' => 'CustomField', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'custom_group_id.name' => 'Number_of_Beds', + 'name' => 'Forfait_dialyse', + 'label' => 'Forfait dialyse', + 'data_type' => 'Int', + 'html_type' => 'Text', + 'default_value' => NULL, + 'is_required' => FALSE, + 'is_searchable' => FALSE, + 'is_search_range' => FALSE, + 'help_pre' => NULL, + 'help_post' => NULL, + 'mask' => NULL, + 'attributes' => NULL, + 'javascript' => NULL, + 'is_active' => TRUE, + 'is_view' => FALSE, + 'options_per_line' => NULL, + 'text_length' => 255, + 'start_date_years' => NULL, + 'end_date_years' => NULL, + 'date_format' => NULL, + 'time_format' => NULL, + 'note_columns' => 60, + 'note_rows' => 4, + 'column_name' => 'forfait_dialyse_14', + 'serialize' => 0, + 'filter' => NULL, + 'in_selector' => FALSE, + ], + ], + ], + [ + 'name' => 'CustomGroup_Number_of_Beds_CustomField_PSY', + 'entity' => 'CustomField', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'custom_group_id.name' => 'Number_of_Beds', + 'name' => 'PSY', + 'label' => 'PSY', + 'data_type' => 'Int', + 'html_type' => 'Text', + 'default_value' => NULL, + 'is_required' => FALSE, + 'is_searchable' => FALSE, + 'is_search_range' => FALSE, + 'help_pre' => NULL, + 'help_post' => NULL, + 'mask' => NULL, + 'attributes' => NULL, + 'javascript' => NULL, + 'is_active' => TRUE, + 'is_view' => FALSE, + 'options_per_line' => NULL, + 'text_length' => 255, + 'start_date_years' => NULL, + 'end_date_years' => NULL, + 'date_format' => NULL, + 'time_format' => NULL, + 'note_columns' => 60, + 'note_rows' => 4, + 'column_name' => 'psy_15', + 'serialize' => 0, + 'filter' => NULL, + 'in_selector' => FALSE, + ], + ], + ], + [ + 'name' => 'CustomGroup_Number_of_Beds_CustomField_MECS_therme', + 'entity' => 'CustomField', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'custom_group_id.name' => 'Number_of_Beds', + 'name' => 'MECS_therme', + 'label' => 'MECS therme', + 'data_type' => 'Int', + 'html_type' => 'Text', + 'default_value' => NULL, + 'is_required' => FALSE, + 'is_searchable' => FALSE, + 'is_search_range' => FALSE, + 'help_pre' => NULL, + 'help_post' => NULL, + 'mask' => NULL, + 'attributes' => NULL, + 'javascript' => NULL, + 'is_active' => TRUE, + 'is_view' => FALSE, + 'options_per_line' => NULL, + 'text_length' => 255, + 'start_date_years' => NULL, + 'end_date_years' => NULL, + 'date_format' => NULL, + 'time_format' => NULL, + 'note_columns' => 60, + 'note_rows' => 4, + 'column_name' => 'mecs_therme_16', + 'serialize' => 0, + 'filter' => NULL, + 'in_selector' => FALSE, + ], + ], + ], + [ + 'name' => 'CustomGroup_Number_of_Beds_CustomField_MECS', + 'entity' => 'CustomField', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'custom_group_id.name' => 'Number_of_Beds', + 'name' => 'MECS', + 'label' => 'MECS', + 'data_type' => 'Int', + 'html_type' => 'Text', + 'default_value' => NULL, + 'is_required' => FALSE, + 'is_searchable' => FALSE, + 'is_search_range' => FALSE, + 'help_pre' => NULL, + 'help_post' => NULL, + 'mask' => NULL, + 'attributes' => NULL, + 'javascript' => NULL, + 'is_active' => TRUE, + 'is_view' => FALSE, + 'options_per_line' => NULL, + 'text_length' => 255, + 'start_date_years' => NULL, + 'end_date_years' => NULL, + 'date_format' => NULL, + 'time_format' => NULL, + 'note_columns' => 60, + 'note_rows' => 4, + 'column_name' => 'mecs_22', + 'serialize' => 0, + 'filter' => NULL, + 'in_selector' => FALSE, + ], + ], + ], + [ + 'name' => 'CustomGroup_Number_of_Beds_CustomField_RF', + 'entity' => 'CustomField', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'custom_group_id.name' => 'Number_of_Beds', + 'name' => 'RF', + 'label' => 'RF', + 'data_type' => 'Int', + 'html_type' => 'Text', + 'default_value' => NULL, + 'is_required' => FALSE, + 'is_searchable' => FALSE, + 'is_search_range' => FALSE, + 'help_pre' => NULL, + 'help_post' => NULL, + 'mask' => NULL, + 'attributes' => NULL, + 'javascript' => NULL, + 'is_active' => TRUE, + 'is_view' => FALSE, + 'options_per_line' => NULL, + 'text_length' => 255, + 'start_date_years' => NULL, + 'end_date_years' => NULL, + 'date_format' => NULL, + 'time_format' => NULL, + 'note_columns' => 60, + 'note_rows' => 4, + 'column_name' => 'rf_17', + 'serialize' => 0, + 'filter' => NULL, + 'in_selector' => FALSE, + ], + ], + ], + [ + 'name' => 'CustomGroup_Number_of_Beds_CustomField_Soins_de_suite', + 'entity' => 'CustomField', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'custom_group_id.name' => 'Number_of_Beds', + 'name' => 'Soins_de_suite', + 'label' => 'Soins de suite', + 'data_type' => 'Int', + 'html_type' => 'Text', + 'default_value' => NULL, + 'is_required' => FALSE, + 'is_searchable' => FALSE, + 'is_search_range' => FALSE, + 'help_pre' => NULL, + 'help_post' => NULL, + 'mask' => NULL, + 'attributes' => NULL, + 'javascript' => NULL, + 'is_active' => TRUE, + 'is_view' => FALSE, + 'options_per_line' => NULL, + 'text_length' => 255, + 'start_date_years' => NULL, + 'end_date_years' => NULL, + 'date_format' => NULL, + 'time_format' => NULL, + 'note_columns' => 60, + 'note_rows' => 4, + 'column_name' => 'soins_de_suite_18', + 'serialize' => 0, + 'filter' => NULL, + 'in_selector' => FALSE, + ], + ], + ], + [ + 'name' => 'CustomGroup_Number_of_Beds_CustomField_HAD', + 'entity' => 'CustomField', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'custom_group_id.name' => 'Number_of_Beds', + 'name' => 'HAD', + 'label' => 'HAD', + 'data_type' => 'Int', + 'html_type' => 'Text', + 'default_value' => NULL, + 'is_required' => FALSE, + 'is_searchable' => FALSE, + 'is_search_range' => FALSE, + 'help_pre' => NULL, + 'help_post' => NULL, + 'mask' => NULL, + 'attributes' => NULL, + 'javascript' => NULL, + 'is_active' => TRUE, + 'is_view' => FALSE, + 'options_per_line' => NULL, + 'text_length' => 255, + 'start_date_years' => NULL, + 'end_date_years' => NULL, + 'date_format' => NULL, + 'time_format' => NULL, + 'note_columns' => 60, + 'note_rows' => 4, + 'column_name' => 'had_19', + 'serialize' => 0, + 'filter' => NULL, + 'in_selector' => FALSE, + ], + ], + ], + [ + 'name' => 'CustomGroup_Number_of_Beds_CustomField_Cot_forfaitaire_1', + 'entity' => 'CustomField', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'custom_group_id.name' => 'Number_of_Beds', + 'name' => 'Cot_forfaitaire_1', + 'label' => 'Cot. forfaitaire 1', + 'data_type' => 'Int', + 'html_type' => 'Text', + 'default_value' => NULL, + 'is_required' => FALSE, + 'is_searchable' => FALSE, + 'is_search_range' => FALSE, + 'help_pre' => NULL, + 'help_post' => NULL, + 'mask' => NULL, + 'attributes' => NULL, + 'javascript' => NULL, + 'is_active' => TRUE, + 'is_view' => FALSE, + 'options_per_line' => NULL, + 'text_length' => 255, + 'start_date_years' => NULL, + 'end_date_years' => NULL, + 'date_format' => NULL, + 'time_format' => NULL, + 'note_columns' => 60, + 'note_rows' => 4, + 'column_name' => 'cot_forfaitaire_1_20', + 'serialize' => 0, + 'filter' => NULL, + 'in_selector' => FALSE, + ], + ], + ], + [ + 'name' => 'CustomGroup_Number_of_Beds_CustomField_Cot_forfaitaire_2', + 'entity' => 'CustomField', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'custom_group_id.name' => 'Number_of_Beds', + 'name' => 'Cot_forfaitaire_2', + 'label' => 'Cot. forfaitaire 2', + 'data_type' => 'Int', + 'html_type' => 'Text', + 'default_value' => NULL, + 'is_required' => FALSE, + 'is_searchable' => FALSE, + 'is_search_range' => FALSE, + 'help_pre' => NULL, + 'help_post' => NULL, + 'mask' => NULL, + 'attributes' => NULL, + 'javascript' => NULL, + 'is_active' => TRUE, + 'is_view' => FALSE, + 'options_per_line' => NULL, + 'text_length' => 255, + 'start_date_years' => NULL, + 'end_date_years' => NULL, + 'date_format' => NULL, + 'time_format' => NULL, + 'note_columns' => 60, + 'note_rows' => 4, + 'column_name' => 'cot_forfaitaire_2_21', + 'serialize' => 0, + 'filter' => NULL, + 'in_selector' => FALSE, + ], + ], + ], +]; \ No newline at end of file diff --git a/managed/CustomGroup_Organization_Type.mgd.php b/managed/CustomGroup_Organization_Type.mgd.php new file mode 100644 index 0000000000000000000000000000000000000000..f6c65d3d5696d924ceb00ab6b645f8bcc2e78f0d --- /dev/null +++ b/managed/CustomGroup_Organization_Type.mgd.php @@ -0,0 +1,285 @@ +<?php +return [ + [ + 'name' => 'CustomGroup_Organization_Type', + 'entity' => 'CustomGroup', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'name' => 'Organization_Type', + 'title' => 'Organization Type', + 'extends' => 'Membership', + 'extends_entity_column_value' => NULL, + 'style' => 'Inline', + 'collapse_display' => FALSE, + 'help_pre' => '', + 'help_post' => '', + 'weight' => 1, + 'is_active' => TRUE, + 'is_multiple' => FALSE, + 'min_multiple' => NULL, + 'max_multiple' => NULL, + 'collapse_adv_display' => TRUE, + 'created_date' => '2022-09-13 08:11:58', + 'is_reserved' => FALSE, + 'is_public' => TRUE, + 'icon' => '', + 'extends_entity_column_id' => NULL, + ], + ], + ], + [ + 'name' => 'OptionGroup_Organization_Type_Type_of_Organization', + 'entity' => 'OptionGroup', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'name' => 'Organization_Type_Type_of_Organization', + 'title' => 'Organization Type :: Type of Organization', + 'description' => NULL, + 'data_type' => 'String', + 'is_reserved' => FALSE, + 'is_active' => TRUE, + 'is_locked' => FALSE, + 'option_value_fields' => [ + 'name', + 'label', + 'description', + ], + ], + ], + ], + [ + 'name' => 'OptionGroup_Organization_Type_Type_of_Organization_OptionValue_FHP', + 'entity' => 'OptionValue', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'option_group_id.name' => 'Organization_Type_Type_of_Organization', + 'label' => 'FHP', + 'value' => '1', + 'name' => 'FHP', + 'grouping' => NULL, + 'filter' => 0, + 'is_default' => FALSE, + 'description' => NULL, + 'is_optgroup' => FALSE, + 'is_reserved' => FALSE, + 'is_active' => TRUE, + 'icon' => NULL, + 'color' => NULL, + 'component_id' => NULL, + 'domain_id' => NULL, + 'visibility_id' => NULL, + ], + ], + ], + [ + 'name' => 'OptionGroup_Organization_Type_Type_of_Organization_OptionValue_R_gional', + 'entity' => 'OptionValue', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'option_group_id.name' => 'Organization_Type_Type_of_Organization', + 'label' => 'Régional', + 'value' => '2', + 'name' => 'R_gional', + 'grouping' => NULL, + 'filter' => 0, + 'is_default' => FALSE, + 'description' => NULL, + 'is_optgroup' => FALSE, + 'is_reserved' => FALSE, + 'is_active' => TRUE, + 'icon' => NULL, + 'color' => NULL, + 'component_id' => NULL, + 'domain_id' => NULL, + 'visibility_id' => NULL, + ], + ], + ], + [ + 'name' => 'OptionGroup_Organization_Type_Type_of_Organization_OptionValue_FHP_MCO', + 'entity' => 'OptionValue', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'option_group_id.name' => 'Organization_Type_Type_of_Organization', + 'label' => 'FHP-MCO', + 'value' => '3', + 'name' => 'FHP_MCO', + 'grouping' => NULL, + 'filter' => 0, + 'is_default' => FALSE, + 'description' => NULL, + 'is_optgroup' => FALSE, + 'is_reserved' => FALSE, + 'is_active' => TRUE, + 'icon' => NULL, + 'color' => NULL, + 'component_id' => NULL, + 'domain_id' => NULL, + 'visibility_id' => NULL, + ], + ], + ], + [ + 'name' => 'OptionGroup_Organization_Type_Type_of_Organization_OptionValue_FHP_DIALYSE', + 'entity' => 'OptionValue', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'option_group_id.name' => 'Organization_Type_Type_of_Organization', + 'label' => 'FHP-DIALYSE', + 'value' => '4', + 'name' => 'FHP_DIALYSE', + 'grouping' => NULL, + 'filter' => 0, + 'is_default' => FALSE, + 'description' => NULL, + 'is_optgroup' => FALSE, + 'is_reserved' => FALSE, + 'is_active' => TRUE, + 'icon' => NULL, + 'color' => NULL, + 'component_id' => NULL, + 'domain_id' => NULL, + 'visibility_id' => NULL, + ], + ], + ], + [ + 'name' => 'OptionGroup_Organization_Type_Type_of_Organization_OptionValue_UNCPSY', + 'entity' => 'OptionValue', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'option_group_id.name' => 'Organization_Type_Type_of_Organization', + 'label' => 'UNCPSY', + 'value' => '5', + 'name' => 'UNCPSY', + 'grouping' => NULL, + 'filter' => 0, + 'is_default' => FALSE, + 'description' => NULL, + 'is_optgroup' => FALSE, + 'is_reserved' => FALSE, + 'is_active' => TRUE, + 'icon' => NULL, + 'color' => NULL, + 'component_id' => NULL, + 'domain_id' => NULL, + 'visibility_id' => NULL, + ], + ], + ], + [ + 'name' => 'OptionGroup_Organization_Type_Type_of_Organization_OptionValue_CSSR_FHP', + 'entity' => 'OptionValue', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'option_group_id.name' => 'Organization_Type_Type_of_Organization', + 'label' => 'CSSR-FHP', + 'value' => '6', + 'name' => 'CSSR_FHP', + 'grouping' => NULL, + 'filter' => 0, + 'is_default' => FALSE, + 'description' => NULL, + 'is_optgroup' => FALSE, + 'is_reserved' => FALSE, + 'is_active' => TRUE, + 'icon' => NULL, + 'color' => NULL, + 'component_id' => NULL, + 'domain_id' => NULL, + 'visibility_id' => NULL, + ], + ], + ], + [ + 'name' => 'OptionGroup_Organization_Type_Type_of_Organization_OptionValue_UNHPC', + 'entity' => 'OptionValue', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'option_group_id.name' => 'Organization_Type_Type_of_Organization', + 'label' => 'UNHPC', + 'value' => '7', + 'name' => 'UNHPC', + 'grouping' => NULL, + 'filter' => 0, + 'is_default' => FALSE, + 'description' => NULL, + 'is_optgroup' => FALSE, + 'is_reserved' => FALSE, + 'is_active' => TRUE, + 'icon' => NULL, + 'color' => NULL, + 'component_id' => NULL, + 'domain_id' => NULL, + 'visibility_id' => NULL, + ], + ], + ], + [ + 'name' => 'CustomGroup_Organization_Type_CustomField_Type_of_Organization', + 'entity' => 'CustomField', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'custom_group_id.name' => 'Organization_Type', + 'name' => 'Type_of_Organization', + 'label' => 'Type of Organization', + 'data_type' => 'String', + 'html_type' => 'CheckBox', + 'default_value' => NULL, + 'is_required' => FALSE, + 'is_searchable' => FALSE, + 'is_search_range' => FALSE, + 'help_pre' => NULL, + 'help_post' => NULL, + 'mask' => NULL, + 'attributes' => NULL, + 'javascript' => NULL, + 'is_active' => TRUE, + 'is_view' => FALSE, + 'options_per_line' => 1, + 'text_length' => 255, + 'start_date_years' => NULL, + 'end_date_years' => NULL, + 'date_format' => NULL, + 'time_format' => NULL, + 'note_columns' => 60, + 'note_rows' => 4, + 'column_name' => 'type_of_organization_6', + 'option_group_id.name' => 'Organization_Type_Type_of_Organization', + 'serialize' => 1, + 'filter' => NULL, + 'in_selector' => FALSE, + ], + ], + ], +]; \ No newline at end of file diff --git a/managed/CustomGroup_Primary_Donor.mgd.php b/managed/CustomGroup_Primary_Donor.mgd.php new file mode 100644 index 0000000000000000000000000000000000000000..5a69fee7ec4007e31f756859409e4281d0f78f4e --- /dev/null +++ b/managed/CustomGroup_Primary_Donor.mgd.php @@ -0,0 +1,73 @@ +<?php + +return [ + [ + 'name' => 'CustomGroup_Primary_Donor', + 'entity' => 'CustomGroup', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'name' => 'Primary_Donor', + 'title' => 'Primary Donor', + 'extends' => 'Membership', + 'extends_entity_column_value' => NULL, + 'style' => 'Inline', + 'collapse_display' => FALSE, + 'help_pre' => '', + 'help_post' => '', + 'weight' => 6, + 'is_active' => TRUE, + 'is_multiple' => FALSE, + 'min_multiple' => NULL, + 'max_multiple' => NULL, + 'collapse_adv_display' => TRUE, + 'created_date' => '2022-09-22 09:21:58', + 'is_reserved' => FALSE, + 'is_public' => TRUE, + 'icon' => '', + 'extends_entity_column_id' => NULL, + ], + ], + ], + [ + 'name' => 'CustomGroup_Primary_Donor_CustomField_Organization', + 'entity' => 'CustomField', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'custom_group_id.name' => 'Primary_Donor', + 'name' => 'Organization', + 'label' => 'Organization', + 'data_type' => 'ContactReference', + 'html_type' => 'Autocomplete-Select', + 'default_value' => NULL, + 'is_required' => FALSE, + 'is_searchable' => FALSE, + 'is_search_range' => FALSE, + 'help_pre' => NULL, + 'help_post' => NULL, + 'mask' => NULL, + 'attributes' => NULL, + 'javascript' => NULL, + 'is_active' => TRUE, + 'is_view' => FALSE, + 'options_per_line' => NULL, + 'text_length' => 255, + 'start_date_years' => NULL, + 'end_date_years' => NULL, + 'date_format' => NULL, + 'time_format' => NULL, + 'note_columns' => 60, + 'note_rows' => 4, + 'column_name' => 'organization_23', + 'serialize' => 0, + 'filter' => 'action=lookup&group=2', + 'in_selector' => FALSE, + ], + ], + ], +]; \ No newline at end of file diff --git a/managed/Entities.mgd.php b/managed/Entities.mgd.php index f825a582a3eb75dc1f69f6adcff15ab8512d2db1..683574364c7c3ddcf3be8a9bdba03bf24e62d028 100644 --- a/managed/Entities.mgd.php +++ b/managed/Entities.mgd.php @@ -1,264 +1,5 @@ <?php -return []; -/*return [ - [ - 'name' => 'OptionValue_membership_type_custom_data_type', - 'entity' => 'OptionValue', - 'cleanup' => 'always', - 'update' => 'unmodified', - 'params' => [ - 'version' => 4, - 'values' => [ - 'option_group_id.name' => 'cg_extend_objects', - 'label' => 'Membership Type', - 'name' => 'civicrm_membership_type', - 'value' => 'MembershipType', - 'description' => NULL, - 'is_active' => TRUE, - 'grouping' => NULL, - ], - 'match' => ['label'], - ], - ], - [ - 'name' => 'OptionGroup_tier_membership_prices', - 'entity' => 'OptionGroup', - 'cleanup' => 'unused', - 'update' => 'unmodified', - 'params' => [ - 'version' => 4, - 'values' => [ - 'name' => 'tiered_membership_prices', - 'title' => 'Tiered Membership prices', - 'description' => NULL, - 'data_type' => 'String', - 'is_reserved' => TRUE, - 'is_active' => TRUE, - 'is_locked' => FALSE, - 'option_value_fields' => [ - 'name', - 'label', - 'description', - ], - ], - ], - ], - [ - 'name' => 'OptionGroup_tier_membership_prices_OptionValue_4', - 'entity' => 'OptionValue', - 'cleanup' => 'unused', - 'update' => 'unmodified', - 'params' => [ - 'version' => 4, - 'values' => [ - 'option_group_id.name' => 'tier_membership_prices', - 'label' => '4', - 'value' => '10', - 'name' => '4', - 'grouping' => NULL, - 'filter' => 0, - 'is_default' => FALSE, - 'description' => '0-4', - 'is_optgroup' => FALSE, - 'is_reserved' => TRUE, - 'is_active' => TRUE, - 'icon' => NULL, - 'color' => NULL, - 'component_id' => NULL, - 'domain_id' => NULL, - 'visibility_id' => NULL, - ], - ], - ], - [ - 'name' => 'OptionGroup_tier_membership_prices_OptionValue_14', - 'entity' => 'OptionValue', - 'cleanup' => 'unused', - 'update' => 'unmodified', - 'params' => [ - 'version' => 4, - 'values' => [ - 'option_group_id.name' => 'tier_membership_prices', - 'label' => '14', - 'value' => '20', - 'name' => '14', - 'grouping' => NULL, - 'filter' => 0, - 'is_default' => FALSE, - 'description' => '5-14', - 'is_optgroup' => FALSE, - 'is_reserved' => TRUE, - 'is_active' => TRUE, - 'icon' => NULL, - 'color' => NULL, - 'component_id' => NULL, - 'domain_id' => NULL, - 'visibility_id' => NULL, - ], - ], - ], - [ - 'name' => 'OptionGroup_tier_membership_prices_OptionValue_49', - 'entity' => 'OptionValue', - 'cleanup' => 'unused', - 'update' => 'unmodified', - 'params' => [ - 'version' => 4, - 'values' => [ - 'option_group_id.name' => 'tier_membership_prices', - 'label' => '49', - 'value' => '30', - 'name' => '49', - 'grouping' => NULL, - 'filter' => 0, - 'is_default' => FALSE, - 'description' => '15-49', - 'is_optgroup' => FALSE, - 'is_reserved' => TRUE, - 'is_active' => TRUE, - 'icon' => NULL, - 'color' => NULL, - 'component_id' => NULL, - 'domain_id' => NULL, - 'visibility_id' => NULL, - ], - ], - ], - [ - 'name' => 'OptionGroup_tier_membership_prices_OptionValue_9999999', - 'entity' => 'OptionValue', - 'cleanup' => 'unused', - 'update' => 'unmodified', - 'params' => [ - 'version' => 4, - 'values' => [ - 'option_group_id.name' => 'tier_membership_prices', - 'label' => '9999999', - 'value' => '40', - 'name' => '9999999', - 'grouping' => NULL, - 'filter' => 0, - 'is_default' => FALSE, - 'description' => '50+', - 'is_optgroup' => FALSE, - 'is_reserved' => TRUE, - 'is_active' => TRUE, - 'icon' => NULL, - 'color' => NULL, - 'component_id' => NULL, - 'domain_id' => NULL, - 'visibility_id' => NULL, - ], - ], - ], - [ - 'name' => 'CustomGroup_Employee_count', - 'entity' => 'CustomGroup', - 'cleanup' => 'unused', - 'update' => 'unmodified', - 'params' => [ - 'version' => 4, - 'values' => [ - 'name' => 'Employee_count', - 'title' => 'Employee count', - 'extends' => 'Organization', - 'extends_entity_column_value' => NULL, - 'style' => 'Inline', - 'collapse_display' => FALSE, - 'help_pre' => '', - 'help_post' => '', - 'weight' => 1, - 'is_active' => TRUE, - 'is_multiple' => FALSE, - 'min_multiple' => NULL, - 'max_multiple' => NULL, - 'collapse_adv_display' => TRUE, - 'created_date' => '2022-07-21 14:04:47', - 'is_reserved' => FALSE, - 'is_public' => TRUE, - 'icon' => '', - 'extends_entity_column_id' => NULL, - ], - ], - ], - [ - 'name' => 'CustomGroup_Employee_count_CustomField_Employee_count', - 'entity' => 'CustomField', - 'cleanup' => 'unused', - 'update' => 'unmodified', - 'params' => [ - 'version' => 4, - 'values' => [ - 'custom_group_id.name' => 'Employee_count', - 'name' => 'Employee_count', - 'label' => 'Employee count', - 'data_type' => 'String', - 'html_type' => 'Text', - 'default_value' => NULL, - 'is_required' => FALSE, - 'is_searchable' => FALSE, - 'is_search_range' => FALSE, - 'help_pre' => NULL, - 'help_post' => NULL, - 'mask' => NULL, - 'attributes' => NULL, - 'javascript' => NULL, - 'is_active' => TRUE, - 'is_view' => FALSE, - 'options_per_line' => NULL, - 'text_length' => 255, - 'start_date_years' => NULL, - 'end_date_years' => NULL, - 'date_format' => NULL, - 'time_format' => NULL, - 'note_columns' => 60, - 'note_rows' => 4, - 'column_name' => 'employee_count_1', - 'serialize' => 0, - 'filter' => NULL, - 'in_selector' => FALSE, - ], - ], - ], - [ - 'name' => 'CustomGroup_Employee_count_CustomField_Employee_count_including_subsidiaries', - 'entity' => 'CustomField', - 'cleanup' => 'unused', - 'update' => 'unmodified', - 'params' => [ - 'version' => 4, - 'values' => [ - 'custom_group_id.name' => 'Employee_count', - 'name' => 'Employee_count_including_subsidiaries', - 'label' => 'Employee count including subsidiaries', - 'data_type' => 'String', - 'html_type' => 'Text', - 'default_value' => NULL, - 'is_required' => FALSE, - 'is_searchable' => FALSE, - 'is_search_range' => FALSE, - 'help_pre' => NULL, - 'help_post' => NULL, - 'mask' => NULL, - 'attributes' => NULL, - 'javascript' => NULL, - 'is_active' => TRUE, - 'is_view' => TRUE, - 'options_per_line' => NULL, - 'text_length' => 255, - 'start_date_years' => NULL, - 'end_date_years' => NULL, - 'date_format' => NULL, - 'time_format' => NULL, - 'note_columns' => 60, - 'note_rows' => 4, - 'column_name' => 'employee_count_including_subsidi_2', - 'serialize' => 0, - 'filter' => NULL, - 'in_selector' => FALSE, - ], - ], - ], +return [ [ 'name' => 'RelationshipType_1', 'entity' => 'RelationshipType', @@ -281,4 +22,4 @@ return []; ], ], ], -];*/ +]; diff --git a/templates/CRM/Tieredpricingformembership/Form/TierPrice.tpl b/templates/CRM/Tieredpricingformembership/Form/TierPrice.tpl index 695a484746d46f41a906fbde76dc96d1dd8b9e1a..ea060bff36a295726e099b3814c43485908ad2d5 100644 --- a/templates/CRM/Tieredpricingformembership/Form/TierPrice.tpl +++ b/templates/CRM/Tieredpricingformembership/Form/TierPrice.tpl @@ -1,11 +1,10 @@ {* HEADER *} -<div class="crm-submit-buttons"> -{include file="CRM/common/formButtons.tpl" location="top"} -</div> - {* FIELD EXAMPLE: OPTION 1 (AUTOMATIC LAYOUT) *} +{if $action eq 8} + Do you want to delete this entry? +{/if} <table class="form-layout-compressed"> <tr class="crm-tierprice-form-block-membership_type_id"> <td class="label"> diff --git a/templates/CRM/Tieredpricingformembership/Page/TierPrice.tpl b/templates/CRM/Tieredpricingformembership/Page/TierPrice.tpl deleted file mode 100644 index f037aff6d12399076ed59f1caefa1925e30da25f..0000000000000000000000000000000000000000 --- a/templates/CRM/Tieredpricingformembership/Page/TierPrice.tpl +++ /dev/null @@ -1,36 +0,0 @@ -{if $action eq 1 or $action eq 2 or $action eq 8} - {include file="CRM/Tieredpricingformembership/Form/TierPrice.tpl"} -{else} -<div class="crm-content-block crm-block"> - {if $tierPrices} - <div id="tierprices"> - <table class="selector row-highlight"> - <tr class="columnheader"> - <th>{ts}Membership Type Id{/ts}</th> - <th>{ts}Tier Level Minimum Staff{/ts}</th> - <th>{ts}Tier Level Maximum Staff{/ts}</th> - <th>{ts}Unit Price{/ts}</th> - <th></th> - </tr> - {foreach from=$tierPrices item=tierPrice} - <tr id="tier-price-{$row.id}" class="crm-entity {cycle values="odd-row,even-row"}"> - <td>{$tierPrice.membership_type_id}</td> - <td>{$tierPrice.min_staff_tier_level}</td> - <td>{$tierPrice.max_staff_tier_level}</td> - <td>{$tierPrice.unit_price}</td> - <td>{$tierPrice.action|smarty:nodefaults|replace:'xx':$row.id}</td> - </tr> - {/foreach} - </table> - </div> - {elseif $action ne 1} - <div class="messages status no-popup"> - {icon icon="fa-info-circle"}{/icon} - {ts}There are no Tier Prices entered.{/ts} - </div> - <div class="action-link"> - {crmButton p='civicrm/admin/tierprice' q="action=add&reset=1" id="newTierPrice" icon="plus-circle"}{ts}Add Tier Price{/ts}{/crmButton} - </div> - {/if} -</div> -{/if} diff --git a/tieredpricingformembership.php b/tieredpricingformembership.php index 4e3a3957851fbf87a1795cf93656e6342c18881c..90b93f0c2a126891518cd24d9239ab079e9dd0da 100644 --- a/tieredpricingformembership.php +++ b/tieredpricingformembership.php @@ -1,8 +1,10 @@ + <?php require_once 'tieredpricingformembership.civix.php'; // phpcs:disable -use CRM_Tieredpricingformembership_ExtensionUtil as E; +use CRM_Tieredpricingformembership_Utils as E; +use CRM_Tieredpricingformembership_ExtensionUtil as F; // phpcs:enable /** @@ -80,107 +82,136 @@ function tieredpricingformembership_civicrm_entityTypes(&$entityTypes) { } function tieredpricingformembership_civicrm_post($op, $objectName, $objectId, &$objectRef) { + // when a new or existing organization is updated, recalculate and save the employee count if ($objectName == 'Organization' && in_array($op, ['edit', 'create'])) { - $subsdiaryOrgs = \Civi\Api4\Relationship::get(FALSE) - ->addWhere('relationship_type_id:name', '=', 'Has Subsidiary') - ->addWhere('contact_id_a', '=', $objectId) - ->execute(); - if (!empty($subsdiaryOrgs)) { - $subcount = 0; - $count = \Civi\Api4\Contact::get(FALSE)->addSelect('Employee_count.Employee_count')->addWhere('id', '=', $objectId)->execute()->first()['Employee_count.Employee_count'] ?? 0; - foreach ($subsdiaryOrgs as $org) { - $subcount += \Civi\Api4\Contact::get(FALSE)->addSelect('Employee_count.Employee_count')->addWhere('id', '=', $org['contact_id_b'])->execute()->first()['Employee_count.Employee_count'] ?? 0; - } - $subcount += $count; -/* - \Civi\Api4\Contact::update(FALSE) - ->addValue('id', $objectId) - ->addValue('Employee_count.Employee_count_including_subsidiaries', $count); -*/ - $cfID = \Civi\Api4\CustomField::get(FALSE) - ->addSelect('id') - ->addWhere('custom_group_id:name', '=', 'Employee_count') - ->addWhere('name', '=', 'Employee_count_including_subsidiaries') - ->execute()->first()['id']; - civicrm_api3('CustomValue', 'create', [ - 'entity_id' => $objectId, - 'custom_' . $cfID => $subcount, - ]); - - $cfID = _get_custom_field_id_by_name('Tier_prices', 'Option_group_containing_price_tiers_based_on_employee_count_inc'); - $membershipTypes = \Civi\Api4\MembershipType::get(FALSE)->addWhere('member_of_contact_id', $objectId)->execute(); - $price = _get_tier_price_by_count($subcount); - foreach ($membershipTypes as $membershipType) { - civicrm_api3('CustomValue', 'create', [ - 'entity_id' => $membershipType['id'], - 'custom_' . $cfID => $price, - ]); - } + E::updateEmployeeCount($objectId); + } + // when a new or existing subsidiary relationship is updated, recalculate and save the employee count + if ($objectName == 'Relationship' && in_array($op, ['edit', 'create'])) { + if ($objectRef->relationship_type_id == \Civi\Api4\RelationshipType::get(FALSE)->addWhere('name_a_b', '=', 'Has Subsidiary')->execute()->first()['id']) { + E::updateEmployeeCount($objectRef->contact_id_a); } } } -function _get_custom_field_id_by_name($fieldName, $cgName) { - return \Civi\Api4\CustomField::get(FALSE) - ->addSelect('id') - ->addWhere('custom_group_id:name', '=', $cgName) - ->addWhere('name', '=', $fieldName) - ->execute()->first()['id']; +function tieredpricingformembership_civicrm_postProcess($formName, &$form) { + // when a employee count of a organization is updated from inline edit in contact summary page, recalculate and save the employee count + if ('CRM_Contact_Form_Inline_CustomData' == $formName) { + if ($form->_contactType == 'Organization' && !empty($form->_contactId)) { + $cgID = \Civi\Api4\CustomGroup::get(FALSE)->addWhere('name', '=', 'Employee_count')->execute()->first()['id']; + if (!empty($form->_submitValues['custom_' . $cgID . '_' . $form->_submitValues['customRecId']])) { + E::updateEmployeeCount($form->_contactId, $form->_submitValues['custom_' . $cgID . '_' . $form->_submitValues['customRecId']]); + } + } + } + // update existing contribution with updated line-item + if ($formName == 'CRM_Contribute_Form_Contribution_Main') { + // get all mapping record between membership type and organization type and number of beds fields + $mappingRecord = E::mappedEntries(); + $lineItems = $tierPrices = []; + $totalAmount = 0; + $cfID = E::getCustomFieldIDByName('Organization', 'Primary_Donor'); + // get the employee count of donor organization + $employeeCount = \Civi\Api4\Contact::get(FALSE) + ->addSelect('Employee_count.Employee_count_including_subsidiaries') + ->addWhere('id', '=', $form->_submitValues['custom_' . $cfID]) + ->execute()->first()['Employee_count.Employee_count_including_subsidiaries'] ?? 0; + // update the line-item unit price based tier level price, which is decided by tier range the employee count falls + $formLineItems = $form->get('lineItem'); + foreach ($formLineItems[$form->_priceSetId] as &$item) { + if (empty($tierPrices[$item['membership_type_id']])) { + // fetch the tier price of selected membership type + $tierPrices[$item['membership_type_id']] = \Civi\Api4\TierPrice::get(FALSE) + ->addSelect('max_staff_tier_level', 'min_staff_tier_level', 'unit_price') + ->addWhere('membership_type_id', '=', $item['membership_type_id']) + ->execute()->getArrayCopy(); + } + $key = 'price_' . $item['price_field_id'] . '_' . $item['price_field_value_id']; + // qty is going to be number of beds selected in the donation form + $item['qty'] = $form->_submitValues[$mappingRecord[$key]['qty']]; + foreach ($tierPrices[$item['membership_type_id']] as $k1 => $tierPrice) { + // if the employee count of the organization falls in the tier range the get the unit-price + if (($employeeCount <= $tierPrice['max_staff_tier_level'] || empty($tierPrice['max_staff_tier_level'])) && $employeeCount >= $tierPrice['min_staff_tier_level']) { + $item['unit_price'] = $tierPrice['unit_price']; + } + } + $item['line_total'] = $item['qty'] * $item['unit_price']; + $totalAmount += $item['line_total']; + } + $form->set('lineItem', $formLineItems); + $form->set('amount', $totalAmount); + $form->_params['amount'] = $totalAmount; + $form->_values['amount'] = $totalAmount; + } + + if ($formName == 'CRM_Contribute_Form_Contribution_Confirm') { + $cfID = E::getCustomFieldIDByName('Organization', 'Primary_Donor'); + // update the existing contribution with updated line-item, total amount and organization contact ID + civicrm_api3('Contribution', 'create', [ + 'id' => $form->_contributionID, + 'contact_id' => $form->_submitValues['custom_' . $cfID], + 'contribution_status_id' => 'Completed', + ]); + + // update the primary membership to selected primary organization + foreach (civicrm_api3('MembershipPayment', 'get', ['contribution_id' => $form->_contributionID])['values'] as $membershipPayment) { + CRM_Core_DAO::executeQuery("UPDATE civicrm_membership SET contact_id = %1 WHERE id = %2", [1 => [$form->_submitValues['custom_' . $cfID], 'Integer'], 2 => [$membershipPayment['membership_id'], 'Integer']]); + } + } } + function tieredpricingformembership_civicrm_buildForm($formName, &$form) { - if ($formName == 'CRM_Member_Form_MembershipType') { - $cfID = _get_custom_field_id_by_name('Employee_count_including_subsidiaries', 'Employee_count'); + if ($formName == 'CRM_Contribute_Form_Contribution_Main') { + $mappingRecord = E::mappedEntries(); + $mappingRecord = json_encode($mappingRecord); + $bednos = json_encode($bednos); + $customKey = 'custom_' . E::getCustomFieldIDByName('Type_of_Organization', 'Organization_Type'); Civi::resources()->addScript(" - CRM.$(function($) { - $( document ).ajaxComplete(function() { - $('#member_of_contact_id').on('change', function(e) { - CRM.api3('Contact', 'get', { - 'sequential': 1, - 'return': [\"custom_{$cfID}\"], - 'id': $(this).val() - }).then(function(result) { - var c = 0, - count = parseInt(result['values'][0]['custom_2']); - $('[id^=\'custom_3\'] > option').each(function(){ - if (count < parseInt(this.text) || count == parseInt(this.text)) { - c++; - } - if (c == 1) { - $('[id^=\'custom_3\']').val(this.value).trigger('change'); - $('#minimum_fee').val(this.value); - return false; - } - }); - }); - }); - }); -}); - ", -100, 'html-header'); + CRM.$(function($) { + var mapping = {$mappingRecord}, + bednos = {$bednos}; + $('#priceset').hide(); + $('input[type=\"text\"]').on('change', function(e) { + if ($.inArray($(this).attr('id'), bednos) !== -1) { + selectPriceField(); + } + }); + $('#_qf_Main_upload-bottom').on('click', function(e) { + selectPriceField(); + }); + $('input[name*=\"{$customKey}\"]').on('click', function(e) { + $.each(mapping, function(k, v) { + if (v.org_type == $(this).attr('id') && $.trim($('#' + v.qty).val()) != '') { + $('#' + k).trigger('click'); + } + }); + }); + function selectPriceField() { + var orgType = []; + $('input[name*=\"{$customKey}\"]').filter(':checked').each(function() { + orgType.push($(this).attr('id')); + }); + $.each(mapping, function(k, v) { + if ($.trim($('#' + v.qty).val()) != '' && $.inArray(v.org_type, orgType) !== -1) { + if (!$('#' + k).is(':checked')) { + $('#' + k).trigger('click'); + } + } + else if ($.trim($('#' + v.qty).val()) == '' && $('#' + k).is(':checked')) { + $('#' + k).trigger('click'); + } + }); + } + });"); } } -// --- Functions below this ship commented out. Uncomment as required. --- - -/** - * Implements hook_civicrm_preProcess(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_preProcess - */ -//function tieredpricingformembership_civicrm_preProcess($formName, &$form) { -// -//} - -/** - * Implements hook_civicrm_navigationMenu(). - * - * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_navigationMenu - */ function tieredpricingformembership_civicrm_navigationMenu(&$menu) { _tieredpricingformembership_civix_insert_navigation_menu($menu, 'Administer/CiviMember', array( - 'label' => E::ts('Tier Prices'), + 'label' => F::ts('Tier Prices'), 'name' => 'civimember_tier_prices', - 'url' => 'civicrm/admin/tierprice', + 'url' => 'civicrm/tiered-membership-prices', 'permission' => 'access CiviMember', 'operator' => 'OR', 'separator' => 0, diff --git a/xml/Menu/tieredpricingformembership.xml b/xml/Menu/tieredpricingformembership.xml index 37fc6978de5ebbe25f1a4bd65ba378a2db61b66a..bf31348b739d3836a17f63f7fa2a1768139f38ce 100644 --- a/xml/Menu/tieredpricingformembership.xml +++ b/xml/Menu/tieredpricingformembership.xml @@ -2,7 +2,7 @@ <menu> <item> <path>civicrm/admin/tierprice</path> - <page_callback>CRM_Tieredpricingformembership_Page_TierPrice</page_callback> + <page_callback>CRM_Tieredpricingformembership_Form_TierPrice</page_callback> <title>Tier Prices</title> <access_arguments>administer CiviMember</access_arguments> </item>