Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Date picker
02-15-2021, 01:22 AM,
#1
Date picker
Next month it will be 13 years since Renier submitted his date picker javascript component, which has been successfully used more or less unchanged since then. However all modern browsers have for some years now got their own HTML5 date picker components built in, and I wonder whether it is now time to move to using this.

It requires a small amount of work in each script as the HTML5 component returns dates in the format yyyy-mm-dd but displays the date in the browsers own locale format. This means that we need to simplify the use of the ConvertSQLDate() and FormatDateForSQL() functions. The HTML5 component will also do date validations.

The final result will I think be a nicer looking date picker, and simpler code.

Any thoughts?

Tim
Reply
02-15-2021, 05:54 AM,
#2
RE: Date picker
Sounds like a no-brainer to me, I like the idea!
Reply
02-15-2021, 09:19 AM,
#3
RE: Date picker
(02-15-2021, 05:54 AM)TurboPT Wrote: Sounds like a no-brainer to me, I like the idea!
Hi Paul, here is GLJournal.php with the changes done for you to look at. You can see the changes that need doing by doing a diff of this file.


.php   GLJournal.php (Size: 22.86 KB / Downloads: 1)

The files that need changing are:
AddCustomerNotes.php
AddCustomerTypeNotes.php
AuditTrail.php
BankMatching.php
BOMs.php
BOMs_SingleLevel.php
CollectiveWorkOrderCost.php
ConfirmDispatch_Invoice.php
Contracts.php
CounterReturns.php
CounterSales.php
CustomerAccount.php
CustomerBalancesMovement.php
CustomerInquiry.php
CustomerReceipt.php
Customers.php
CustomerTransInquiry.php
DailyBankTransactions.php
DeliveryDetails.php
FixedAssetDepreciation.php
FixedAssetRegister.php
GeneratePickingList.php
GLJournalInquiry.php
GoodsReceived.php
HistoricalTestResults.php
includes/InputSerialItemsKeyed.php
includes/OutputSerialItems.php
InternalStockRequestInquiry.php
InternalStockRequest.php
MRPCalendar.php
MRPCreateDemands.php
MRPDemands.php
MRPPlannedPurchaseOrders.php
MRPPlannedWorkOrders.php
Payments.php
PcAssignCashTabToTab.php
PcAssignCashToTab.php
PcClaimExpensesFromTab.php
PcReportExpense.php
PcReportTab.php
PcTabExpensesList.php
PDFChequeListing.php
PDFCustomerList.php
PDFCustTransListing.php
PDFDeliveryDifferences.php
PDFDIFOT.php
PDFLowGP.php
PDFOrdersInvoiced.php
PDFOrderStatus.php
PDFPeriodStockTransListing.php
PDFPickingList.php
PDFPriceList.php
PDFPrintLabel.php
PDFRemittanceAdvice.php
PDFSellThroughSupportClaim.php
PDFSuppTransListing.php
PO_Header.php
PO_Items.php
POReport.php
PO_SelectOSPurchOrder.php
PriceMatrix.php
PricesBasedOnMarkUp.php
Prices_Customer.php
Prices.php
PurchasesReport.php
PurchData.php
RecurringSalesOrders.php
ReverseGRN.php
SalesByTypePeriodInquiry.php
SalesCategoryPeriodInquiry.php
SalesInquiry.php
SalesReport.php
SalesTopCustomersInquiry.php
SalesTopItemsInquiry.php
SelectCompletedOrder.php
SelectOrderItems.php
SelectQASamples.php
SelectSalesOrder.php
SellThroughSupport.php
Shipments.php
SpecialOrder.php
StockCategorySalesInquiry.php
StockLocMovements.php
StockMovements.php
StockQuantityByDate.php
SuppCreditGRNs.php
SupplierCredit.php
SupplierInquiry.php
SupplierInvoice.php
SupplierPriceList.php
Suppliers.php
SupplierTenderCreate.php
SupplierTenders.php
SupplierTransInquiry.php
SuppPaymentRun.php
TestPlanResults.php
WorkOrderEntry.php
WorkOrderIssue.php
WorkOrderReceive.php
Z_ImportPriceList.php

I don't mind helping with some of them.

Tim
Reply
02-15-2021, 01:03 PM, (This post was last modified: 02-15-2021, 02:31 PM by TurboPT.)
#4
RE: Date picker
Thanks! I created a branch for the effort.

We seem to have a few minor differences within GLJournal.php? (literally, only about a handful)

To the input at line 446, I had to add FormatDateForSQL to the input's value to make it appear on the page as a date. Otherwise, the date input displayed with format mm / dd / yyyy as the value instead of the related session date. (we must have other subtle differences that I might not know?)

Update to the last portion:
After testing changes applied to AddCustomerNotes.php (pushed to the branch), I may not have correctly copied a couple of changes from the GLJournal.php file, so I'll re-diff the GLJournal.php file again tomorrow.
Reply
02-15-2021, 08:31 PM,
#5
RE: Date picker
Hi Paul, you have hit upon a potential problem. The date shown in the input box will always be in the format for the locale that your browser is set to. In your case en_US which will show the date as mm-dd-yyyy. On submitting the form the browser will automatically submit in the form yyyy-mm-dd in all cases. So, the script as I did shows the wrong format if the webERP default format is different from the browser locale format. Does that make sense?
There are work arounds, but I suppose the question is how much of a deal breaker this is. Do many users have the webERP default date format different from their browser locale format?

Tim
Reply
02-16-2021, 01:05 PM,
#6
RE: Date picker
Doh! ... well, glad it's an early catch.

I'm not sure on the deal breaker aspect. Is this to say adding the function(s) as I did would not be the way to go?

...and I'm not sure on the last part to the webERP users default date format vs. the browser.
Reply
02-16-2021, 11:06 PM,
#7
RE: Date picker
I am curious Paul, what differences other than the ones required for changing the date picker do you see between my script that I submitted and the one on Git?
Reply
02-18-2021, 12:52 PM, (This post was last modified: 02-18-2021, 01:12 PM by TurboPT.)
#8
RE: Date picker
Apologies Tim, I did not get to this sooner.

It's nothing too major, really.

The 3 main differences were:
In our file, lines: 65, 436, 438. Line 65 is an extra condition block, the other two are single-line differences.

The rest appear to related to changing the date:
In your file, lines: 268, 290 look as if the FormatDateForSQL function was removed as part of the calendar change?
(this is where I said previously that I might not have correctly applied all of your changes)

Then at line 441 in your file, 446 in ours, is where I added the FormatDateForSQL to format the date when I tested. This is where I'm not sure if this is what should have been added by me, but made the date populate the field as expected to visually check the page. (unless I need the changes from line 268 and 290 to avoid this change -- I'll have to apply the changes to check)
Reply
02-18-2021, 07:08 PM,
#9
RE: Date picker
Hi Paul, These changes are all related to changes in the date picker.

The condition block at 65 was removed because it is obsolete. The HTML5 date picker always returns a date in the format yyyy-mm-dd and so checking whether it is a valid date format is pointless.

The change on lines 436 and 438 is to default the date to yyyy-mm-dd if no date is currently entered. Previously it defaulted to the webERP session date, but now the date picker control expects it to always be in the yyyy-mm-dd format (becuse you removed this change is why you had to do your change, but I think it is more elegant to do it here).

The file I submitted was based on this file (https://github.com/webERP-team/webERP/bl...ournal.php) with only the changes necessary to use the HTML5 date picker applied to it.

Tim
Reply
02-19-2021, 10:49 AM, (This post was last modified: 02-19-2021, 10:50 AM by TurboPT.)
#10
RE: Date picker
Ok, sounds like I was "cherry picking" the diff between your file and current webERP, thinking that there were some differences between webERP and other changes you may have had.

So, I need to go back and apply everything that you've done then! (assumption/confusion on my part)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)