Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Invoice date


Guest

Recommended Posts

I was questioning myself about months replacement with translation for my language, displayed in INVOICE what is sent to client and on admin site printing invoice.

 

Can this be possible to do this

 

now i get MAR 03 2010

 

the goal is Marts 03 2010

 

 

Translations:

 

March - english

 

Marts - Latvian (i have some special characters in some months)

 

i was thinking something about this:

 

define('MONTHS_LONG_ARRAY',Janvāris,Februāris,Marts,Aprīlis,Maijs,Jūnijs,Jūlijs,Augusts,Septembris,Oktobris,Nnovembris,Decembris');

 

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

EDIT:

 

or

 

define('MONTH_JAN', 'Janvāris);

define('MONTH_FEB', 'Februāris);

etc...

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

 

Is this possible?

Link to comment
Share on other sites

I was messing around with PHP

 

and here is what i have got, but i think it`s can be made a bit more easy!

 

<?php
if ($date == "Jan".date(" d, Y"))

{
	echo "Janvāris".date(" d, Y");
}

elseif ($date == "Feb".date(" d, Y"))
{
	echo "Februāris".date(" d, Y");
}

elseif ($date == "Mar".date(" d, Y"))
{
	echo "Marts".date(" d, Y");
}

elseif ($date == "Apr".date(" d, Y"))
{
	echo "Aprīlis".date(" d, Y");
}

else
{
	echo "ERROR";
}
?>

 

p.s. code is not complete for 12 months but only for 4

 

This i will add in cataloge/print_my_invoice.php | cataloge/admin/invoice.php | cataloge/admin/packingslip.php etc.

 

Can some one help make it not so complicated?

Link to comment
Share on other sites

I was messing around with PHP

 

and here is what i have got, but i think it`s can be made a bit more easy!

 

 

 

p.s. code is not complete for 12 months but only for 4

 

This i will add in cataloge/print_my_invoice.php | cataloge/admin/invoice.php | cataloge/admin/packingslip.php etc.

 

Can some one help make it not so complicated?

Look up the CASE statement in a php manual.

Community Bootstrap Edition, Edge

 

Avoid the most asked question. See How to Secure My Site and How do I...?

Link to comment
Share on other sites

This thread has some useful code in it.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

This thread has some useful code in it.

 

 

I think this dose not the job, not so easy!

 

I have tryed this out. but with no success... :(

 

 

Need to stuck with if and ifelse

 

 

The case statement i don`t really get work, i think it will take some time form me to learn it! wish me luck and any help is accepted! :)

Link to comment
Share on other sites

Got this with statement CASE

 

if ($date == $men.date(" d, Y")){

$men = date("M");

switch ($men) {

  case "Jan" :
  echo "Janvāris";
  break;

  case "Feb" :
  echo "Februāris";
  break;

  case "Mar" :
  echo "Marts";
  break;

  default :
  echo "ERROR";
  break;

  }
}

 

i can`t get it right to make work with array statement replace..

Link to comment
Share on other sites

Do you have somewhere a non-default date format of M d Y? If that's what you're using, it sounds like your server is configured for English, not Latvian. If the server is in another country, you may just have to live with that. So, for a specific date string $date with "Mar 04, 2010" ("M d, Y" format), you want to spell out the full month in Latvian? No problem. Wherever you have a date that includes the 3-letter English abbreviation for the month, in variable $date (say), add:

$date = replaceMon($date);

Add the following function, making sure that it is available to all pages that need it (perhaps add it to application_top.php?):

function replaceMon($Date) {
 // replace English 3 letter month abbreviation with full Latvian month name
 switch(substr($Date(0,3)) {
   case 'Jan': $Date = "Janvāris" . substr($Date,3); break;
   case 'Feb': $Date = "Februāris". substr($Date,3); break;
   case 'Mar': $Date = "Marts". substr($Date,3); break;
    ... etc. ...
 }
 return $Date;
}

I think that should work OK, even if you're working in UTF-8.

Link to comment
Share on other sites

$date = replaceMon($date);

Add the following function, making sure that it is available to all pages that need it (perhaps add it to application_top.php?):

function replaceMon($Date) {
 // replace English 3 letter month abbreviation with full Latvian month name
 switch(substr($Date(0,3)) {
   case 'Jan': $Date = "Janvāris" . substr($Date,3); break;
   case 'Feb': $Date = "Februāris". substr($Date,3); break;
   case 'Mar': $Date = "Marts". substr($Date,3); break;
 }
 return $Date;
}

 

 

This code makes error with { at the beginig, i`ll will try to fix this...

 

i`m open for more solutions!

Link to comment
Share on other sites

Oops, my bad.

switch(substr($Date(0,3))) {

Add missing ).

 

 

I get this error:

 

Fatal error: Call to undefined function Mar 04, 2010() in /var/www/testshop/includes/application_top.php on line 237

Link to comment
Share on other sites

Arrrrrgh! That's what happens when I rush.

switch(substr($Date,0,3)) {

Only 8,192 permutations to go...

 

This work great!

 

But if i what to change the date from: date("M d, Y") to date("d M Y")

 

a assume i need to change the code for date transform?

 

 

Can i take a look somewhere the meaning of date ordering for function substr($Date,0,3)

Link to comment
Share on other sites

This work great!

Phew! I was wondering how long it would take for me to get it!

 

But if i what to change the date from: date("M d, Y") to date("d M Y")

 

a assume i need to change the code for date transform?

If your date format is 04 Mar 2010, it gets a little bit more complicated:

switch(substr($Date,3,3)) {
   case 'Jan': $Date = substr($Date,0,3) . "Janvāris" . substr($Date,7); break;
    ...

 

Can i take a look somewhere the meaning of date ordering for function substr($Date,0,3)

substr = substring function, extract some portion of $Date string

0 = starting index (first character)

3 = length (characters) (if not given, extract all the way to the end of the string)

Mar 04, 2010
0   4   8    substr($Date,0,3) = "Mar", substr($Date,3) = " 04, 2010"

04 Mar 2010
0  3   7     substr($Date,3,3) = "Mar", substr($Date,0,3) = "04 ", substr($Date,7) = "2010"

http://us2.php.net/manual/en/function.date.php

http://us2.php.net/manual/en/function.substr.php

Link to comment
Share on other sites

Phew! I was wondering how long it would take for me to get it!

 

 

If your date format is 04 Mar 2010, it gets a little bit more complicated:

switch(substr($Date,3,3)) {
   case 'Jan': $Date = substr($Date,0,3) . "Janvāris" . substr($Date,7); break;
    ...

 

 

substr = substring function, extract some portion of $Date string

0 = starting index (first character)

3 = length (characters) (if not given, extract all the way to the end of the string)

Mar 04, 2010
0   4   8    substr($Date,0,3) = "Mar", substr($Date,3) = " 04, 2010"

04 Mar 2010
0  3   7     substr($Date,3,3) = "Mar", substr($Date,0,3) = "04 ", substr($Date,7) = "2010"

http://us2.php.net/manual/en/function.date.php

http://us2.php.net/manual/en/function.substr.php

 

Thank you a lot!

This is great!

Link to comment
Share on other sites

Thank you a lot!

This is great!

 

 

EDIT: Deleted the post

 

I need get some sleep, i was putting the files in wrong test shop!

 

DUMB me :D

Link to comment
Share on other sites

  $months = array('Janvaris', 'Februaris', 'Marts', 'Aprilis', 'Maijs', 'Junijs', 'Julijs', 'Augusts', 'Septembris', 'Oktobris', 'Novembris', 'Decembris');
 $date =  strftime('%d '.substr( $months[strftime('%m')-1], 0, 3).' %Y'); // use this for day month year format
 $date =  strftime(substr( $months[strftime('%m')-1], 0, 3) . ' %d %Y'); // use this for month day year format

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

  $months = array('Janvaris', 'Februaris', 'Marts', 'Aprilis', 'Maijs', 'Junijs', 'Julijs', 'Augusts', 'Septembris', 'Oktobris', 'Novembris', 'Decembris');
 $date =  strftime('%d '.substr( $months[strftime('%m')-1], 0, 3).' %Y'); // use this for day month year format
 $date =  strftime(substr( $months[strftime('%m')-1], 0, 3) . ' %d %Y'); // use this for month day year format

 

Thank you!

 

but i think here i need to make some coreections:

 

$months = array('Janvaris', 'Februaris', 'Marts123456789asdfg', 'Aprilis', 'Maijs', 'Junijs', 'Julijs', 'Augusts', 'Septembris', 'Oktobris', 'Novembris', 'Decembris');
 $date2 =  strftime('%d '.substr( $months[strftime('%m')-1], 0).' %Y'); // use this for day month year format
 $date2 =  strftime(substr( $months[strftime('%m')-1], 0) . ' %d %Y'); // use this for month day year format

 

I have replaced - > $months[strftime('%m')-1], 0, 3).' %Y');

with -> $months[strftime('%m')-1], 0).' %Y');

 

Because the word length was limited to 3 simbols!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...