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, $date_system;
628 $how = user_date_format(); // 0 = us/ca, 1 = eu, au, nz, 2 = jp, sw
629 $sep = $dateseps[user_date_sep()]; // date separator
630 $wstart = (($date_system == 1 || $date_system == 2) ? 6 : ($how == 0 ? 0 : 1)); // weekstart (sun = 0, mon = 1)
631 $months = array(_("January"),_("February"),_("March"),_("April"),_("May"),_("June"),_("July"),_("August"),_("September"),_("October"),_("November"),_("December"));
632 $wdays = array(_("Su"),_("Mo"),_("Tu"),_("We"),_("Th"),_("Fr"),_("Sa"));
634 if ($date_system == 1)
635 list($cyear, $cmon, $cday) = gregorian_to_jalali(date("Y"), date("n"), date("j"));
636 else if ($date_system == 2)
637 list($cyear, $cmon, $cday) = gregorian_to_islamic(date("Y"), date("n"), date("j"));
640 #CCIFrame { display: none; left: 0px; position: absolute; top: 0px; height: 250px; width: 250px; z-index: 99;}
641 #CC { position:absolute; background-color:#FFF; margin:0; padding:0; display:none; z-index: 100;}
642 #CC table { font-family: arial, verdana, helvetica, sans-serif;font-size: 8pt; border-left: 1px solid #336; border-right: 1px solid #336;}
643 #CC th { font-weight: normal;}
644 #CC th a { font-weight: normal; text-decoration: none; color: #FFF; padding: 1px;}
645 #CC td { text-align: center;}
646 #CC .header { background-color: #336;}
647 #CC .weekday { background-color: #DDD; color: #000;}
648 #CC .weekend { background-color: #FFC; color: #000;}
649 #CC .current { border: 1px solid #339; background-color: #336; color: #FFF;}
650 #CC .weekday,#CC .weekend,#CC .current { display: block; text-decoration: none; border: 1px solid #FFF; width: 2em;}
651 #CC .weekday:hover,#CC .weekend:hover,#CC .current:hover { color: #FFF; background-color: #336; border: 1px solid #999;}
652 #CC .previous { text-align: left;}
653 #CC .next { text-align: right;}
654 #CC .previous,#CC .next { padding: 1px 3px 1px 3px; font-size: 1.4em;}
655 #CC .previous a,#CC .next a { color: #FFF; text-decoration: none; font-weight: bold;}
656 #CC .title { text-align: center; font-weight: bold; color: #FFF;}
657 #CC .empty { background-color: #CCC; border: 1px solid #FFF;}
660 $js .= "<script type=\"text/javascript\">
662 function positionInfo(object) {
664 this.getElementLeft = getElementLeft;
665 function getElementLeft() {
668 if(typeof(p_elm) == 'object'){
671 elm = document.getElementById(p_elm);
673 while (elm != null) {
675 elm = elm.offsetParent;
679 this.getElementWidth = getElementWidth;
680 function getElementWidth(){
682 if(typeof(p_elm) == 'object'){
685 elm = document.getElementById(p_elm);
687 return parseInt(elm.offsetWidth);
689 this.getElementRight = getElementRight;
690 function getElementRight(){
691 return getElementLeft(p_elm) + getElementWidth(p_elm);
693 this.getElementTop = getElementTop;
694 function getElementTop() {
697 if(typeof(p_elm) == 'object'){
700 elm = document.getElementById(p_elm);
702 while (elm != null) {
704 elm = elm.offsetParent;
708 this.getElementHeight = getElementHeight;
709 function getElementHeight(){
711 if(typeof(p_elm) == 'object'){
714 elm = document.getElementById(p_elm);
716 return parseInt(elm.offsetHeight);
718 this.getElementBottom = getElementBottom;
719 function getElementBottom(){
720 return getElementTop(p_elm) + getElementHeight(p_elm);
724 var calendarId = 'CC';
726 var currentMonth = 0;
728 var selectedYear = 0;
729 var selectedMonth = 0;
731 var months = ['$months[0]','$months[1]','$months[2]','$months[3]','$months[4]','$months[5]','$months[6]','$months[7]','$months[8]','$months[9]','$months[10]','$months[11]'];
732 var wdays = ['$wdays[0]', '$wdays[1]', '$wdays[2]', '$wdays[3]', '$wdays[4]', '$wdays[5]', '$wdays[6]'];
733 var dateField = null;
734 function getProperty(p_property){
735 var p_elm = calendarId;
737 if(typeof(p_elm) == 'object'){
740 elm = document.getElementById(p_elm);
746 return elm[p_property];
755 function setElementProperty(p_property, p_value, p_elmId){
758 if(typeof(p_elm) == 'object'){
761 elm = document.getElementById(p_elm);
763 if((elm != null) && (elm.style != null)){
765 elm[ p_property ] = p_value;
768 function setProperty(p_property, p_value) {
769 setElementProperty(p_property, p_value, calendarId);
771 function getDaysInMonth(year, month) {
773 if ($date_system == 1)
775 return [31,31,31,31,31,31,30,30,30,30,30,(((((((year - ((year > 0) ? 474 : 473)) % 2820) + 474) + 38) * 682) % 2816) < 682 ? 30 : 29)][month-1];
777 else if ($date_system == 2)
779 return [30,29,30,29,30,29,30,29,30,29,30,(((((11 * year) + 14) % 30) < 11) ? 30 : 29)][month-1];
783 return [31,((!(year % 4 ) && ( (year % 100 ) || !( year % 400 ) ))?29:28),31,30,31,30,31,31,30,31,30,31][month-1];
787 function getDayOfWeek(year, month, day) {
789 if ($date_system == 1 || $date_system == 2)
794 return a - (b * Math.floor(a / b));
798 return mod(Math.floor((j + 1.5)), 7);
801 if ($date_system == 1)
803 var epbase, epyear, t;
804 epbase = year - ((year >= 0) ? 474 : 473);
805 epyear = 474 + mod(epbase, 2820);
806 t = day + ((month <= 7) ? ((month - 1) * 31) : (((month - 1) * 30) + 6)) +
807 Math.floor(((epyear * 682) - 110) / 2816) + (epyear - 1) * 365 +
808 Math.floor(epbase / 2820) * 1029983 + (1948320.5 - 1);
810 else if ($date_system == 2)
813 t = Math.floor((11 * year + 3) / 30) + 354 * year + 30 * month -
814 Math.floor((month - 1) / 2) + day + 1948440 - 385;
822 var date = new Date(year,month-1,day)
823 return date.getDay();
827 this.clearDate = clearDate;
828 function clearDate() {
829 dateField.value = '';
832 this.setDate = setDate;
833 function setDate(year, month, day) {
835 if (month < 10) {month = '0' + month;}
836 if (day < 10) {day = '0' + day;}
840 var dateString = month+'$sep'+day+'$sep'+year;
844 var dateString = day+'$sep'+month+'$sep'+year;
848 var dateString = year+'$sep'+month+'$sep'+day;
851 dateField.value = dateString;
856 this.changeMonth = changeMonth;
857 function changeMonth(change) {
858 currentMonth += change;
860 if(currentMonth > 12) {
863 } else if(currentMonth < 1) {
867 calendar = document.getElementById(calendarId);
868 calendar.innerHTML = calendarDrawTable();
870 this.changeYear = changeYear;
871 function changeYear(change) {
872 currentYear += change;
874 calendar = document.getElementById(calendarId);
875 calendar.innerHTML = calendarDrawTable();
877 function getCurrentYear() {
878 var year = new Date().getYear();
879 if(year < 1900) year += 1900;
882 function getCurrentMonth() {
883 return new Date().getMonth() + 1;
885 function getCurrentDay() {
886 return new Date().getDate();
888 function calendarDrawTable() {
890 var wstart = $wstart;
892 var startDayOfWeek = getDayOfWeek(currentYear, currentMonth, dayOfMonth);
893 var daysInMonth = getDaysInMonth(currentYear, currentMonth);
894 var css_class = null; //CSS class for each day
895 var table = \"<table cellspacing='0' cellpadding='0' border='0'>\";
896 table += \"<tr class='header'>\";
897 table += \" <td colspan='2' class='previous'><a href='javascript:changeCCMonth(-1);'><</a><br><a href='javascript:changeCCYear(-1);'>«</a></td>\";
898 table += \" <td colspan='3' class='title'>\" + months[currentMonth-1] + \"<br>\" + currentYear + \"</td>\";
899 table += \" <td colspan='2' class='next'><a href='javascript:changeCCMonth(1);'>></a><br><a href='javascript:changeCCYear(1);'>»</a></td>\";
902 for (var n=0; n<7; n++)
903 table += \"<th>\" + wdays[(wstart+n)%7]+\"</th>\";
905 for(var week=0; week < 6; week++) {
907 for(var n=0; n < 7; n++) {
908 dayOfWeek = (wstart+n)%7;
909 if(week == 0 && startDayOfWeek == dayOfWeek) {
911 } else if (validDay == 1 && dayOfMonth > daysInMonth) {
915 if (dayOfMonth == selectedDay && currentYear == selectedYear && currentMonth == selectedMonth) {
916 css_class = 'current';
918 if ($date_system == 1 || $date_system == 2)
920 } else if (dayOfWeek == 5) {
924 } else if (dayOfWeek == 0 || dayOfWeek == 6) {
927 css_class = 'weekend';
929 css_class = 'weekday';
931 table += \"<td><a class='\"+css_class+\"' href=\\\"javascript:setCCDate(\"+currentYear+\",\"+currentMonth+\",\"+dayOfMonth+\")\\\">\"+dayOfMonth+\"</a></td>\";
934 table += \"<td class='empty'> </td>\";
939 table += \"<tr class='header'><th colspan='7' style='padding: 3px;'><a href='javascript:hideCC();'>$back</a></td></tr>\";
940 table += \"</table>\";
944 function show(field) {
946 if (dateField == field) {
953 var dateString = new String(dateField.value);
954 var dateParts = dateString.split('$sep');
958 selectedMonth = parseInt(dateParts[0],10);
959 selectedDay = parseInt(dateParts[1],10);
960 selectedYear = parseInt(dateParts[2],10);
964 selectedDay = parseInt(dateParts[0],10);
965 selectedMonth = parseInt(dateParts[1],10);
966 selectedYear = parseInt(dateParts[2],10);
970 selectedYear = parseInt(dateParts[0],10);
971 selectedMonth = parseInt(dateParts[1],10);
972 selectedDay = parseInt(dateParts[2],10);
977 if (!(selectedYear && selectedMonth && selectedDay)) {
979 if ($date_system == 1 || $date_system == 2)
982 selectedMonth = $cmon;
984 selectedYear = $cyear;
990 selectedMonth = getCurrentMonth();
991 selectedDay = getCurrentDay();
992 selectedYear = getCurrentYear();
997 currentMonth = selectedMonth;
998 currentDay = selectedDay;
999 currentYear = selectedYear;
1000 if(document.getElementById){
1001 calendar = document.getElementById(calendarId);
1002 calendar.innerHTML = calendarDrawTable(currentYear, currentMonth);
1003 setProperty('display', 'block');
1004 var fieldPos = new positionInfo(dateField);
1005 var calendarPos = new positionInfo(calendarId);
1006 var x = fieldPos.getElementLeft();
1007 var y = fieldPos.getElementBottom();
1008 setProperty('left', x + 'px');
1009 setProperty('top', y + 'px');
1011 setElementProperty('display', 'block', 'CCIframe');
1012 setElementProperty('left', x + 'px', 'CCIframe');
1013 setElementProperty('top', y + 'px', 'CCIframe');
1014 setElementProperty('width', calendarPos.getElementWidth() + 'px', 'CCIframe');
1015 setElementProperty('height', calendarPos.getElementHeight() + 'px', 'CCIframe');
1022 setProperty('display', 'none');
1023 setElementProperty('display', 'none', 'CCIframe');
1027 this.visible = visible;
1028 function visible() {
1031 this.can_hide = can_hide;
1035 function date_picker(textField) {
1043 function setCCDate(year, month, day) {
1044 cC.setDate(year, month, day);
1046 function changeCCYear(change) {
1047 cC.changeYear(change);
1049 function changeCCMonth(change) {
1050 cC.changeMonth(change);
1052 document.write(\"<iframe id='CCIframe' src='javascript:false;' frameBorder='0' scrolling='no'></iframe>\");
1053 document.write(\"<div id='CC'></div>\");
1060 function alert($msg)
1062 echo "\n<script type=\"text/javascript\">\n"
1064 . "alert('$msg');\n"
1069 if (!function_exists('_vd'))
1071 function _vd($mixed, $title = '', $exit = false)
1073 // Only the site admin is able to proceed here.
1074 echo (!empty($title) ? ($title .':') : '') .'<pre>';