OTRS - change tickets history showing in new ticket based on customer User not Customer ID - otrs

I would like to change the tickets history that is showing when you start to create a new ticket based on the customer user that is starting the ticket creation and not on the Customer ID as is the default.
Any guidance? Thank you.

Do you mean the open tickets that show on the right-hand side, in the Customer Information box? You can add history for the customer login rather than the customer ID by enabling
Frontend::CustomerUser::Item###16-OpenTicketsForCustomerUserLogin and disabling Frontend::CustomerUser::Item###15-OpenTickets in SysConfig.
If you'd mean the list of tickets that is shown on the bottom of the screen, the limitation to searching by customerid is unfortunately hard-coded in AgentCustomerSearch.pm so changing that would need code changes.

In
...otrs/Kernel/Modules/AgentCustomerSearch.pm
in this block of code (around line 250),
Add: CustomerUserLoginRaw => $CustomerUserID
Comment out: CustomerIDRaw => #CustomerIDs,
It should look like this:
my #ViewableTickets;
if (#CustomerIDs) {
#ViewableTickets = $TicketObject->TicketSearch(
Result => 'ARRAY',
Limit => 250,
SortBy => [$SortBy],
OrderBy => [$OrderBy],
# CustomerIDRaw => \#CustomerIDs,
CustomerUserLoginRaw => $CustomerUserID,
UserID => $Self->{UserID},
Permission => 'ro',
);
}

Related

Where is location of renderView function that used in Opencart Journal 3 theme Quick Checkout controller

I am trying to auto add a specific product to cart when visitors added an other specific product to cart on Opencart 3.0.2.0 and Journal 3 theme in Quick Checkout.
I could do it in cart.twig but I couldn't do it in Quick Checkout because I can't find where is renderView function that rendering cart_block in checkout controller.
Related code is bellow;
This code from catalog>controller>journal3>checkout.php.
From line 204 to 215.
$data['cart_block'] = $this->renderView('journal3/checkout/cart', array(
'column_image' => $this->language->get('column_image'),
'column_name' => $this->language->get('column_name'),
'column_model' => $this->language->get('column_model'),
'column_quantity' => $this->language->get('column_quantity'),
'column_price' => $this->language->get('column_price'),
'column_total' => $this->language->get('column_total'),
'text_recurring_item' => $this->language->get('text_recurring_item'),
'button_update' => $this->language->get('button_update'),
'button_remove' => $this->language->get('button_remove'),
'error_warning' => $this->language->get('error_stock'),
));
One simple but not optimal solution can be like this:
Go to catalog/controller/checkout/cart.php, find the add method public function add() { then in that add method find the following line of code:
$this->cart->add($this->request->post['product_id'], $quantity, $option, $recurring_id);
Just below that line of code, you can add the following line of code:
if($this->request->post['product_id'] ==43){
$this->cart->add('28',1);
}
** Please make changes as per your requirement. The above code means if product id 43 is added then product id 28 gets added automatically, but keep in mind if someone adds two 43 then there will be two 28 products.

Oracle APEX how do I populate cascading select lists without page submit

I have an APEX page with a few select lists, using collections to save and refresh the page. The "System" select list is dependent upon the "Brand" selected value. I have the page working how I want, but it requires the page to be submitted after a "Brand" value is chosen so that the "System" lov is properly populated.
I am trying to make it so that when the "Brand" value is changed or selected, the "System" lov is changed immediately without needing a page submit. I've been reading and it seems you need to use jQuery and AJAX callback, but I just cannot get my head around that and make any progress.
Hoping someone can help me. I am certainly a rookie with web coding in general.
Added: my local APEX version is 5.0.3.
https://apex.oracle.com/pls/apex/f?p=4550
Workspace: UNCLE_BUCK_WS
User: developer1
Pwd: developer1
Application 83513 - Tooth Selector
Page 5: Page that works using submit page
Page 6: Page I started trying to use jQuery, but did not get very far
Added:
There is no cascading LOV for manual tabular form. See my region definition below. Hoping someone can still help, maybe copy my page and make the required changes.
select apex_item.select_list_from_query(p_idx => 1,
p_value => n001,
p_query => 'SELECT tooth_number display_value, tooth_number return_value FROM psp_teeth WHERE tooth_numbering_method = :P5_TOOTH_NUMBER_METHOD
ORDER BY tooth_number',
p_null_text => '- Choose Tooth -')
|| apex_item.hidden(p_idx => 50, p_value => seq_id) Tooth_Number
, apex_item.select_list_from_lov(p_idx => 10, p_value => c001, p_lov => 'BRAND', p_null_text => '- Choose Brand -') brand
, apex_item.select_list_from_lov(p_idx => 12, p_value => c002, p_lov => 'TYPE', p_null_text => '- Choose Type -') type
, apex_item.select_list (p_idx => 14,
p_value => c003,
p_list_values => CASE c001
WHEN 'BRAND_A' THEN 'SYSTEM_A1,SYSTEM_A2'
WHEN 'BRAND_B' THEN 'SYSTEM_B1,SYSTEM_B2'
END,
p_show_null => 'YES',
p_null_text => '- Choose System -') system
, apex_item.checkbox2(p_idx => 16, p_value => seq_id, p_checked_values => CASE c004 WHEN '1' THEN seq_id END) delete_row
from apex_collections
where collection_name = 'TEMPCOL'
Don't use tabular forms, they are archaic! Use an Interactive Grid instead, which supports cascading LOVs declaratively (you don't need to write any code, just specify that column TYPE cascades from column BRAND):
See page 9 in your app where I have created one (I didn't bother creating the master region). My LOV definition for TYPE is a bit cumbersome, you may be able to improve on that (i.e. get back to the "dynamic static" LOV that you had before).

How do I programmatically restore an Apex 5 report to default state?

I have an Interactive report in Apex 5, and each time the page load, I want it to look exactly as it was shown the first time I ran it, with default settings.
The problem is that if the user applies any filter, or hide columns, the next time the page loads, the report remembers that configuration.
I tried to use the APEX_IR.RESET_REPORT procedure undocumented here:
https://docs.oracle.com/database/121/AEAPI/apex_ir.htm#BABEJAFB
but it either doesn't works, or only undoes the last change, or needs many runs to actually work.
I tried a dynamic action at page load with this code:
DECLARE
v_region_id APEX_APPLICATION_PAGE_REGIONS.REGION_ID%TYPE;
BEGIN
SELECT region_id INTO v_region_id
FROM APEX_APPLICATION_PAGE_REGIONS
WHERE application_id = :APP_ID
AND page_id = :APP_PAGE_ID
AND static_id = 'Images_Report';
APEX_IR.RESET_REPORT(
P_page_id => :APP_PAGE_ID,
P_region_id => v_region_id,
p_report_id => null
);
END;
And I also tried this code
DECLARE
v_region_id APEX_APPLICATION_PAGE_REGIONS.REGION_ID%TYPE;
BEGIN
SELECT region_id INTO v_region_id
FROM APEX_APPLICATION_PAGE_REGIONS
WHERE application_id = :APP_ID
AND page_id = :APP_PAGE_ID
AND static_id = 'Images_Report';
APEX_IR.RESET_REPORT(
P_page_id => :APP_PAGE_ID,
P_region_id => v_region_id,
p_report_id => APEX_IR.GET_LAST_VIEWED_REPORT_ID(
p_page_id => :APP_PAGE_ID,
p_region_id => v_region_id
)
);
END;
I expect the report to look as in default state (on first run), every time I load the page.
Instead the report shows the last state, even if the user logs out, logs in and restarts the application.
Send RIR as the clear cache parameter in your URL
https://docs.oracle.com/database/apex-5.1/HTMDB/linking-to-interactive-reports.htm#GUID-B917CEB3-A0B9-414B-A90A-7B44DD15EA67
URL would look like
f?p=102:94:6722612001859::NO:RIR::
https://docs.oracle.com/database/apex-5.1/HTMDB/understanding-url-syntax.htm#HTMDB03019
The documentation states this regarding the apex_ir.reset_report procedure
This procedure should only be used in page submit processes.
Which could be why you had trouble

Auto apply coupon in Opencart 2.3.0.2

Trying to auto apply a coupon code (2 of them actually) when a customer checks out so that I can offer discounts when 4 and 10 items in a specif category or bought, WITHOUT the need for the customer to enter a code. I have tried adding manually the name of my coupon into the "amount" voucher of the /catalog/controller/checkout/cart.php file without success. Is there an easy fix for this?
// Gift Voucher
$data['vouchers'] = array();
if (!empty($this->session->data['vouchers'])) {
foreach ($this->session->data['vouchers'] as $key => $voucher) {
$data['vouchers'][] = array(
'key' => $key,
'description' => $voucher['description'],
'amount' => $this->currency->format($voucher['FOUR'], $this->session->data['currency']),

Getting current cart ID in prestashop

I am busy with a site built on Code Igniter that needs integration with Prestashop. In the site, when creating a user account, I save a "shop_id" to the database, which is then retrieved as a session variable when logging in.
I am using the Prestashop API to retrieve the customer successfully (using above "shop_id")
$xml = $this->PSWebService->get(
array('resource' => 'customers', 'id' => (int)$this->user['shop_id'])
);
This successfully returns the user in question, but there is no Cart IDs in this result.
Logging in to the back-end of my shop, I see that there are multiple carts associated with the logged in user.
My question is: How to I retrieve the LATEST cart ID using the API?
$userId = (int) $this->user['shop_id'];
$opt['resource'] = 'carts';
$xml = $this->PSWebService->get($opt);
$carts = $xml->carts->children();
foreach ($carts as $cart) {
$cartIds[] = $cart['id'];
}
for ($i = count($cartIds) - 1; $i > -1; $i--) {
$opt['id'] = $cartIds[$i];
$xml = $this->PSWebService->get($opt);
//since cart ids are descending the first found will be the latest
if ($xml->cart->id_customer == $userId) {
$latestCartId = $cartIds[$i];
break;
}
}
Kind of late, but I struggled a bit with this same problem and found a way to do it just from query, based on yenshirak's tip (since cart ids are descending the first found will be the latest).
I query the API directly using postman like this:
get all carts:
GET webserver/api/carts
get cart for customer:
GET webserver/api/carts?filter[id_customer]=1
get the most recent:
GET webserver/api/carts?filter[id_customer]=1&sort=[id_DESC]&limit=1
for a pretty print, you can also add params:
display=full&output_format=JSON
You can do this in php, I have not tested if the syntax is correct, but based on documentation it looks something like this:
$opt = array(
'resource' => 'carts',
'filter[id_customer]' => '[1]',
'sort' => '[id_DESC]',
'limit' => '1'
);
$xml = $webService->get($opt);