3 include_once($path_to_root . "/admin/db/voiding_db.inc");
5 //--------------------------------------------------------------------------------------
7 function get_supplier_trans_view_str($type, $trans_no, $label="")
9 global $path_to_root, $use_popup_windows;
12 if ($type == systypes::po())
13 $viewer = "view_po.php";
15 $viewer = "view_supp_invoice.php";
17 $viewer = "view_supp_credit.php";
19 $viewer = "view_supp_payment.php";
21 $viewer = "view_grn.php";
30 if ($use_popup_windows)
31 $preview_str = "<a target='_blank' href='$path_to_root/purchasing/view/$viewer?trans_no=$trans_no' onclick=\"javascript:openWindow(this.href,this.target); return false;\" >$label</a>";
33 $preview_str = "<a target='_blank' href='$path_to_root/purchasing/view/$viewer?trans_no=$trans_no'>$label</a>";
36 $preview_str = $label;
41 //--------------------------------------------------------------------------------------
43 function get_gl_view_str($type, $trans_no, $label="", $force=false)
45 global $path_to_root, $use_popup_windows;
47 if (!$force && !user_show_gl_info())
52 if ($use_popup_windows)
53 $gl_view = "<a target='_blank' href='$path_to_root/gl/view/gl_trans_view.php?type_id=$type&trans_no=$trans_no' onclick=\"javascript:openWindow(this.href,this.target); return false;\" >$label</a>";
55 $gl_view = "<a target='_blank' href='$path_to_root/gl/view/gl_trans_view.php?type_id=$type&trans_no=$trans_no'>$label</a>";
60 //--------------------------------------------------------------------------------------
62 function get_gl_view_str_cell($type, $trans_no, $label="")
64 $str = get_gl_view_str($type, $trans_no, $label);
66 return "<td>$str</td>";
69 //--------------------------------------------------------------------------------------
71 function get_customer_trans_view_str($type, $trans_no, $label="")
73 global $path_to_root, $use_popup_windows;
77 $viewer = "view_invoice.php";
79 $viewer = "view_credit.php";
81 $viewer = "view_receipt.php";
83 $viewer = "view_sales_order.php";
92 if ($use_popup_windows)
93 $preview_str = "<a target='_blank' href='$path_to_root/sales/view/$viewer?trans_no=$trans_no' onclick=\"javascript:openWindow(this.href,this.target); return false;\" >$label</a>";
95 $preview_str = "<a target='_blank' href='$path_to_root/sales/view/$viewer?trans_no=$trans_no'>$label</a>";
98 $preview_str = $label;
103 //--------------------------------------------------------------------------------------
105 function get_banking_trans_view_str($type, $trans_no, $label="")
107 global $path_to_root, $use_popup_windows;
112 $viewer = "bank_transfer_view.php";
114 $viewer = "gl_payment_view.php";
116 $viewer = "gl_deposit_view.php";
127 if ($use_popup_windows)
128 $preview_str = "<a target='_blank' href='$path_to_root/gl/view/$viewer?trans_no=$trans_no' onclick=\"javascript:openWindow(this.href,this.target); return false;\" >$label</a>";
130 $preview_str = "<a target='_blank' href='$path_to_root/gl/view/$viewer?trans_no=$trans_no'>$label</a>";
133 $preview_str = $label;
138 //--------------------------------------------------------------------------------------
140 function get_inventory_trans_view_str($type, $trans_no, $label="")
142 global $path_to_root, $use_popup_windows;
146 if ($type == systypes::inventory_adjustment())
147 $viewer = "view_adjustment.php";
148 elseif ($type == systypes::location_transfer())
149 $viewer = "view_transfer.php";
158 if ($use_popup_windows)
159 $preview_str = "<a target='_blank' href='$path_to_root/inventory/view/$viewer?trans_no=$trans_no' onclick=\"javascript:openWindow(this.href,this.target); return false;\" >$label</a>";
161 $preview_str = "<a target='_blank' href='$path_to_root/inventory/view/$viewer?trans_no=$trans_no'>$label</a>";
164 $preview_str = $label;
169 //--------------------------------------------------------------------------------------
171 function get_manufacturing_trans_view_str($type, $trans_no, $label="")
173 global $path_to_root, $use_popup_windows;
178 $viewer = "wo_issue_view.php";
180 $viewer = "wo_production_view.php";
181 elseif ($type == systypes::work_order())
182 $viewer = "work_order_view.php";
191 if ($use_popup_windows)
192 $preview_str = "<a target='_blank' href='$path_to_root/manufacturing/view/$viewer?trans_no=$trans_no' onclick=\"javascript:openWindow(this.href,this.target); return false;\" >$label</a>";
194 $preview_str = "<a target='_blank' href='$path_to_root/manufacturing/view/$viewer?trans_no=$trans_no'>$label</a>";
197 $preview_str = $label;
202 //--------------------------------------------------------------------------------------
204 function get_dimensions_trans_view_str($type, $trans_no, $label="")
206 global $path_to_root, $use_popup_windows;
211 $viewer = "view_dimension.php";
220 if ($use_popup_windows)
221 $preview_str = "<a target='_blank' href='$path_to_root/dimensions/view/$viewer?trans_no=$trans_no' onclick=\"javascript:openWindow(this.href,this.target); return false;\" >$label</a>";
223 $preview_str = "<a target='_blank' href='$path_to_root/dimensions/view/$viewer?trans_no=$trans_no'>$label</a>";
226 $preview_str = $label;
231 //--------------------------------------------------------------------------------------
233 function get_trans_view_str($type, $trans_no, $label="")
235 $view_str = get_customer_trans_view_str($type, $trans_no, $label);
236 if ($view_str != null)
239 $view_str = get_supplier_trans_view_str($type, $trans_no, $label);
240 if ($view_str != null)
243 $view_str = get_banking_trans_view_str($type, $trans_no, $label);
244 if ($view_str != null)
247 $view_str = get_inventory_trans_view_str($type, $trans_no, $label);
248 if ($view_str != null)
251 $view_str = get_manufacturing_trans_view_str($type, $trans_no, $label);
252 if ($view_str != null)
255 $view_str = get_dimensions_trans_view_str($type, $trans_no, $label);
256 if ($view_str != null)
262 //--------------------------------------------------------------------------------------
264 function exchange_rate_display($from_currency, $to_currency, $date_, $buttons=true)
266 if ($from_currency != $to_currency)
268 if ($buttons && isset($_POST['get_rate']))
270 $comp_currency = get_company_currency();
271 if ($from_currency == $comp_currency)
272 $currency = $to_currency;
274 $currency = $from_currency;
275 $rate = get_ecb_rate($currency);
276 if (get_date_exchange_rate($currency, $date_))
277 update_exchange_rate($currency, $date_, $rate, $rate);
279 add_exchange_rate($currency, $date_, $rate, $rate);
280 if ($from_currency == $comp_currency)
284 $rate = get_exchange_rate_from_to($to_currency, $from_currency, $date_);
285 $rate = number_format2($rate, user_exrate_dec());
286 label_row(_("Exchange Rate:"),"1 " . $from_currency . " = " . $rate . " " . $to_currency .
287 ($buttons?" " . submit('get_rate',_("Get"), false):""));
291 //--------------------------------------------------------------------------------------
293 function is_voided_display($type, $id, $label)
296 $void_entry = get_voided_entry($type, $id);
298 if ($void_entry == null)
301 start_table("width=50% $table_style");
302 echo "<tr><td align=center><font color=red>$label</font><br>";
303 echo "<font color=red>" . _("Date Voided:") . " " . sql2date($void_entry["date_"]) . "</font><br>";
304 if (strlen($void_entry["memo_"]) > 0)
305 echo "<center><font color=red>" . _("Memo:") . " " . $void_entry["memo_"] . "</font><br>";
312 //--------------------------------------------------------------------------------------
314 function comments_display_row($type, $id)
316 $comments = get_comments($type, $id);
317 if ($comments and db_num_rows($comments))
319 echo "<tr><td colspan=15>";
320 while ($comment = db_fetch($comments))
322 echo $comment["memo_"] . "<br>";
328 //--------------------------------------------------------------------------------------
330 function get_comments_string($type, $type_no)
333 $result = get_comments($type, $type_no);
334 while ($comment = db_fetch($result))
336 if (strlen($str_return))
337 $str_return = $str_return . " \n";
338 $str_return = $str_return . $comment["memo_"];
343 //--------------------------------------------------------------------------------------
345 function view_stock_status($stock_id, $description=null)
347 global $path_to_root;
349 //hyperlink_params_separate($path_to_root . "/inventory/inquiry/stock_status.php", (user_show_codes()?$stock_id . " - ":"") . $description, "stock_id=$stock_id");
350 $preview_str = "<a target='_blank' href='$path_to_root/inventory/inquiry/stock_status.php?stock_id=$stock_id' onclick=\"javascript:openWindow(this.href,this.target); return false;\" >". (user_show_codes()?$stock_id . " - ":"") . $description."</a>";
352 //hyperlink_params_separate($path_to_root . "/inventory/inquiry/stock_status.php", $stock_id, "stock_id=$stock_id");
353 $preview_str = "<a target='_blank' href='$path_to_root/inventory/inquiry/stock_status.php?stock_id=$stock_id' onclick=\"javascript:openWindow(this.href,this.target); return false;\" >$stock_id</a>";
357 function view_stock_status_cell($stock_id, $description=null)
360 view_stock_status($stock_id, $description);
364 //--------------------------------------------------------------------------------------
366 function display_debit_or_credit_cells($value)
376 amount_cell(abs($value));
386 //--------------------------------------------------------------------------------------
388 function display_customer_trans_tax_details($tax_items, $columns)
390 while ($tax_item = db_fetch($tax_items))
392 $tax = number_format2($tax_item['amount'],user_price_dec());
393 if ($tax_item['included_in_price'])
394 label_row(_("Included") . " " . $tax_item['tax_type_name'] . " (" . $tax_item['rate'] . "%) " .
395 _("Amount") . ": $tax", "", "colspan=$columns align=right", "align=right");
397 label_row($tax_item['tax_type_name'] . " (" . $tax_item['rate'] . "%)",
398 $tax, "colspan=$columns align=right", "align=right");
402 //--------------------------------------------------------------------------------------
404 function display_supp_trans_tax_details($tax_items, $columns)
406 while ($tax_item = db_fetch($tax_items))
408 $tax = number_format2(abs($tax_item['amount']),user_price_dec());
409 if ($tax_item['included_in_price'])
410 label_row(_("Included") . " " . $tax_item['tax_type_name'] . " (" . $tax_item['rate'] . "%) " .
411 _("Amount:") . ": $tax", "colspan=$columns align=right", "align=right");
413 label_row($tax_item['tax_type_name'] . " (" . $tax_item['rate'] . "%)",
414 $tax, "colspan=$columns align=right", "align=right");
418 //--------------------------------------------------------------------------------------
420 function display_edit_tax_items($taxes, $columns)
424 foreach ($taxes as $taxitem)
426 if ($taxitem['included_in_price'])
428 label_row(_("Included") . " " . $taxitem['tax_type_name'] . " (" . $taxitem['rate'] . "%) " .
429 _("Amount:") . " " . number_format2($taxitem['Value'],user_price_dec()), "", "colspan=$columns align=right", "align=right");
433 label_row($taxitem['tax_type_name'] . " (" . $taxitem['rate'] . "%)",
434 number_format2($taxitem['Value'],user_price_dec()), "colspan=$columns align=right", "align=right");
435 $total += $taxitem['Value'];
442 //--------------------------------------------------------------------------------------
444 function display_footer_exit()
446 global $path_to_root;
452 //--------------------------------------------------------------------------------------
454 function display_allocations($alloc_result, $total)
458 if (!$alloc_result || db_num_rows($alloc_result) == 0)
461 display_heading2(_("Allocations"));
463 start_table("$table_style width=80%");
465 $th = array( _("Type"), _("Number"), _("Date"), _("Total Amount"),
466 _("Left to Allocate"), _("This Allocation"));
468 $k = $total_allocated = 0;
470 while ($alloc_row = db_fetch($alloc_result))
473 alt_table_row_color($k);
475 label_cell(systypes::name($alloc_row['type']));
476 label_cell(get_trans_view_str($alloc_row['type'],$alloc_row['trans_no']));
477 label_cell(sql2date($alloc_row['tran_date']));
478 amount_cell($alloc_row['Total']);
479 //amount_cell($alloc_row['Total'] - $alloc_row['PrevAllocs'] - $alloc_row['amt']);
480 amount_cell($alloc_row['Total'] - $alloc_row['amt']);
481 amount_cell($alloc_row['amt']);
484 $total_allocated += $alloc_row['amt'];
487 label_cell(_("Total Allocated:"), "align=right colspan=5");
488 amount_cell($total_allocated);
491 label_cell(_("Left to Allocate:"), "align=right colspan=5");
492 amount_cell($total - $total_allocated);
498 //--------------------------------------------------------------------------------------
500 function display_allocations_from($person_type, $person_id, $type, $type_no, $total)
502 switch ($person_type)
504 case payment_person_types::customer() :
505 $alloc_result = get_allocatable_to_cust_transactions($person_id, $type_no, $type);
506 display_allocations($alloc_result, $total);
508 case payment_person_types::supplier() :
509 $alloc_result = get_allocatable_to_supp_transactions($person_id, $type_no, $type);
510 display_allocations($alloc_result, $total);
515 function get_js_go_back()
517 $js = "\n<script type=\"text/javascript\">\n"
519 . "function goBack()\n"
521 . " if (window.history.length <= 1)\n"
522 . " window.close();\n"
524 . " window.history.go(-1);\n"
531 function get_js_open_window($width, $height)
533 $js = "\n<script type=\"text/javascript\">\n"
535 . "function openWindow(url, title)\n"
537 . " var left = (screen.width - $width) / 2;\n"
538 . " var top = (screen.height - $height) / 2;\n"
539 . " window.open(url, title, 'width=$width,height=$height,left='+left+',top='+top+',screenX='+left+',screenY='+top+',status=no,scrollbars=yes');\n"
546 function get_js_form_entry($edit_name, $sel_name, $next_name)
548 $js = "\n<script type=\"text/javascript\">\n"
550 . "function recalcAccounts()\n"
552 . " var myForm = document.forms[0];\n"
553 . " var len = myForm.$sel_name.length;\n"
555 . " var ac = myForm.$edit_name.value;\n"
557 . " myForm.$sel_name.options[myForm.$sel_name.selectedIndex].selected = false;\n"
558 . " for (i = 0; i < len; i++)\n"
560 . " txt = myForm.$sel_name.options[i].text;\n"
561 . " if (txt.indexOf(ac) == 0)\n"
563 . " myForm.$sel_name.options[i].selected = true;\n"
568 . "function setAccount(p, s)\n"
570 . " var myForm = document.forms[0];\n"
571 . " if (p == 0 && myForm.$edit_name.value == \"\")\n"
573 . " myForm.$edit_name.value = myForm.$sel_name.options[myForm.$sel_name.selectedIndex].value;\n"
575 . " myForm.submit();\n"
576 . " myForm.$next_name.focus();\n"
584 function get_js_set_focus($name)
586 $js = "\n<script type=\"text/javascript\">\n"
588 . "function setFocus()\n"
590 . " document.forms[0].$name.focus();\n"
597 function get_js_png_fix()
599 $js = "<script type=\"text/javascript\">\n"
600 . "function fixPNG(myImage)\n"
602 . " var arVersion = navigator.appVersion.split(\"MSIE\")\n"
603 . " var version = parseFloat(arVersion[1])\n"
604 . " if ((version >= 5.5) && (version < 7) && (document.body.filters))\n"
606 . " var imgID = (myImage.id) ? \"id='\" + myImage.id + \"' \" : \"\"\n"
607 . " var imgClass = (myImage.className) ? \"class='\" + myImage.className + \"' \" : \"\"\n"
608 . " var imgTitle = (myImage.title) ?\n"
609 . " \"title='\" + myImage.title + \"' \" : \"title='\" + myImage.alt + \"' \"\n"
610 . " var imgStyle = \"display:inline-block;\" + myImage.style.cssText\n"
611 . " var strNewHTML = \"<span \" + imgID + imgClass + imgTitle\n"
612 . " + \" style=\\\"\" + \"width:\" + myImage.width\n"
613 . " + \"px; height:\" + myImage.height\n"
614 . " + \"px;\" + imgStyle + \";\"\n"
615 . " + \"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader\"\n"
616 . " + \"(src=\'\" + myImage.src + \"\', sizingMethod='scale');\\\"></span>\"\n"
617 . " myImage.outerHTML = strNewHTML\n"
624 function get_js_date_picker()
626 global $dateseps, $path_to_root;
628 $encoding = $_SESSION['language']->encoding; // character encoding
629 $dir = $_SESSION['language']->dir; // left to right, right to left
630 $how = user_date_format(); // 0 = us/ca, 1 = eu, au, nz, 2 = jp, sw
631 $sep = $dateseps[user_date_sep()]; // date separator
632 $wstart = ($how != 0); // weekstart (sun = 0, mon = 1)
633 $width = 250; // datepicker width
634 $height = 180; // datepicker height
635 $path = "$path_to_root/themes/default/images/"; // path to images
636 $tbgcolor = "#4682b4"; // title backgrond
637 $tcolor = "white"; // title color
638 $wbgcolor = "#87cefa"; // weekdays background
639 $wcolor = "white"; // weekdays color
640 $cbgcolor = "#ffb6c1"; // current day background
641 $ebgcolor = "#dbeaf5"; // week-end background
642 $bgcolor = "white"; // normal background
643 $color = "darkblue"; // month day color
644 $gcolor = "#aaaaaa"; // prev/next month day color
645 $family = "tahoma,verdana"; // font-family
647 $js = "\n<script type=\"text/javascript\">\n"
649 . "function date_picker(nm, val) {\n"
650 . " var mons = ['"._('January')."', '"._('February')."', '"._('March')."', '"._('April')."', '"._('May')."', '"._('June')."',\n"
651 . " '"._('July')."', '"._('August')."', '"._('Sebtember')."', '"._('October')."', '"._('November')."', '"._('December')."'];\n"
652 . " var wdays = ['"._('Su')."', '"._('Mo')."', '"._('Tu')."', '"._('We')."', '"._('Th')."', '"._('Fr')."', '"._('Sa')."'];\n"
653 . " var wstart = $wstart; // day of week starts from (normally 0 or 1)\n"
654 . " var _date = (val == null || val =='' ? new Date() : str2dt(val));\n"
655 . " var _prev = new Date(_date);\n"
656 . " _prev.setMonth(_date.getMonth()-1);\n"
657 . " var _next = new Date(_date);\n"
658 . " _next.setMonth(_date.getMonth()+1);\n"
659 . " var _prevy = new Date(_date);\n"
660 . " _prevy.setFullYear(_date.getFullYear()-1);\n"
661 . " var _nexty = new Date(_date);\n"
662 . " _nexty.setFullYear(_date.getFullYear()+1);\n"
663 . " var _first = new Date(_date);\n"
664 . " _first.setDate(1);\n"
665 . " _first.setDate(1-(7+_first.getDay()-wstart)%7);\n"
666 . " var _last = new Date(_next);\n"
667 . " _last.setDate(0);\n"
668 . " var left = (screen.width - $width) / 2;\n"
669 . " var top = (screen.height - $height) / 2;\n"
670 . " var buff = new String (\n"
671 . "\"<html dir='$dir'>\\n\"+\n"
673 . "\" <title>DatePicker</title>\\n\"+\n"
674 . "\" <meta http-equiv='Content-type' content='text/html'; charset='$encoding'>\\n\"+\n"
675 . "\" <style>\\n\"+\n"
676 . "\" body { background-color:$tbgcolor; margin:0; padding:0; font-family: $family; font-size: 13px; }\\n\"+\n"
677 . "\" select { font-size: 12px; }\\n\"+\n"
678 . "\" a { text-decoration: none; }\\n\"+\n"
679 . "\" a:hover { text-decoration: underline; }\\n\"+\n"
680 . "\" .tbg { background-color: $tbgcolor; color: $tcolor; font-size: 12px; font-weight: bold; text-align: center;}\\n\"+\n"
681 . "\" .wbg { background-color: $wbgcolor; color: $wcolor; font-size: 12px; text-align: right; }\\n\"+\n"
682 . "\" .cbg { background-color: $cbgcolor; font-size: 12px; text-align: right; }\\n\"+\n"
683 . "\" .ebg { background-color: $ebgcolor; font-size: 12px; text-align: right; }\\n\"+\n"
684 . "\" .bg { background-color: $bgcolor; font-size: 12px; text-align: right; }\\n\"+\n"
685 . "\" .c { color: $color; }\\n\"+\n"
686 . "\" .gc { color: $gcolor; }\\n\"+\n"
687 . "\" </style>\\n\"+\n"
688 . "\"</head>\\n\"+\n"
690 . "\"<table cellspacing=\\\"0\\\" border=\\\"0\\\" style=\\\"width:100%;\\\">\\n\"+\n"
691 . "\"<tr><td class=\\\"tbg\\\">\\n\"+\n"
692 . "\"<table cellspacing=\\\"1\\\" cellpadding=\\\"2\\\" border=\\\"0\\\" style=\\\"width:100%;\\\">\\n\"+\n"
693 . "\"<tr>\\n <td class=\\\"tbg\\\"><a href=\\\"javascript:window.opener.date_picker('\"+\n"
694 . " nm+\"', '\"+ dt2dtstr(_prev)+\"');\\\">\"+\n"
695 . "\"<img src=\\\"".$path."prev.gif\\\" width=\\\"16\\\" height=\\\"16\\\" border=\\\"0\\\"\"+\n"
696 . "\" alt=\\\""._('previous month')."\\\"></a></td>\\n\"+\n"
697 . "\" <td class=\\\"tbg\\\" colspan=\\\"5\\\">\"+\n"
698 . " mons[_date.getMonth()]+\"</td>\\n\"+\n"
699 . "\" <td class=\\\"tbg\\\"><a href=\\\"javascript:window.opener.date_picker('\"\n"
700 . " +nm+\"', '\"+dt2dtstr(_next)+\"');\\\">\"+\n"
701 . "\"<img src=\\\"".$path."next.gif\\\" width=\\\"16\\\" height=\\\"16\\\" border=\\\"0\\\"\"+\n"
702 . "\" alt=\\\""._('next month')."\\\"></a></td>\\n</tr>\\n\"+\n"
703 . "\"<tr>\\n <td class=\\\"tbg\\\"><a href=\\\"javascript:window.opener.date_picker('\"+\n"
704 . " nm+\"', '\"+ dt2dtstr(_prevy)+\"');\\\">\"+\n"
705 . "\"<img src=\\\"".$path."prev.gif\\\" width=\\\"16\\\" height=\\\"16\\\" border=\\\"0\\\"\"+\n"
706 . "\" alt=\\\""._('previous year')."\\\"></a></td>\\n\"+\n"
707 . "\" <td class=\\\"tbg\\\" colspan=\\\"5\\\">\"+\n"
708 . " _date.getFullYear()+\"</td>\\n\"+\n"
709 . "\" <td class=\\\"tbg\\\"><a href=\\\"javascript:window.opener.date_picker('\"\n"
710 . " +nm+\"', '\"+dt2dtstr(_nexty)+\"');\\\">\"+\n"
711 . "\"<img src=\\\"".$path."next.gif\\\" width=\\\"16\\\" height=\\\"16\\\" border=\\\"0\\\"\"+\n"
712 . "\" alt=\\\""._('next year')."\\\"></a></td>\\n</tr>\\n\"\n"
714 . " var _current = new Date(_first);\n"
715 . " // weekdays titles\n"
716 . " buff += \"<tr>\\n\";\n"
717 . " for (var n=0; n<7; n++)\n"
718 . " buff += \" <td class=\\\"wbg\\\">\"+\n"
719 . " wdays[(wstart+n)%7]+\"</td>\\n\";\n"
720 . " // calendar table\n"
721 . " buff += \"</tr>\\n\";\n"
722 . " for (var i=0; i<6; i++) {\n"
724 . " buff += \"<tr>\\n\";\n"
725 . " for (var n=0; n<7; n++) {\n"
726 . " if (_current.getDate() == _date.getDate() &&\n"
727 . " _current.getMonth() == _date.getMonth())\n"
728 . " // current date\n"
729 . " buff += \" <td class=\\\"cbg\\\">\";\n"
730 . " else if (_current.getDay() == 0 || _current.getDay() == 6)\n"
731 . " // weekend days\n"
732 . " buff += \" <td class=\\\"ebg\\\">\";\n"
734 . " // working days of current month\n"
735 . " buff += \" <td class=\\\"bg\\\">\";\n"
736 . " if (_current.getMonth() == _date.getMonth())\n"
737 . " // days of current month\n"
738 . " buff += \"<a href=\\\"javascript:window.opener.\"+nm+\n"
739 . " \".value='\"+dt2dtstr(_current)+\"'; window.close();\\\">\"+\n"
740 . " \"<span class=\\\"c\\\">\";\n"
742 . " // days of other months\n"
743 . " buff += \"<a href=\\\"javascript:window.opener.\"+nm+\n"
744 . " \".value='\"+dt2dtstr(_current)+\"'; window.close();\\\">\"+\n"
745 . " \"<span class=\\\"gc\\\">\";\n"
746 . " buff += _current.getDate()+\"</span></a></td>\\n\";\n"
747 . " _current.setDate(_current.getDate()+1);\n"
750 . " buff += \"</tr>\\n\";\n"
752 . " // picker footer\n"
754 . " \"</table>\\n\" +\n"
755 . " \"</tr>\\n</td>\\n</table>\\n\" +\n"
756 . " \"</body>\\n\" +\n"
757 . " \"</html>\\n\";\n"
758 . " var picker = window.open('', 'DatePicker',\n"
759 . " 'width=$width,height=$height,status=no,resizable=yes,top='+top+',left='+left+'');\n"
760 . " picker.opener = self;\n"
761 . " var _doc = picker.document;\n"
762 . " _doc.write (buff);\n"
765 . "// datetime parsing and formatting routimes. modify them if you wish other datetime format\n"
766 . "function str2dt (val) {\n"
767 . " var re_date = /^(\\d+)\\".$sep."(\\d+)\\".$sep."(\\d+)+$/;\n"
768 . " if (!re_date.exec(val))\n"
769 . " return alert('"._('Invalid Datetime format').": '+ val);\n";
771 $js .= " return (new Date (RegExp.$3, RegExp.$1-1, RegExp.$2));\n";
773 $js .= " return (new Date (RegExp.$3, RegExp.$2-1, RegExp.$1));\n";
775 $js .= " return (new Date (RegExp.$1, RegExp.$2-1, RegExp.$3));\n";
777 . "function dt2dtstr (_date) {\n"
778 . " var da = new String(_date.getDate());\n"
779 . " var mo = new String(_date.getMonth()+1);\n"
780 . " var yr = _date.getFullYear();\n"
781 . " if (da.length < 2)\n"
783 . " if (mo.length < 2)\n"
786 $js .= " return (new String (mo+'$sep'+da+'$sep'+yr));\n";
788 $js .= " return (new String (da+'$sep'+mo+'$sep'+yr));\n";
790 $js .= " return (new String (yr+'$sep'+mo+'$sep'+da));\n";
799 echo "\n<script type=\"text/javascript\">\n"
806 if (!function_exists('_vd'))
808 function _vd($mixed, $title = '', $exit = false)
810 // Only the site admin is able to proceed here.
811 echo (!empty($title) ? ($title .':') : '') .'<pre>';