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

Merge Dev Branch #1036

Merged
merged 34 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c0eb1a9
BTHAMM-15: Add custom delay before updating line item total
olayiwola-compucorp May 14, 2024
fbbac39
BTHAMM-15: Resolve incorrect total due to round off
olayiwola-compucorp May 27, 2024
e10157d
BTHAMM-15: Add delay between lineitem population
olayiwola-compucorp May 27, 2024
0a82f75
COMCL-603: Update case type entity name as that has been updated in c…
Jul 15, 2024
f15853c
Merge pull request #1019 from compucorp/COMCL-603-fix-case-type-entit…
shahrukh-compuco Jul 16, 2024
79f00f6
COMCL-603: Correct visual bundle assets path
Jul 18, 2024
83a8e87
Merge pull request #1020 from compucorp/COMCL-603-fix-case-type-entit…
shahrukh-compuco Jul 18, 2024
fac25b6
COMCL-644: Fix contribution settings page
Jul 25, 2024
fd53403
Merge pull request #1021 from compucorp/COMCL-644-fix-contribution-se…
shahrukh-compuco Jul 25, 2024
e23cc9f
COMCL-620: Fix add case button issue
Aug 1, 2024
b8ad51e
Merge pull request #1023 from compucorp/COMCL-620-fix-permissions-issue
shahrukh-compuco Aug 1, 2024
3a82313
COMCL-649: Fix custom group page
Aug 2, 2024
59b9ab2
Merge pull request #1024 from compucorp/comcl-649-fix-custom-group-ad…
shahrukh-compuco Aug 2, 2024
d3b6056
COMCL-674: Fix new contribution page layout
Aug 2, 2024
c67a088
Merge pull request #1025 from compucorp/comcl-674-fix-new-contributio…
shahrukh-compuco Aug 2, 2024
09de836
COMCL-640: Ensure submit buttons will validate the form properly
olayiwola-compucorp Aug 5, 2024
06c2ae4
Merge pull request #1026 from compucorp/COMCL-640-fix-activity
olayiwola-compucorp Aug 8, 2024
9837098
COMCL-706: Fix menu styles
Aug 8, 2024
3a7f19f
Merge pull request #1027 from compucorp/comcl-706-fix-menu-styles
shahrukh-compuco Aug 9, 2024
270a302
COMCL-716: Fix other relationship tab on case details page
Aug 13, 2024
f3da082
Merge pull request #1029 from compucorp/comcl-716-fix-other-relations…
shahrukh-compuco Aug 13, 2024
4cbde12
COMCL-701: Fix auto filling of owner id field on create quotation form
Aug 14, 2024
7a594fa
COMCL-704: Fix quotation template
Aug 14, 2024
ff65d4b
Merge pull request #1016 from compucorp/BTHAMM-15-delay-total-calc
shahrukh-compuco Aug 14, 2024
189d252
Merge pull request #1030 from compucorp/comcl-701-fix-owner-id-field
shahrukh-compuco Aug 14, 2024
646eeee
Merge pull request #1031 from compucorp/comcl-704-fix-quotation-template
shahrukh-compuco Aug 14, 2024
ba11f06
COMCL-709: Fix case search on dashboard
Aug 14, 2024
74b4d50
Merge pull request #1032 from compucorp/comcl-709-fix-cases-search
shahrukh-compuco Aug 14, 2024
1edecbf
BTHAMM-31: Set sales order line items from backend
olayiwola-compucorp Aug 16, 2024
e1b8ca8
COMCL-707: Fix case category Terms
Aug 16, 2024
bae28d3
COMCL-714: Fix case activity report
Aug 16, 2024
431cb63
Merge pull request #1033 from compucorp/BTHAMM-31-correct-qot
olayiwola-compucorp Aug 19, 2024
9368043
Merge pull request #1035 from compucorp/comcl-714-fix-activity-report…
shahrukh-compuco Aug 19, 2024
ad19a83
Merge pull request #1034 from compucorp/comcl-707-fix-case-category-t…
shahrukh-compuco Aug 19, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ public function addQuotationsNoteField(CRM_Core_Form &$form) {
'weight' => 5,
'description' => ts('Enter note or message to be displyaed on quotations'),
'attributes' => ['rows' => 2, 'cols' => 40],
'name' => $fieldName,
'quick_form_type' => 'Element',
],
];

$form->add('wysiwyg', $fieldName, $field[$fieldName]['title'], $field[$fieldName]['attributes']);
$form->assign('htmlFields', array_merge($form->get_template_vars('htmlFields'), $field));
$form->assign('fields', array_values(array_merge($form->getTemplateVars('fields'), $field)));
$value = Civi::settings()->get($fieldName) ?? NULL;
$form->setDefaults(array_merge($form->_defaultValues, [$fieldName => $value]));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

use Civi\Api4\PriceField;
use Civi\Api4\PriceFieldValue;
use Civi\Api4\PriceSet;
use CRM_Civicase_ExtensionUtil as E;
use CRM_Civicase_Service_CaseSalesOrderLineItemsGenerator as salesOrderlineItemGenerator;

Expand Down Expand Up @@ -27,6 +30,14 @@ public function run(CRM_Core_Form &$form, $formName) {
}
$lineItemGenerator = new salesOrderlineItemGenerator($salesOrderId, $toBeInvoiced, $percentValue);
$lineItems = $lineItemGenerator->generateLineItems();
$priceField = $this->getDefaultPriceSetFields();
\Civi::cache('short')->set('sales_order_line_items', $lineItems);

$submittedValues = [];
foreach ($lineItems as $index => &$lineItem) {
$submittedValues[] = $priceField[$index]['id'];
}
$form->assign('lineItemSubmitted', json_encode($submittedValues));

CRM_Core_Resources::singleton()
->addScriptFile(E::LONG_NAME, 'js/sales-order-contribution.js')
Expand Down Expand Up @@ -61,4 +72,25 @@ public function shouldRun(CRM_Core_Form $form, string $formName, ?int $salesOrde
&& !empty($salesOrderId);
}

/**
* Returns default contribution price set fields.
*
* @return array
* Array of price fields
*/
private function getDefaultPriceSetFields(): array {
$priceSet = PriceSet::get(FALSE)
->addWhere('name', '=', 'default_contribution_amount')
->addWhere('is_quick_config', '=', 1)
->execute()
->first();

return PriceField::get(FALSE)
->addWhere('price_set_id', '=', $priceSet['id'])
->addChain('price_field_value', PriceFieldValue::get(FALSE)
->addWhere('price_field_id', '=', '$id')
)->execute()
->getArrayCopy();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ public function run($form, $formName) {
return;
}

$contactTypes = json_decode($form->get_template_vars('contactTypes'));
$multipleTypes = $form->get_template_vars('allowMultiple');
$caseEntityNames = CaseType::buildOptions('case_type_category', 'validate');

// This is the generic entity for all cases.
$caseEntityNames[] = 'Case';

$contactTypes = array_merge($contactTypes, $caseEntityNames);
foreach ($caseEntityNames as $caseEntityName) {
$multipleTypes[$caseEntityName] = TRUE;
}

$form->assign('contactTypes', json_encode($contactTypes));
$form->assign('allowMultiple', $multipleTypes);
CRM_Core_Resources::singleton()->addSetting([
'caseEntityNames' => $caseEntityNames,
]);
Expand Down
33 changes: 33 additions & 0 deletions CRM/Civicase/Hook/PageRun/AddCaseTypeCategoryToCache.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

use CRM_Civicase_Helper_CaseUrl as CaseUrlHelper;

/**
* Add case type category to cache.
*/
class CRM_Civicase_Hook_PageRun_AddCaseTypeCategoryToCache {

/**
* Add case type category to cache.
*
* @param object $page
* Page Object.
*/
public function run(&$page): void {
$this->addCaseTypeCategoryToCache();
}

/**
* Add case type category to cache.
*/
private function addCaseTypeCategoryToCache(): void {
if (CRM_Utils_System::currentPath() === 'civicrm/case/a') {
$caseCategoryInfo = CaseUrlHelper::getCategoryParamsFromUrl();
\Civi::cache('metadata')->set('current_case_category', $caseCategoryInfo[1]);
}
elseif (!in_array(CRM_Utils_System::currentPath(), ['civicrm/asset/builder', 'civicrm/user-menu'], TRUE)) {
\Civi::cache('metadata')->set('current_case_category', NULL);
}
}

}
125 changes: 125 additions & 0 deletions CRM/Civicase/Hook/alterContent/AddSalesOrderLineToContribution.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<?php

/**
* Adds sales order line items to the contribution.
*/
class CRM_Civicase_Hook_alterContent_AddSalesOrderLineToContribution {

/**
* Stores the sales order line items retrieved from the cache.
*
* @var array
*/
private $salesOrderLineItems;

/**
* Constructs the AddSalesOrderLindeToContribution class.
*
* @param string $content
* The content to be altered.
* @param array $context
* The context for the hook.
* @param string $tplName
* The name of the template.
*/
public function __construct(private &$content, private $context, private $tplName) {
$this->salesOrderLineItems = \Civi::cache('short')->get('sales_order_line_items');
}

/**
* Add sales order line items to the contribution.
*/
public function run() {
if (!$this->shouldRun()) {
return;
}

$this->addLineItems();
}

/**
* Adds sales order line items to the contribution.
*
* This method retrieves the sales order line items from the cache, and then
* updates the corresponding input fields in the contribution
* page's HTML content.
*/
public function addLineItems() {
$dom = new DomDocument();
$dom->loadHTML($this->content);

$table = $dom->getElementById('info');

// Delete the first row (index 0)
if ($table) {
$firstRow = $table->getElementsByTagName('tr')->item(0);
if ($firstRow) {
$table->removeChild($firstRow);
}
}

$rows = $table->getElementsByTagName('tr');
// Set the values in the DOM.
foreach ($this->salesOrderLineItems as $index => $item) {
if ($index < $rows->length) {
// Get the current row.
$row = $rows->item($index);

// Remove 'hiddenElement' class if it exists.
$row->setAttribute('class', str_replace('hiddenElement', '', $row->getAttribute('class')));

// Set the values from the line item array.
$inputs = $row->getElementsByTagName('input');
$selects = $row->getElementsByTagName('select');

foreach ($inputs as $input) {
$name = $input->getAttribute('name');

if (strpos($name, 'qty') !== FALSE) {
$input->setAttribute('value', $item['qty']);
}
elseif (strpos($name, 'tax_amount') !== FALSE) {
$input->setAttribute('value', $item['tax_amount']);
}
elseif (strpos($name, 'line_total') !== FALSE) {
$input->setAttribute('value', $item['line_total']);
}
elseif (strpos($name, 'unit_price') !== FALSE) {
$input->setAttribute('value', $item['unit_price']);
}
elseif (strpos($name, 'label') !== FALSE) {
$input->setAttribute('value', $item['label']);
}
}

foreach ($selects as $select) {
$name = $select->getAttribute('name');

if (strpos($name, 'financial_type_id') !== FALSE) {
foreach ($select->getElementsByTagName('option') as $option) {
if ($option->getAttribute('value') == $item['financial_type_id']) {
$option->setAttribute('selected', 'selected');
break;
}
}
}
}
}
}

\Civi::cache('short')->delete('sales_order_line_items');

$this->content = $dom->saveHTML();
}

/**
* Determines whether the hook should run.
*
* @return bool
* TRUE if the hook should run, FALSE otherwise.
*/
public function shouldRun() {
return $this->tplName === "CRM/Contribute/Page/Tab.tpl" && $this->context == "page" && !empty($this->salesOrderLineItems);
}

}
2 changes: 1 addition & 1 deletion CRM/Civicase/Service/CaseSalesOrderLineItemsGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private function lineItemToContributionLineItem(array $item) {
'entity_table' => 'civicrm_contribution',
'financial_type_id' => $item['financial_type_id'],
'line_total' => round($item['total'], 2),
'unit_price' => round($item['unit_price'], 2),
'unit_price' => $item['unit_price'],
];
}

Expand Down
32 changes: 32 additions & 0 deletions CRM/Civicase/Upgrader/Steps/Step0020.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use CRM_Civicase_Setup_Manage_QuotationTemplateManager as QuotationTemplateManager;

/**
* Update sales order invoice message template.
*/
class CRM_Civicase_Upgrader_Steps_Step0020 {

/**
* Runs the upgrader changes.
*
* @return bool
* Return value in boolean.
*/
public function apply(): bool {
try {
(new QuotationTemplateManager())->create();
}
catch (\Throwable $th) {
\Civi::log()->error('Error upgrading Civicase', [
'context' => [
'backtrace' => $th->getTraceAsString(),
'message' => $th->getMessage(),
],
]);
}

return TRUE;
}

}
5 changes: 3 additions & 2 deletions CRM/Civicase/XMLProcessor/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public static function getCaseReport($clientID, $caseID, $activitySetName, $para
$template->assign('caseId', $caseID);
$template->assign('clientID', $clientID);
$template->assign('activitySetName', $activitySetName);
$allActivityTypes = CRM_Case_PseudoConstant::caseActivityType();

if (!empty($params['is_redact'])) {
$report->_isRedact = TRUE;
Expand Down Expand Up @@ -96,10 +97,10 @@ public static function getCaseReport($clientID, $caseID, $activitySetName, $para

if ($activitySetName && !empty($activitySetNames[$activitySetName])) {
$timelineActivities = $report->getActivityTypes($xml, $activitySetName);
$activityTypes = !empty($timelineActivities) ? $timelineActivities : CRM_Case_XMLProcessor::allActivityTypes();
$activityTypes = !empty($timelineActivities) ? $timelineActivities : $allActivityTypes;
}
else {
$activityTypes = CRM_Case_XMLProcessor::allActivityTypes();
$activityTypes = $allActivityTypes;
}

if (!$activityTypes) {
Expand Down
6 changes: 3 additions & 3 deletions ang/civicase-base.ang.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
*/

use Civi\CCase\Utils as Utils;
use CRM_Civicase_Helper_OptionValues as OptionValuesHelper;
use CRM_Civicase_Helper_CaseUrl as CaseUrlHelper;
use CRM_Civicase_Helper_GlobRecursive as GlobRecursive;
use CRM_Civicase_Helper_NewCaseWebform as NewCaseWebform;
use CRM_Civicase_Helper_OptionValues as OptionValuesHelper;
use CRM_Civicase_Service_CaseCategoryCustomFieldsSetting as CaseCategoryCustomFieldsSetting;
use CRM_Civicase_Helper_CaseUrl as CaseUrlHelper;

[$caseCategoryId, $caseCategoryName] = CaseUrlHelper::getCategoryParamsFromUrl();

Expand Down Expand Up @@ -110,7 +110,7 @@ function expose_settings(array &$options, array $defaults) {
function get_base_js_files() {
return array_merge(
[
'assetBuilder://visual-bundle.js',
Civi::service('asset_builder')->getUrl('visual-bundle.js'),
'ang/civicase-base.js',
],
GlobRecursive::getRelativeToExtension(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h1 ng-if="view !== 'contact'" crm-page-title>{{ ts('Manage Quotations') }}</h1>
<afsearch-contact-quotations options="{contact_id: contactId}" ng-switch-when="contact"> </afsearch-contact-quotations>
<afsearch-quotations ng-switch-default> </afsearch-quotations>
</div>

</div>
</div>
</div>
Expand All @@ -35,7 +35,6 @@ <h1 ng-if="view !== 'contact'" crm-page-title>{{ ts('Manage Quotations') }}</h1>
margin: 0em 1em;
}
#bootstrap-theme.civicase__container .quotation__list ul.dropdown-menu {
right: 0;
left: auto;
}
</style>
Loading
Loading