How can customize Oracle APEX Print PDF header & show Image - oracle

I have a problem with the oracle apex default PDF showing custom heading and company logo. as like below picture
enter link description here

EJ Egyed,
Here is my code below,
DECLARE
l_columns apex_data_export.t_columns;
l_context apex_exec.t_context;
l_export apex_data_export.t_export;
l_print_config apex_data_export.t_print_config;
BEGIN
l_context := apex_exec.open_query_context(
p_location => apex_exec.c_location_local_db,
p_sql_query => 'select * FROM emp order by deptno' );
-- Define columns
apex_data_export.add_column(
p_columns => l_columns,
p_name => 'DEPTNO',
p_heading => 'Dept No');
apex_data_export.add_column(
p_columns => l_columns,
p_name => 'EMPNO',
p_heading => 'Emp No');
apex_data_export.add_column(
p_columns => l_columns,
p_name => 'ENAME',
p_heading => 'Emp Name');
apex_data_export.add_column(
p_columns => l_columns,
p_name => 'SAL',
p_heading => 'Salary',
p_format_mask => 'FML999G999G999G999G990D00');
l_print_config := apex_data_export.get_print_config(
p_orientation => apex_data_export.c_orientation_portrait,
p_border_width => 1,
p_body_font_color => 'Black',
p_page_header => 'Dekko Legacy Group',
p_page_header_font_color => 'Black',
p_page_header_font_size => 20,
p_page_header_font_family => null,
p_page_header_font_weight => apex_data_export.c_font_weight_bold,
p_page_header_alignment => 'CENTER',
p_page_footer => 'Generated by '|| :APP_USER,
p_page_footer_font_color => 'Black',
p_page_footer_font_size => 10,
p_page_footer_font_family => null,
p_page_footer_font_weight => apex_data_export.c_font_weight_bold,
p_page_footer_alignment => 'LEFT',
p_border_color => 'Black');
l_export := apex_data_export.export (
p_context => l_context,
p_format => :P32_FORMAT,--apex_data_export.c_format_pdf,
p_columns => l_columns,
p_file_name => 'employees',
p_print_config => l_print_config
);
apex_exec.close( l_context );
apex_data_export.download(p_export => l_export);
EXCEPTION
WHEN others THEN
apex_exec.close( l_context );
raise;
END;

It's hard to add a logo and custom header to the default PDF export of Oracle APEX.
This is why we created APEX Office Print, which allows you to export based on a template you create. In your case, it's as easy as adding the logo and header in your Excel template and using a tag where you want the data to be. You find examples in the AOP Sample Apps.
There's a free tier of AOP and also paid options. Although it might be payable, you will save enormous time on creating the PDFs and reports you need and you have a much bigger toolset and options to give your end-users.
Hope that helps.

Related

ACL for Sending e-Mail with APEX Oracle 11.2

I'm trying to send e-Mail as a simple Send e-Mail process with Oracle APEX 11.2, and I can't figure out how the correct ACL has to be set. I tried this, but no success, still getting: ORA-24247: network access denied by access control list (ACL). What am I doing wrong?
SELECT * FROM dba_network_acl_privileges shows that all rules are granted and also select * from dba_network_acls shows both rules.
Thanks in Advance!
BEGIN
DBMS_NETWORK_ACL_ADMIN.DROP_ACL (acl => 'send_mail.xml' );
DBMS_NETWORK_ACL_ADMIN.CREATE_ACL('send_mail.xml','Allow mail to be send', 'APEX_050100', TRUE, 'connect');
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE('send_mail.xml','APEX_050100',TRUE, 'connect');
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE('send_mail.xml','APEX_050100',TRUE, 'resolve');
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL (acl => 'send_mail.xml',host => '*',lower_port => null, upper_port => null);
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL (acl => 'send_mail.xml',host => 'smtp.google.com',lower_port => null, upper_port => null);
commit;
END;
BEGIN
DBMS_NETWORK_ACL_ADMIN.DROP_ACL (acl => 'utl_smtp.xml' );
DBMS_NETWORK_ACL_ADMIN.CREATE_ACL('utl_smtp.xml','Allow mail to be send', 'APEX_050100', TRUE, 'connect');
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE('utl_smtp.xml','APEX_050100',TRUE, 'connect');
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE('utl_smtp.xml','APEX_050100',TRUE, 'resolve');
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL (acl => 'utl_smtp.xml',host => '*',lower_port => null, upper_port => null);
END;
This is how I do it.
-- Drop ACL ====================================================================
BEGIN
DBMS_NETWORK_ACL_ADMIN.drop_acl (acl => 'mydba.xml');
END;
/
-- Create ACL ==================================================================
BEGIN
DBMS_NETWORK_ACL_ADMIN.create_acl (
acl => 'mydba.xml',
description => 'SMTP, MAIL, HTTP Access',
principal => 'LITTLEFOOT',
is_grant => TRUE,
privilege => 'connect',
start_date => NULL,
end_date => NULL);
END;
/
-- Assign ACL ==================================================================
BEGIN
DBMS_NETWORK_ACL_ADMIN.assign_acl (acl => 'mydba.xml',
HOST => '*',
lower_port => NULL,
upper_port => NULL);
END;
/
-- Add privilege ===============================================================
BEGIN
-- LITTLEFOOT
DBMS_NETWORK_ACL_ADMIN.add_privilege (acl => 'mydba.xml',
principal => 'LITTLEFOOT',
is_grant => TRUE,
privilege => 'connect',
start_date => NULL,
end_date => NULL);
DBMS_NETWORK_ACL_ADMIN.add_privilege (acl => 'mydba.xml',
principal => 'LITTLEFOOT',
is_grant => TRUE,
privilege => 'resolve',
start_date => NULL,
end_date => NULL);
END;
/
COMMIT;
When new users require privileges, I just copy/paste LITTLEFOOT's data from the "Add privilege" procedure and change principal's name (currently, there are dozen of users in my script).

Sort by custom field (acf) date picker and publish date

I would like to sort posts using firstly the custom field date picker by ACF plugin for wordpress, and then when that's non existing, by the published date.
Our theme works with cases so I cooked up something like this but I failed misearbly, any suggestions ?
case 'concertdatum':
$wp_query_args['meta_query'] = array(
'relation' => 'AND',
'datum_clause' => array(
'meta_key' => 'datum',
'meta_type' => 'DATETIME'
),
'publish_clause' => array(
'column' => 'post_date_gmt',
'compare' => 'EXISTS',
),
)
$wp_query_args['order'] = array(
'datum_clause' => 'DESC',
'publish_clause' => 'DESC'
);
break;

Laravel 4 Database insert Error - preg_replace(): Parameter mismatch, pattern is a string while replacement is an array

In database seeder, I just want to insert some hard-coded data to the table.
$Pro1_id = DB::table('projects')->select('id')->where('projectName', '=', 'Project A')->get();
$data1_1 = array(
'id' => 1,
'projectID' => $Pro1_id,
'attributeID' => 1,
'levelID' => 2,
'percentage' => 20,
'risk_value' => 25186.86311,
'expectation_value' => 706455.9401,
);
$data1_2 = array(
'projectID' => $Pro1_id,
'attributeID' => 2,
'levelID' => 1,
'percentage' => 60,
'risk_value' => 530351.3397,
'expectation_value' => 392207.1248,
);
$data1 = [$data1_1, $data1_2];
DB::table('Mapping')->insert($data1);
However, I got the error:
[ErrorException] preg_replace(): Parameter mismatch, pattern is a
string while replacement is an array
It is so weird, because I did the same to another table, it worked.
DB::table('projects')->insert(array(
array(
'id' => Webpatser\Uuid\Uuid::generate(),
'projectName' => 'Project A',
'creator_id' => $pro1_creatorID,
'create_at' => \Carbon\Carbon::now()->toDateString(),
'lastEditor_id' => $pro1_creatorID,
'edit_at' => \Carbon\Carbon::now()->toDateString(),
'utility' => 1.597119661,
'exponential' => 4.94,
'projectValue' => 1225090.39
),
array(
'id' => Webpatser\Uuid\Uuid::generate(),
'projectName' => 'Project B',
'creator_id' => $pro2_creatorID,
'create_at' => \Carbon\Carbon::create(2014, 12, 12)->toDateString(),
'lastEditor_id' => $pro2_creatorID,
'edit_at' => \Carbon\Carbon::create(2014, 12, 12)->toDateString(),
'utility' => 1.754989409,
'exponential' => 5.78,
'projectValue' => 293760.36
),
array(
'id' => Webpatser\Uuid\Uuid::generate(),
'projectName' => 'Project C',
'creator_id' => $pro3_creatorID,
'create_at' => \Carbon\Carbon::create(2013, 10, 21)->toDateString(),
'lastEditor_id' => $pro3_creatorID,
'edit_at' => \Carbon\Carbon::create(2013, 10, 21)->toDateString(),
'utility' => 1.423114267,
'exponential' => 4.15,
'projectValue' => 1461924.67
)
)
);
I really don't understand why inserting into projects table works, but the one of the mapping table does NOT work.
They are exactly the same method.
I think your code is correct but when you insert the id in array, you are doing the wrong way.
$Pro1_id = DB::table('projects')->select('id')->where('projectName', '=', 'Project A')->get();
Here, $Pro1_id is Collection that contain value return from your query. Sometimes it might be one, but sometimes it might be 2 or 3.... So , your are doing the wrong way when you are inserting the id in the array. So , use foreach loop like this :
foreach($Pro1_id as $pro){
DB::table('Mapping')->insert(array(
'id' => 1,
'projectID' => $pro->id,
'attributeID' => 1,
'levelID' => 2,
'percentage' => 20,
'risk_value' => 25186.86311,
'expectation_value' => 706455.9401,
));
}
For simple , get returns Collection and is rather supposed to fetch multiple rows.
For more info . Check this

How do I send e-mails through Oracle DBMS_SCHEDULER?

I'm having difficulty sending email notifications through DBMS_SCHEDULER.
I've gone through instructions here on adding email notifications and here on configuring the mail server but I still don't get any e-mails sent. I'm using the same mail server settings on UTL_MAIL (to send mail using procedures) and Oracle Enterprise Manager (To get backup and availability email and they work fine.) I would rather not use UTL_MAIL instead as it doesn't offer the simplicity and flexibility I'm hoping to achieve with scheduler emails.
Below we have what server settings I've configured and how I'm trying to create a job that will send notifications.
/*Settings*/
exec dbms_scheduler.set_scheduler_attribute('email_server','xxx');
exec dbms_scheduler.set_scheduler_attribute('email_sender','Scheduler#domain.com');
/* Dont think this is needed but added anyway, this allows UTL_MAIL to work*/
alter system set smtp_out_server = 'xxx';
begin
dbms_network_acl_admin.create_acl (
acl => 'dbms_scheduler.xml',
description => 'Allow mail to be send',
principal => 'SCHEMA',
is_grant => TRUE,
privilege => 'connect'
);
commit;
end;
begin
dbms_network_acl_admin.add_privilege (
acl => 'dbms_scheduler.xml',
principal => 'SCHEMA',
is_grant => TRUE,
privilege => 'resolve'
);
commit;
end;
begin
dbms_network_acl_admin.assign_acl(
acl => 'dbms_scheduler.xml',
host => 'xxx'
);
commit;
end;
/*Create a quick, simple job*/
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => '"SCHEMA"."EMAIL_TEST"',
job_type => 'STORED_PROCEDURE',
job_action => 'SCHEMA.DO_MOD',
number_of_arguments => 0,
start_date => NULL,
repeat_interval => NULL,
end_date => NULL,
enabled => FALSE,
auto_drop => FALSE,
comments => '');
DBMS_SCHEDULER.SET_ATTRIBUTE(
name => '"SCHEMA"."EMAIL_TEST"',
attribute => 'restartable', value => TRUE);
DBMS_SCHEDULER.SET_ATTRIBUTE(
name => '"SCHEMA"."EMAIL_TEST"',
attribute => 'logging_level', value => DBMS_SCHEDULER.LOGGING_RUNS);
DBMS_SCHEDULER.SET_ATTRIBUTE(
name => '"SCHEMA"."EMAIL_TEST"',
attribute => 'raise_events', value => '511');
DBMS_SCHEDULER.ADD_JOB_EMAIL_NOTIFICATION (
job_name => '"SCHEMA"."EMAIL_TEST"',
recipients => 'user#xxx',
sender => 'oracle#xxx',
subject => 'Oracle Scheduler Job Notification - %job_owner%.%job_name%.%job_subname% %event_type%',
body => 'Job: %job_owner%.%job_name%.%job_subname%
Event: %event_type%
Date: %event_timestamp%
Log id: %log_id%
Job class: %job_class_name%
Run count: %run_count%
Failure count: %failure_count%
Retry count: %retry_count%
Error code: %error_code
%Error message: %error_message%',
events => 'job_started, job_broken, job_chain_stalled, job_completed, job_disabled, job_failed, job_over_max_dur, job_run_completed, job_sch_lim_reached, job_stopped, job_succeeded',
filter_condition => NULL
);
DBMS_SCHEDULER.enable(
name => '"SCHEMA"."EMAIL_TEST"');
END;
This code all completes successfully but I get no emails. I can also see the entries in user_scheduler_notifications but receive nothing.

How do I create a configurable product with associated products?

The following code does create a configurable product, however, when I open the product in the backend, the following message appears:
Select Configurable Attributes
"Only attributes with scope "Global", input type "Dropdown" and Use To Create Configurable Product "Yes" are available."
A single checkbox is displayed ("Colour Group"), which must be selected before continuing.
When I click "Continue", all of the product data is there as expected EXCEPT for the associated products.
//Mage Product
$mpr = Mage::getModel('catalog/product');
$mpr
->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE)
->setTaxClassId(5)
->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
->setWebsiteIds(array(1))
->setAttributeSetId(4) // You can determine this another way if you need to.
->setSku("C12345")
->setName("C12345")
->setQty(25)
->setShortDescription('short description')
->setDescription('description')
->setPrice(1)
->setStockData(array(
'use_config_manage_stock' => 1,
'is_in_stock' => 1,
'is_salable' => 1,
));
$productData = array(
'7039604' =>
array('0' => array('attribute_id' => '85', 'label' => 'ROYAL','value_index' => '28563', 'is_percent' => 0, 'pricing_value' => '')
,'1' => array('attribute_id' => '192', 'label' => '14', 'value_index' => '28728', 'is_percent' => 0, 'pricing_value' => '')
)
);
$attributeData = array(
'0' => array(
'id' => NULL
,'label' => 'Color'
,'position' => NULL
,'values' => array(
'0' => array('value_index' => 28563, 'label' => 'ROYAL', 'is_percent' => 0, 'pricing_value' => '0', 'attribute_id' => '85')
)
,'attribute_id' => 85
,'attribute_code' => 'color'
,'frontend_label' => 'Color'
,'html_id' => 'config_super_product__attribute_0')
,'1' => array(
'id' => NULL
,'label' => 'Rivers Size'
,'position' => NULL
,'values' => array(
'0' => array('value_index' => 28728, 'label' => '14', 'is_percent' => 0, 'pricing_value' => '0', 'attribute_id' => '192')
)
,'attribute_id' => 192
,'attribute_code' => 'rivers_size'
,'frontend_label' => 'Rivers Size'
,'html_id' => 'config_super_product__attribute_1')
);
$mpr->setConfigurableProductsData($productData);
$mpr->setConfigurableAttributesData($attributeData);
$mpr->setCanSaveConfigurableAttributes(true);
$mpr->save();
Add this code before $mpr->save();
$SKU = "any-simple product sku enter here";
$productid = Mage::getModel('catalog/product')
->getIdBySku(trim($SKU));
$mpr->assignProduct($productid);
And set simple product sku in $SKU variable. and i have check that when i select global variable then after i see associated product in configure product.
Its work fine !!!
If you are getting redirected to select attribute page, this means that attribute data you set in this sample is not saved correctly.
Try viewing catalog_product_super_attribute after script run (new rows should be added).

Resources