Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Invoice Editor 1.0


Recommended Posts

I have just installed Invoice Editor v1.0 (now at version 1.3) on my 2.3.3.4 test server.

 

http://addons.oscommerce.com/info/8885

 

Per the history page, there are:

 

 

1) the last full package dated Jan 26, 2014,

 

2) Admin Tool for Order Editor, dated Feb 9, 2014 and

 

3) a 2-file patch dated Feb 14, 2014

 

 

Per the instructions, I have installed all three, in that sequence. The full package included two sql updates:

 

 

* new_tables.sql

 

* invoice_en.sql

 

 

I have installed both of these. The 'new_tables.sql' created several new tables. All of the previous tables are utf8_unicode_ci, while these new tables are latin1_swedish_ci.

 

I assume that, since this add-on is/was from Germany, there was a need for non-English characters, which necessitated the different table types.

 

But, when I run the Security Check in the Admin section flags these, it states that these need to be converted to utf8.

 

1) Do these really need to be converted? What would happen if I don't convert these?

 

2) If I do need to convert these, what is the best procedure?

 

----------------------------------------------------------------------------------------------------------------

 

Near the end of the installation instructions, it states:

 

If you have installed the Order Editor you, you must do nothing - the code already exists!!!!

Wenn Sie den Order Editor installiert haben, überspringen Sie bitte den folgenden Punkt, da der Code dann bereits vorhanden ist!

 

Then, there is are 43 lines of code that are supposed to be added to/are already in: admin/includes/functions/general.php

 

Yet, these lines of code are *not* already in my general.php file. Do I still need to add this block of code?

 

----------------------------------------------------------------------------------------------------------------

 

Also, at the end of the installation instruction, it states:

 

Create a new folder under admin (e.g. admin/invoices) and set the permission to chmod 777 or at least 755. This folder is used to automatically store your PDF-Invoices using the invoice no as file name. To save invoices, set in the Admin -> Configuration -> Invoice Editor ' Save invoices?' to true, and in storage directory' enter the location of your folder: a directory admin/invoices you would have for example to enter as: invoices/ (WITH backslash).

 

However, neither the 'Save Invoices?' nor 'Storage Directory' are shown on my Admin -> Configuration -> Invoice Editor page.

 

The invoices *are* being saved, but in the admin/ directory, *not* the admin/invoices/ directory.

 

----------------------------------------------------------------------------------------------------------------

 

Per the instructions, I have copied the store logo into the admin/images directory, and have indicated the file name in Admin -> Configuration -> Invoice Editor. My store logo is larger than the 'stock' logo that comes with osCommerce.

 

In the HTML version of the Invoice, the large logo displays at the top of the page, and everything is beneath it.

 

In the PDF version of the Invoice, the store information (Store Name, Store Address, Store City) and the beginning of the customer's information (name, address, etc) are shifted up, and are superimposed upon the logo.

 

-----------------------------------------------------------------------------------------------------------------

 

(slightly related)

 

I have installed a Guest Checkout, and the standard procedure with osC is to send the customer an email upon completing an order, giving the customer a link back to the site, allowing them to check on the status of their order. Unfortunately, that link takes them to the Log-In page, asking them to log into their account with their user name and password. If they checked out as a guest, they won't have an account, a user name, nor a password.

 

So, is there a way to ask the customer, at Checkout_Success, if they want an invoice emailed to them, and give them a choice of a plain text, HTML, or PDF invoice?

 

Thanks.

 

Malcolm

Link to comment
Share on other sites

Hi,

 

As the author of the contrib I will try to answer your questions. Please excuse my limited knowledge of English - I hope I can make me understood anyway

 

1. I'm a little confused because there is no command line in the sql files to set the DB tables to latin1_swedish_ci, utf8 or whatever. :unsure: The tables should be installed with the same coding as all other tables of your DB. If your other tables are in utf8_unicode_ci you should convert the tables of the Invoice editor to utf8.

To do this is quite simple: Go to Admin -> Tools -> Database Tables - click the checkboxes of all tables that are not utf8 - select in the pulldown at the bottom of the page 'Convert to utf8' (a new pulldown appears, where you select 'Auto-Detect') - click the Go button. Ready!

 

2. What is not clear at this instruction? Do you have installed the tool named Order editor? (Order editor is a tool other than Invoice editor!) If yes, you do not need to add these lines of code to your general.php. If no, add them!

 

3. My mistake! :blush: In invoice_en.sql in some entries accidentally a false Configuration Group is entered. To fix it open your DB with phpmyadmin (or whatever you use to manipulate your DB), search ORDER_EDITOR_PAYMENT_DROPDOWN, ORDER_EDITOR_USE_SPPC, ORDER_EDITOR_CREDIT_CARD, INV_SAVE and SAVE_FOLDER and and change the entries for configuration_group_id from 911 to 912.

 

4. You must have a very BIG store logo. You're the first whose logo does not fit in the space provided. :P If you don't want to reduce the size of your logo, you can change the position of the address label. Open invoice_editor_pdf.php and invoice_pdf.php and find the following code:

// Adressfeld mit Absender und Rechnungsanschrift

$pdf->SetX(0);

$pdf->SetY(45); /// horizontal position address label

$pdf->SetFont('Arial','u',7);

$pdf->SetTextColor(0);

$pdf->Text(20,40, SHOPBETREIBER . ' • ' . SHOPSTRASSE . ' • ' . SHOPSTADT); ///horizontal position address headline

$pdf->SetFont('Arial','',10);

$pdf->SetTextColor(0);

$pdf->Cell(15);

$pdf->MultiCell(70, 4, $anrede . tep_address_format($order->billing['format_id'], $order->billing, '', '', "\n"),0,'L');

 

If you increase the values at the marked positions, the address label will slide down. You'll probably have to try a little bit to find the appropriate values ​​for you. If necessary, execute these changes also in the packingslip_editor_pdf.php and packingslip_pdf.php.

 

And last your "slightly related". If you have installed a guest checkout (Purchase without account - PWA??), the guest customer should not get at all a backlink to his - non-existent - order history. With PWA it's a simple piece of code added to the checkout_process.php:

 

if (!$order->customer['is_dummy_account']) {

$email_order .= EMAIL_TEXT_INVOICE_URL . ' ' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $insert_id, 'SSL', false) . "\n" ;

}

 

J.J.

Edited by De Dokta
Link to comment
Share on other sites

Thank you for your prompt reply!

 

1. I'm a little confused because there is no command line in the sql files to set the DB tables to latin1_swedish_ci, utf8 or whatever. :unsure: The tables should be installed with the same coding as all other tables of your DB. If your other tables are in utf8_unicode_ci you should convert the tables of the Invoice editor to utf8.

To do this is quite simple: Go to Admin -> Tools -> Database Tables - click the checkboxes of all tables that are not utf8 - select in the pulldown at the bottom of the page 'Convert to utf8' (a new pulldown appears, where you select 'Auto-Detect') - click the Go button. Ready!

 

I do not know how they were installed as latin1_swedish_ci either. Your conversion instructions were clear, and the conversion went smoothly.

 

2. What is not clear at this instruction? Do you have installed the tool named Order editor? (Order editor is a tool other than Invoice editor!) If yes, you do not need to add these lines of code to your general.php. If no, add them!

 

I confused Order Editor with Invoice Editor. My mistake.

 

3. My mistake! :blush: In invoice_en.sql in some entries accidentally a false Configuration Group is entered. To fix it open your DB with phpmyadmin (or whatever you use to manipulate your DB), search ORDER_EDITOR_PAYMENT_DROPDOWN, ORDER_EDITOR_USE_SPPC, ORDER_EDITOR_CREDIT_CARD, INV_SAVE and SAVE_FOLDER and and change the entries for configuration_group_id from 911 to 912.

 

That fixed it! Thanks.

 

4. You must have a very BIG store logo. You're the first whose logo does not fit in the space provided. :P

 

Yes, it is. I even had issues with it fitting onto the web site. :-

 

If you don't want to reduce the size of your logo, you can change the position of the address label. Open invoice_editor_pdf.php and invoice_pdf.php and find the following code:

// Adressfeld mit Absender und Rechnungsanschrift

$pdf->SetX(0);

$pdf->SetY(45); /// horizontal position address label

$pdf->SetFont('Arial','u',7);

$pdf->SetTextColor(0);

$pdf->Text(20,40, SHOPBETREIBER . ' • ' . SHOPSTRASSE . ' • ' . SHOPSTADT); ///horizontal position address headline

$pdf->SetFont('Arial','',10);

$pdf->SetTextColor(0);

$pdf->Cell(15);

$pdf->MultiCell(70, 4, $anrede . tep_address_format($order->billing['format_id'], $order->billing, '', '', "\n"),0,'L');

 

If you increase the values at the marked positions, the address label will slide down. You'll probably have to try a little bit to find the appropriate values ​​for you. If necessary, execute these changes also in the packingslip_editor_pdf.php and packingslip_pdf.php.

 

Thank you. I do need to make more changes to the invoice and the packing slip (both the HTML and PDF versions), so can you tell me what are the measurements used in positioning items in the PDF versions? Inches? Milimeters? Pixels?

 

And last your "slightly related". If you have installed a guest checkout (Purchase without account - PWA??), the guest customer should not get at all a backlink to his - non-existent - order history. With PWA it's a simple piece of code added to the checkout_process.php:

 

if (!$order->customer['is_dummy_account']) {

$email_order .= EMAIL_TEXT_INVOICE_URL . ' ' . tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $insert_id, 'SSL', false) . "\n" ;

}

 

I am actually building the site using Burt's bootstrap version of osC, so I went with Better Checkout

 

http://www.tostejensen.com/better-checkout.html

 

since they offer a version specifically taylored for this. I will contact them to see if these changes can be added.

 

Thank you for all of your assistance!

 

Malcolm

Link to comment
Share on other sites

Thank you. I do need to make more changes to the invoice and the packing slip (both the HTML and PDF versions), so can you tell me what are the measurements used in positioning items in the PDF versions? Inches? Milimeters? Pixels?

 

Hi,

 

Good question! I never ask for it. :blush: But according to the online manual fpdf - which I used for the pdf forms - is based on milimeters.

 

J.J.

Link to comment
Share on other sites

  • 5 months later...

@@De Dokta

 

In catalog/admin/edit_invoice.php, I think I found a bug ...

 

Around line 1085, you have ...

    <div id="popupPDFCheck" title="<?php echo 'PDF-Check'; ?>">
      <div id="popupContent"><?php include('invoice_editor/popup_pdf_check.php'); ?></div>
    </div>

I needed to add the path to the admin directory, changing it to this:

    <div id="popupPDFCheck" title="<?php echo 'PDF-Check'; ?>">
      <div id="popupContent"><?php include(DIR_WS_ADMIN . 'invoice_editor/popup_pdf_check.php'); ?></div>
    </div>

Can you please confirm this? Thanks!

 

Malcolm

Link to comment
Share on other sites

@@ArtcoInc

 

Also using 234bs I can't confirm that. If I change as proposed the code I get an error - while without this change the popup works without any problems.

Does this popup -  where you are asked to confirm overwriting an existing invoice - not work with you?

 

J.J.

Link to comment
Share on other sites

@@De Dokta

 

Prior to adding that, I was getting an error message at the bottom of the page saying that the program couldn't find that file. Adding the path fixed it.

 

Now, I just removed the path, and the error message is not showing up. And, the pop-up does indeed still pops up.

 

Strange ....  Thank you, though.

Link to comment
Share on other sites

  • 2 weeks later...

@@De Dokta

 

New challenge ... :)

 

I've just installed Purchase Without Account into my 234bs store, in which I already had installed Invoice Editor v1.3. Everything is working fine (phew!)

 

Now, I want to add a new feature ...

 

PWA adds a feature into catalog/admin/orders.php where it shows a check-mark when a customer places an order as a guest:

 

 

It does so by adding a new field "customers_guest" into the "orders" table, with a value of 1 if the customer is a guest, and a value of 0 if they are not. As you can see, this is working fine.

 

The code to display the check mark is:

<td class="dataTableContent" align="right">
  <?php echo $orders['customers_guest'] == '1' ? tep_image(DIR_WS_ICONS . 'tick.gif') : ''; ?>
</td>

Now, I am trying to add showing this value in the edit screen of orders.php:

 

 

 

The piece of code I am adding is here:

          <tr>
            <td class="main"><strong><?php echo ENTRY_PAYMENT_METHOD; ?></strong></td>
            <td class="main"><?php echo $order->info['payment_method']; ?></td>

            <tr>
              <td class="main"><strong><?php echo ORDER_ID; ?></strong></td>
              <td class="main"><?php echo $oID; ?></td>
            </tr>
            <tr>
              <td class="main"><strong><?php echo CUSTOMER_ID; ?></strong></td>
              <td class="main"><?php echo $order->customer['customers_id']; ?></td>
            </tr>

<!-- add to show if a customer is a guest -->

            <tr>
               <td class="main"><strong><?php echo GUEST; ?></strong></td>
               <td class="main"><?php echo $order->customer['customers_guest'] == '1' ? tep_image(DIR_WS_ICONS . 'tick.gif')

: ''; ?>
               </td>
            </tr>
<!-- end 'customer is a guest' -->


            <tr>
              <td class="main"><strong><?php echo INVOICE_NO; ?></strong></td>
              <td class="main">
                <?php echo ($order->info['num_invoice'] != '0') ? (ENTRY_INVOICE_ORDER_ID_PREFIX .

$order->info['num_invoice'] . ENTRY_INVOICE_ORDER_ID_SUFIX) : NO_NUMBER; ?>
              </td>

but, it is not working. I don't know where to find the 'customers_quest' field in the array. I have tried every value I can find in the rest of the code:

 

$order->info['customers_guest']

$order->customer['customers_guest']

$order->delivery['customers_guest']

$order->billing['customers_guest']

$order->products['customers_guest']

$order->total['customers_guest']

 

Any thoughts?

 

Thanks!

 

Malcolm

 

Link to comment
Share on other sites

@@ArtcoInc

 

I tried to keep it as simple as possible. For me it's enough to see in the order overview if a customer is a guest or not. :blush:

 

Ok, if you want/need this "tick" also on the single order site, open admin/includes/classes/order.php and to the $order_query (~line 27) after: customers_address_format_id add: , customers_guest.

Then search for: $this->customer = array('......................... and after:  'format_id' => $order['customers_address_format_id'],

add: 'customers_guest' => $order['customers_guest'],

 

Then <td class="main"><?php echo $order->customer['customers_guest'] == '1' ? tep_image(DIR_WS_ICONS . 'tick.gif'): ''; ?> will work. :rolleyes:

 

J.J.

Link to comment
Share on other sites

Since my store isn't that busy (yet), I typically click into the order from the dashboard. So, I never see the orders overview page.

 

That said, I tried this, but it's not working. I'll have to look at this again in the morning when I'm fresh.

 

Thank you!

 

Malcolm

Link to comment
Share on other sites

  • 2 months later...

@@De Dokta

 

I do believe that I was able to get the last issue resolved. I should have come back to thank you for that. I apologize.

 

Now, a new issue (I think). On my live site, I have received my first order for the year :)  When I go the print the invoice, I see that the invoice number has been reset to '1'. It had been incrementing properly all through last year.

 

I don't know if this is a feature in osC, or was added through your add-in. In either case, I would prefer that the invoice numbers continue in sequence, and not be reset the beginning of each year.

 

Happy New Year!

 

Malcolm

Link to comment
Share on other sites

@@ArtcoInc
 
Hi Malcolm
 

Yes, resetting the invoice number to 1 at the turn of the year is a function of the invoice Editor. As far as I know, there is no own invoice number function in osc
I prefer a new count for each year. If you prefer a continuous counting without reset, go to admin\includes\functions\invoice_num.php and replace the complete code by:

function tep_set_num($oID) {
    $invoice_query = tep_db_query("select orders_id, num_invoice from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");
    $mes = tep_db_fetch_array($invoice_query);

    if($mes['num_invoice'] == '0') {
    $num_invoice = '';
    $zahl_query = tep_db_query("select count(*) as number from " . TABLE_ORDERS ."");
    $zahl = tep_db_fetch_array($zahl_query);
    if($zahl['number'] == '0'){
    $num_invoice = '1';
    
    }else{
    $next_num_query = tep_db_query("select max(num_invoice) as num_invoice from " . TABLE_ORDERS ."");
    $next_num = tep_db_fetch_array($next_num_query);
    if(!isset($next_num['num_invoice'])){
    $num_invoice = 1;
    }else{
    $num_invoice = $next_num['num_invoice']+1;
    }
    }
    return tep_db_query("update " . TABLE_ORDERS . " set num_invoice = '". $num_invoice . "',      orders_date_finished = '" . $date . "' where orders_id = '" . (int)$oID . "'");

   }
}

That's all!

 

J.J.

Edited by De Dokta
Link to comment
Share on other sites

@@De Dokta

 

(just a quick follow-up question (or two))

 

I understand that the laws are different there in Germany than here in the USA, so if I may ask, what was the reason to reset the invoice number each year?

 

Also, is there a limit to the size of the invoice number? If I read things right, the num_invoice field in the orders table is type int(6) , which means that there is a limit of 999,999 invoices.

 

Also, when you display the invoice, your code says:  sprintf("%02u",$order->info['num_invoice']) . Does this limit the display to 2 characters? Or, just a minimum of two characters, with a leading 0 if needed?

 

Thanks again!

 

Malcolm

Link to comment
Share on other sites

@@ArtcoInc

 

Do you have more than 999999 invoices? :P Or do you expect any time soon to exceed this limit? Then you may change the num_invoice field from int(6) to int(7), 8, 10, 100 or whatever you want........

 

"%02u" adds a leading zero for single-digit numbers. I just think it looks better. :-

 

The German laws do not say that I must start the counting of invoices each year with 1 - they only say that every invoice number must be unique. But since I built the invoice editor for our shop and I think it is clear when I start every year again with the invoice number 1, I just decided to chose this way. Our invoice numbers consist of a prefix, the counter, the current month and the current year e.g. VS25/022014. In this way, I can assign each invoice at a glance a month and year! The mentioned invoice number for example tells me that it was the 25. invoice of the year 2014 and was created in February. And the prefix tells me that it was a sale in our online shop. -_-

 

J.J.

Link to comment
Share on other sites

@De Dokta

First a thank you for the add on ! 

I have installed it and everything works fine exept for one thing. 

When I click on 'Edit invoice' in my admin panel I get a blank page. (PHP error) I started checking all my files and file changes and everything seems to be in order. Allthough I think there is a fault in my generel.php file (attached). All the changes where made according to your manual. 

 

Do you have any idea what the problem could be? 

Another question I have, is if it would be possible to send the invoice automaticly to the customer when the purchase is done? 

 

Ben 

general.php

Link to comment
Share on other sites

Hi

 

Just checked your general.php in my testshop and could not reproduce your problem. So I would say your general.php is ok.

 

There are two buttons to open the invoice editor. One on the right column of your orders overview (orders.php), the other, when you open a single order. Does one of these buttons start the invoice editor?

If not, is the file admin/edit_invoice_process.php in place and did you register this file into your admin/includes/filenames.php?

 

Yes, it is in principle possible to send an invoice with the order confirmation - but not with this tool. I remember a discussion in the German forum how to create a pdf invoice on the fly and to attach it to the confirmation mail. There may be a similar discussion somewhere here in the forum.

I have not built such a function, because this is something problematic in Germany for accounting reasons. (We have a lot of rules and regulations here!  :x  )

 

J.J.

Link to comment
Share on other sites

@@benwijns
 

The only thing left to do now is to change the lay out of my pdf. How would you propose to do this? 
Is there a way to work with css?


No sorry, pdf files can not be styled using css. You must open the files e.g. invoice_editor_pdf.php and change it according to your needs. A lot of tips how to work with fpdf you can find here
 

Another questions, sorry !  :blush:
I have just noticed that my invoices are nog saving on to my server. 
Any idea?

Did you create a new folder to save your invoices e.g. admin/invoice? Did you set the permission of this folder to chmod 777 or at least 755? Did you set in Admin -> Configuration -> Invoice Editor ' Save invoices?' to true, and did you enter the location of your invoice folder in Admin -> Configuration -> Invoice Editor 'Storage directory' ?

 

J.J.

 

Edited by De Dokta
Link to comment
Share on other sites

@@De Dokta

 

Another questions, sorry !  :blush:

I have just noticed that my invoices are nog saving on to my server. 

Any idea? 

 

Ben 

 

 

@@benwijns

 

Did you create a new folder to save your invoices e.g. admin/invoice? Did you set the permission of this folder to chmod 777 or at least 755? Did you set in Admin -> Configuration -> Invoice Editor ' Save invoices?' to true, and did you enter the location of your invoice folder in Admin -> Configuration -> Invoice Editor 'Storage directory' ?

 

J.J.

 

It has been my experience that the PDF invoices are saved, as per the Dr's instructions above. But, the HTML invoices are not saved. Instead, they are created dynamically each time they are accessed.

 

Malcolm

 

Link to comment
Share on other sites

It has been my experience that the PDF invoices are saved, as per the Dr's instructions above. But, the HTML invoices are not saved. Instead, they are created dynamically each time they are accessed.

 

Malcolm

 

Thanks for the note! I forgot to mention that. :blush: :-

Link to comment
Share on other sites

@@De Dokta @@ArtcoInc

 

Thank you very much guys for the fast responses. 

I checked all my settings according to your tips and actually those are the things I all ready had checked a few times. Everything seems to be in order. 

However after some more research I actually found another problem. I can't attach invoices. When I check the box and press update, no changes are made. 

I think both problems come forth from the same bug. Is that possible? 

 

Thanks again for the effort, guys. 

 

Ben 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...