Added option to handle Jalali and Islamic Calendars
[fa-stable.git] / includes / ui / ui_input.inc
index 58027b2fcface54702a10d6f467a16d3cf6cd881..0220b7be55db4538642974f4c05c3b46a15be2ee 100644 (file)
@@ -242,16 +242,25 @@ function date_cells($label, $name, $init=null, $inc_days=0, $inc_months=0, $inc_
        {
                if (!$init)
                {
-                       if ($inc_days == 1001)
+                       if ($inc_years == 1001)
                                $_POST[$name] = null;
-                       else    
-                               $_POST[$name] = date(user_date_display(), Mktime(0,0,0,date("m") + $inc_months,date("d") + $inc_days,date("Y") + $inc_years));
+                       else
+                       {
+                               $dd = Today();
+                               if ($inc_days != 0)
+                                       $dd = add_days($dd, $inc_days);
+                               if ($inc_months != 0)
+                                       $dd = add_months($dd, $inc_months);
+                               if ($inc_years != 0)
+                                       $dd = add_years($dd, $inc_years);
+                               $_POST[$name] = $dd;
+                       }       
                }               
                else
                        $_POST[$name] = $init;
        }
        if ($use_date_picker)
-               $post_label = "<a href=\"javascript:date_picker('document.forms[0].$name', document.forms[0].$name.value);\">"
+               $post_label = "<a href=\"javascript:date_picker(document.forms[0].$name);\">"
                . "     <img src='$path_to_root/themes/default/images/cal.gif' width='16' height='16' border='0' alt='"._('Click Here to Pick up the date')."'></a>\n";
        else
                $post_label = "";