Page Break not working in PDF

(18 posts) (2 voices)

Tags:

  1. vsivaprabu, Member

    Hi Mydbr Team,

    I have try the page break per record in PDF using following code but its not working an also I have update MYdbr version also. But I didn't get any improvement. Cloud you please help for me.

    CREATE PROCEDURE sp_DBR_Delivery_Tickets(vCompanyid int,StartDate date,EndDate date,Salesperson text,StoreLocation int,pagedisplay int)
    BEGIN

    SELECT 'dbr.template', '#invoice';
    select 'dbr.export.options', 'pagebreak', 1;
    select 'dbr.css', '.page-break.page {page-break-before:always} .page-break.page1 {page-break-before:auto}}';
    select 'dbr.resultclass', 'page-break';
    select 'dbr.wkhtmltopdf', "--header-html ''"; /* Do not use header in export using wkhtmltopdf */
    select 'dbr.export.options', 'autosize', 0; /* Turn off autosize */

    ################## Query ##########

    select 'dbr.purehtml', '<script type="text/javascript">$(document).ready(function() {
    var variable = $(".nsl").parent().css( "display", "none" );
    $(".separator" ).each(function( index ) {
    var str = $(this).text();
    str = str.replace(/####/g," ");
    $(this).html(str);
    });
    });</script>';
    select 'dbr.purehtml', '<style>
    @media print
    {
    hr {page-break-after:always;}
    }
    </style>';

    END

    Thanks,
    Sivanesan.V

  2. myDBR Team, Key Master

    Without actually seeing the full query it is bit hard to say, but you've got two definitions for page break.

    First one is defined for page-break.page css style which seems to be defined via the dbr.resultclass command. Please note that as you are using your own template, the dbr.resultclass command is not applied to template (you can add the page-break class in the template directly.

    The second page break is defined under print media type. Please note that you have to tell wkhtmltopdf to use print media type (--print-media-type), by default wkhtmltopdf uses screen media type.

    Btw, you do not need to use "select 'dbr.purehtml', '<script type="text/javascript">$(document).ready(function() {...});</script>". Just using "select 'dbr.javascript", '...', 'onload' is the same thing.

    Also, instead of using "select 'dbr.purehtml', '<style>...</style>';", you can use "select 'dbr.css'".

    --
    myDBR Team

  3. vsivaprabu, Member

    Hi,

    How to export pdf with page break based every salesperson

    my coding

    SELECT 'dbr.HDR', 'salesperson';
    SELECT 'dbr.sum', 'Cost';
    SELECT 'dbr.sum', 'Gross Profit';
    SELECT 'dbr.sum', 'Margin';
    SELECT 'dbr.sum', 'Comm Dollars';
    SELECT 'dbr.sum', 'Comm Rate';

    select 'dbr.HDR.options', 'pagebreak', 1;
    select 'dbr.css', '.page-break.page {page-break-before:always} .page-break.page1 {page-break-before:auto}}';

    Please help for this

  4. myDBR Team, Key Master

    Use a cursor to separate each salesperson to his/her own result set so you add pagebreak after each set. The explicit pagebreak command is:

    select 'dbr.export.options', 'pagebreak', 1;

    --
    myDBR Team

  5. vsivaprabu, Member

    Hi mydbr Team,

    The page break is working fine but when I export the PDF the last page getting blank. How to avoid this. Could you please let me know.

    Thanks,
    Sivanesan.V

  6. myDBR Team, Key Master

    Please open a support ticket (support email) with report output with '&export=sql' added to the URL. This way we can reproduce the report.

    --
    myDBR Team

  7. vsivaprabu, Member

    Dear Mydbr Team,

    Thanks for reply. I will raise the support ticket.

    I have another doubt how can I use the SSO extra parameter in Parameter queries. Could you please help for this.

    Thanks & Regards,
    Sivanesan.V

  8. myDBR Team, Key Master

    I have another doubt how can I use the SSO extra parameter in Parameter queries. Could you please help for this.

    Single Sign-On extra parameters allow for you to pass addditional fields to myDBR (in addition to username, name, telephone etc). For example you can return CompanyID / DepartmentID for the user and use that as an automatic parameter so you do not need to fetch this through username.

    In order to use the SSO extra parameter, you need to tell myDBR what you wish the call the extra parameter for as an automatic parameter. The parameters are named extra1, extra2, ... in SSO protocol, and you can name them as you like inside myDBR.

    If you want to call extra1 as in_SSO_OrganizationID in myDBR, you will add definition

    $mydbr_defaults['automatic_parameters']['sso_extra1'] = 'in_SSO_OrganizationID';

    to mydbr/user/defaults.php. After this in_SSO_OrganizationID when used as a parameter, will function as any other automatic parameter.

    --
    myDBR Team

  9. vsivaprabu, Member

    Thanks for quick reply

    I have added the following line in SSO login page

    $hash = sha1( $user . $name . $groups . $email . $telephone . $admin . $extra1 . $token . $secret );

    Also I have added following line in mydbr/user/defaults.ph

    $mydbr_defaults['automatic_parameters']['sso_extra1'] = 'in_SSO_OrganizationID';

    Now I create the new procedure like this I getting error

    CREATE PROCEDURE sp_Daily_Sold_Report(in_SSO_OrganizationID int,SoldDate text)
    BEGIN
    SELECT * FROM mappingdetails WHERE map_id = in_SSO_OrganizationID;
    END

    Please help for this.

    Thanks,
    Sivanesan

  10. myDBR Team, Key Master

    Now I create the new procedure like this I getting error

    What is the error you see?

    --
    myDBR Team

  11. vsivaprabu, Member

    Thanks for your reply

    I am getting following error

    The page isn't redirecting properly

    Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

    This problem can sometimes be caused by disabling or refusing to accept cookies.

    I have used following i frame used to load the report

    <iframe id="iframeId" src="https://www.mysite.com/mydbr/report.php?r=4&u1=<?php echo $_SESSION['user_id'];?>&m=1&h=43443345vsdfsd3453435&i=1"
    width="100%" height="500px"></iframe>

  12. myDBR Team, Key Master

    When a extra parameter is added to the Single Sign-On protocol, it becomes an automatic parameter. if yiou add it as a OrganizationID, you do not need to pass UserID or OrganizationID into your report. myDBR will take care all of that automatically for you. if a report contains, as in your case in_SSO_OrganizationID parameter, it will be filled in automatically in the server.

    As for your report then. You should first test that your SSO configuration works (leave out the iframe so you can see what happens). In your example, your report has two parameters in_SSO_OrganizationID and SoldDate. As in_SSO_OrganizationID is an automatic parameter you do not need to pass the parameter to it. The SoldDate is the second parameter and if you pass a parameter to it yourself, it will be either 'u2' (if you want user to be able to change it) or 'p2' (if it will be protected). In your IFARME call you are passing variable to 'u1' which would be the in_SSO_OrganizationID.

    To go forward:

    1) Test that your SSO impelemtation works
    2) Test that in_SSO_OrganizationID is handled correctly by simply defining a report with in_SSO_OrganizationID as a parameter. if the parameter contains correct value, you are ok
    3) Use the reports in IFRAME

    --
    myDBR Team

  13. vsivaprabu, Member

    Thanks for your reply

    I have test SSO login its working with following

    $hash = sha1( $user . $name . $groups . $email . $telephone . $admin . $extra1 . $token . $secret );

    Also I have added following line in mydbr/user/defaults.php

    $mydbr_defaults['automatic_parameters']['sso_extra1'] = 'in_SSO_OrganizationID';

    1 ) SSO Login is working fine
    2 ) next I create the new report

    CREATE PROCEDURE sp_DBR_test_automatic_parameter()
    BEGIN

    SELECT in_SSO_OrganizationID;

    END
    $$

    Then I run the report I getting following error

    Could not execute the report. There was an error in the report.
    Unknown column 'in_SSO_OrganizationID' in 'field list'

    Please clarify. Could you please send the example that would helpful for me.

    Thanks lot for your reply

  14. myDBR Team, Key Master

    In order to use a parameter in a procedure, you need to declare it as a parameter. Your procedure is missing the parameter declaration and therefore MySQL is unable to recognize it.

    --
    myDBR Team

  15. vsivaprabu, Member

    Thanks for your reply please help me for my last request. I have created the procedure like but I am getting empty result.

    CREATE PROCEDURE sp_DBR_test_automatic_parameter(in_SSO_OrganizationID INT)
    BEGIN

    SELECT in_SSO_OrganizationID;

    END

    Following code use to connect the SSO please check am in correct. When use this code but user not created the mydbr. If I wrong please let em know

    $f_do_autologin = false;
    if (isset($_REQUEST['token'])) {
    $token = $_REQUEST['token'];
    $url = $_REQUEST['url'];
    } elseif(!$_REQUEST['hash']) {
    $token = '';
    $url = 'https://www.mysite.com/reports_extra';
    $f_do_autologin = true;
    }

    $user_id = "-1";
    if (isset($_SESSION['user_id'])) {
    $user_id = (get_magic_quotes_gpc()) ? $_SESSION['user_id'] : addslashes($_SESSION['user_id']);
    }

    $query_rsDataSet = sprintf("SELECT id,name,email FROM tbl_users WHERE id = %s", GetSQLValueString($user_id, "int"));
    $rsDataSet = mysql_query($query_rsDataSet, $connDB) or die(mysql_error());
    $row_rsDataSet = mysql_fetch_assoc($rsDataSet);
    $totalRows_rsDataSet = mysql_num_rows($rsDataSet);

    $u = str_replace(" ","_",$row_rsDataSet['name'])."_".$row_rsDataSet['id'];
    $user = $u;
    $name = $u;
    $groups = "Sale";
    $email = $row_rsDataSet['email'];
    $telephone = '+358 123 2345' ;
    $admin = '0';
    $extra1 = isset($_SESSION['user_id'])? $_SESSION['user_id'] : 1;
    $secret = 'ssssssssssssssssssfdgdfgdf';
    if (( $token != "" || $f_do_autologin ) )
    {
    if ($f_do_autologin) {

    }
    // User's email is optional
    if (isset($_REQUEST['noemailchange'])) {
    $email = '';
    }
    else {
    // User's email can be erased by setting blank email address
    $email = isset($_REQUEST['email']) ? $_REQUEST['email'] : '' ;
    }
    // User's telephone is optional
    if (isset($_REQUEST['notelephonechange'])) {
    $email = '';
    }
    else {
    // User's telephone can be erased by setting blank telephone address
    $email = isset($_REQUEST['telephone']) ? $_REQUEST['telephone'] : '' ;
    }
    // Group is optional
    if (isset($_REQUEST['nogroupchange'])) {
    $groups = '';
    }

    $hash = sha1( $user . $name . $groups . $email . $telephone . $admin . $extra1 . $token . $secret );

    $url .= '?user=' . urlencode($user) . '&name=' . urlencode($name) . '&hash=' . $hash;

    if (!isset($_REQUEST['nogroupchange'])) {
    $url .= '&groups=' . urlencode($groups);
    }

    if (!isset($_REQUEST['noemailchange'])) {
    $url .= '&email=' . urlencode($email);
    }

    if (!isset($_REQUEST['notelephonechange'])) {
    $url .= '&telephone=' . urlencode($telephone);
    }

    $url .= '&admin=' . $admin;
    header('Location:' . $url);
    die;
    }

    Thanks lot your help

  16. myDBR Team, Key Master

    Vsivaprabu,
    You are not passing the extra1 as an URL parameter, but you are using it in the hash. This will cause the hash verification to fail when myDBR checks the login URL coming to it. myDBR then rejects the login and redirects user back to your SSO code, hence the loop.

    As you are not using a form to gather the login data, but use database query instead, you can remove all $_REQUEST test from "if (( $token != "" || $f_do_autologin ) )" onwards. Just make sure you add to URL all the parameters you are using in yhe hash calculation.

    --
    myDBR Team

  17. vsivaprabu, Member

    After the two days struggle I have implemented SSO. Thanks for your help.

    Its my last request after SSO login its redirect to http://mysite.com/mydbr/index.php. I want to redirect my website(http://mysite.com/index.php) how can i do this.

    Thanks lot for your help.

    Thanks,
    Siva

  18. myDBR Team, Key Master

    Siva,
    The SSO redirect is automatic. When you access myDBR when you are not logged in, myDBR redirects you to your SSO implementation with the URL of it's location as a parameter. Your SSO implementation then uses this information to redirect user back to myDBR.

    Check the 'url' parameter from thr request coming from myDBR.

    Please note that you do not access the SSO code directly as an user, you always access myDBR which then calls your SSO code if user is not logged in.

    --
    myDBR Team


Reply

You must log in to post.