Thanks for your query,based on the facts that you have posted it appears that you are known diabetic and passing foamy urine which smells bad since few weeks.
This is most likely to be due to UTI
Please confirm whether your diabetes
is well controlled.
Please get your routine urine test and urine culture done to find out the organisms causing this infection and antibiotics to which they are sensitive to.
Please take broad spectrum antibiotics like Cefotaxime
along with urinary antiseptic like Nitrofurantoin
twice daily and urine alkaliser thrice daily.and later on switch on to appropriate antibiotics as per culture report.
Ensure to drink more water.To keep your urine dilute This will help to control dysuria
Hope to get your problem resolved within a week.