Hello, I have problem with my last modification. In each order I need special field with number of invoice. But this field is another than order ID. Because I don“t need field with IP I made this field editable. Now I can edit this field and write a special number.
But I would like to check, that this number is unique, because each invoice must be with specifi number.
It depends what pattern do you want to use for invoice numbering. Generally you can create an invoice number when client sends the order, by adding aForm['iInvoice'] with the same method as the aForm['iOrder'] in addOrder function in core\orders.php and adding variable iInvoice in db/orders.def.php
@deha, this method is good (i use it by myself) only in a country with normal (not stupid) financial officers. there is no problem then (in such countries) when you cancel an order and have a gap between invoice numbers.
the solution to consider could be (i have it already in my head :-) ) : by opening the order a small funtion (like throwLastId) creates a new invioce number (if not already exists) and gives it to dokument into a js variable. a small button (only if wished) "invoice" put it into a field and by saving the order the invoice number will be saved (if in field of course) into own (DB_INVOICES) database [iInvoice, iOrder]. this "throwLastId" function will of course use the DB_INVOICE. in this case you will have separate invoice numbers not necessery coresponding to order numbers. the pattern of the invoice number is a secondary "five minutes" problem :-)