hungryfrank Posted January 20, 2020 Share Posted January 20, 2020 hello I have this code that I want to add for create_account.php. it dose not work when I add it to the header or footer with hooks. it dose get added but it dose not work. it only works between include(template_buttom) and include(application_buttom). it works in the admin section but not in the shop section <script> $(function() { //$.calendarsPicker.setDefaults({renderer: $.calendarsPicker.themeRollerRenderer}); var calendar = $.calendars.instance("<?php echo CALENDER_TYPE; ?>"); // $("#products_date_available").calendarsPicker({calendar: $.calendars.instance("<?php echo CALENDER_TYPE; ?>", "<?php echo CALENDER_LANGUAGE; ?>")}); $("#inlineDatepicker").calendarsPicker({calendar: $.calendars.instance("<?php echo CALENDER_TYPE; ?>", "<?php echo CALENDER_LANGUAGE; ?>"), onSelect: showDate}); $("#expdate").calendarsPicker({calendar: $.calendars.instance("<?php echo CALENDER_TYPE; ?>", "<?php echo CALENDER_LANGUAGE; ?>")}); $("#dob").calendarsPicker({calendar: $.calendars.instance("<?php echo CALENDER_TYPE; ?>", "<?php echo CALENDER_LANGUAGE; ?>")}); $("#inlineDatepicker2").calendarsPicker({calendar: $.calendars.instance("<?php echo CALENDER_TYPE; ?>", "<?php echo CALENDER_LANGUAGE; ?>"), onSelect: showDate}); $("#popupDatepicker").calendarsPicker({calendar: $.calendars.instance("<?php echo CALENDER_TYPE; ?>", "<?php echo CALENDER_LANGUAGE; ?>")}); }); function showDate(date) { alert("The date chosen is " + date); } </script> you can cut up to 4 pages of your checkout by using my three add_ons login create account in one page Express checkout login pop up modal Link to comment Share on other sites More sharing options...
♥ecartz Posted January 20, 2020 Share Posted January 20, 2020 Please post your hook code. You can't embed PHP tags in a string. So you'd have to do something like ob_start(); ?> <script> $(function() { //$.calendarsPicker.setDefaults({renderer: $.calendarsPicker.themeRollerRenderer}); var calendar = $.calendars.instance("<?php echo CALENDER_TYPE; ?>"); // $("#products_date_available").calendarsPicker({calendar: $.calendars.instance("<?php echo CALENDER_TYPE; ?>", "<?php echo CALENDER_LANGUAGE; ?>")}); $("#inlineDatepicker").calendarsPicker({calendar: $.calendars.instance("<?php echo CALENDER_TYPE; ?>", "<?php echo CALENDER_LANGUAGE; ?>"), onSelect: showDate}); $("#expdate").calendarsPicker({calendar: $.calendars.instance("<?php echo CALENDER_TYPE; ?>", "<?php echo CALENDER_LANGUAGE; ?>")}); $("#dob").calendarsPicker({calendar: $.calendars.instance("<?php echo CALENDER_TYPE; ?>", "<?php echo CALENDER_LANGUAGE; ?>")}); $("#inlineDatepicker2").calendarsPicker({calendar: $.calendars.instance("<?php echo CALENDER_TYPE; ?>", "<?php echo CALENDER_LANGUAGE; ?>"), onSelect: showDate}); $("#popupDatepicker").calendarsPicker({calendar: $.calendars.instance("<?php echo CALENDER_TYPE; ?>", "<?php echo CALENDER_LANGUAGE; ?>")}); }); function showDate(date) { alert("The date chosen is " + date); } </script> <?php return ob_get_clean(); Always back up before making changes. Link to comment Share on other sites More sharing options...
hungryfrank Posted January 21, 2020 Author Share Posted January 21, 2020 you put me in the right direction.i fixed it and it works now. thanks a mil maybe u can help me with something else. now I have to update the dob in customers table after it is created in the create_accout.php short of changing the file manually can you point me in the right direction on what to use. you can cut up to 4 pages of your checkout by using my three add_ons login create account in one page Express checkout login pop up modal Link to comment Share on other sites More sharing options...
♥ecartz Posted January 21, 2020 Share Posted January 21, 2020 For just one customer? You can edit date of birth in admin > Customers I believe. If you mean that you want to change the value that the datepicker gives, you might find it easier to wait until I release my customer data changes. That would allow you to write your own date of birth (dob) module. Right now, the thing to do would be to do an injectFormVerify siteWide hook where you change $GLOBALS['dob']. Note that tep_date_raw will run after that so you need to be careful of how you set it. Always back up before making changes. Link to comment Share on other sites More sharing options...
hungryfrank Posted January 21, 2020 Author Share Posted January 21, 2020 I am trying to have a Datepicker that supports different calendars. ie Hebrew calendar. the Datepicker will enter the dob in the format and values of the involve calendar. I need to update it to store the date in the current format. translate the date. I can easily do it with hardcoding. later I would need to change the functions that deals with displaying date. everything works with going in the files and changing it.so its worth to spend some time. and ultimately customer should be able to pick his calendar or if possible get this info from browser. you can cut up to 4 pages of your checkout by using my three add_ons login create account in one page Express checkout login pop up modal Link to comment Share on other sites More sharing options...
♥ecartz Posted January 21, 2020 Share Posted January 21, 2020 The tep_date_raw function is supposed to be defined per language to convert the date picker date format to the YYYYMMDD format used for storage. You might have the date picker write to the correct format for the language. So pass the language format to the date picker. Then it returns the result in the correct format for the language. Or if you're using the same date picker everywhere, perhaps just make tep_date_raw return the input so that the date picker can return in YYYYMMDD format. Always back up before making changes. Link to comment Share on other sites More sharing options...
hungryfrank Posted January 21, 2020 Author Share Posted January 21, 2020 I am not talking only the format. and languages. there are different calendars in the world that everything is different. it is not 21st century and year dosent start at the same day. in ME Southeast Asia there are a lot of world calenders http://keith-wood.name/calendars.html. there are translator classes for each calendar. then the functions for date have to compensate.for this change to display date in local calendar. and Datepicker input has to be translated. all in language file now with the exception of the three date function you can cut up to 4 pages of your checkout by using my three add_ons login create account in one page Express checkout login pop up modal Link to comment Share on other sites More sharing options...
♥ecartz Posted January 22, 2020 Share Posted January 22, 2020 The way that the system is designed, you input in any date format and store in the Gregorian date in YYYYMMDD format. The tep_date_raw converts from the date picker's format to YYYYMMDD. The tep_date_raw is defined once per language. If you are going to be using multiple date pickers for the same language, the easiest thing from the osCommerce perspective would be to have the date picker return the date in the format that tep_date_raw expects. The next easiest would be to have the date picker return the date in YYYYMMDD format and require the date picker to be used everywhere so that tep_date_raw can just return YYYYMMDD input as YYYYMMDD output. The most complicated would be to create an injectFormVerify siteWide hook that converts $GLOBALS['dob'] from whatever format the date picker returns into whatever format tep_date_raw expects in that language. Note that if you have multiple date pickers per language, the last would require a format that selects the right adjustment for the date picker. If you are thinking of storing the date as something other than the Gregorian date in YYYYMMDD format, I'd advise against it. Because then you would have to read the date in the native format. Or convert it later. Which of course is going to be as difficult as converting it first with the added challenge of not being able to compare it with other dates at the storage level. I note that your link suggests that with the plus module, any date picker can translate to yyyymmdd format. So that would probably be the simplest approach. Just make tep_date_raw a passthrough and let the calendar worry about it. Always back up before making changes. Link to comment Share on other sites More sharing options...
hungryfrank Posted January 22, 2020 Author Share Posted January 22, 2020 I was thinking in the line that the db has to stay as it is. all dates have to be stored as Gregorian yyyymmdd. I will put two new funnctions in the language file like English.php function translate_to_gregorian($raw_date) { if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return false; $my_date= $raw_date; return $my_date; } function translate_from_gregorian($raw_date) { if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return false; $my_date= $raw_date; return $my_date; } in the other languages you actually you will have $my_date=somefunction($raw_date) and I will have have to change the function like this function tep_date_short($raw_date) { if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return false; $raw_date = translate_from_gregorian($raw_date); $year = substr($raw_date, 0, 4); $month = (int)substr($raw_date, 5, 2); $day = (int)substr($raw_date, 8, 2); $hour = (int)substr($raw_date, 11, 2); $minute = (int)substr($raw_date, 14, 2); $second = (int)substr($raw_date, 17, 2); if (@date('Y', mktime($hour, $minute, $second, $month, $day, $year)) == $year) { return date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, $year)); } else { return preg_replace('/2037$/', $year, date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, 2037))); } } here I will give the functions a translated year month and day values and let the oscommerce take over for formatting. you can cut up to 4 pages of your checkout by using my three add_ons login create account in one page Express checkout login pop up modal Link to comment Share on other sites More sharing options...
hungryfrank Posted January 22, 2020 Author Share Posted January 22, 2020 function tep_datetime_short($raw_datetime) { if ( ($raw_datetime == '0000-00-00 00:00:00') || ($raw_datetime == '') ) return false; $hour = (int)substr($raw_datetime, 11, 2); $minute = (int)substr($raw_datetime, 14, 2); $second = (int)substr($raw_datetime, 17, 2); $raw_datetime = translate_from_gregorian($raw_datetime); $year = (int)substr($raw_datetime, 0, 4); $month = (int)substr($raw_datetime, 5, 2); $day = (int)substr($raw_datetime, 8, 2); return strftime(DATE_TIME_FORMAT, mktime($hour, $minute, $second, $month, $day, $year)); } or if you need to keep the time. here I use the same time that osc uses or if you want you can adjust it based on timezone you can cut up to 4 pages of your checkout by using my three add_ons login create account in one page Express checkout login pop up modal Link to comment Share on other sites More sharing options...
hungryfrank Posted January 22, 2020 Author Share Posted January 22, 2020 one problem is in categories.php around line 563 <td class="main"><?php echo tep_draw_input_field('products_date_available', translate_from_gregorian($pInfo->products_date_available), 'id="products_date_available" style="width: 500px;"') . ' <small>(YYYY-MM-DD)</small>'; ?></td> here I have to make a core change because osc dose not format the $pinfo->product_date_available. this is an inconsistency in the way osc handles the date when it is displayed to user you can cut up to 4 pages of your checkout by using my three add_ons login create account in one page Express checkout login pop up modal Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.