3 include_once($path_to_root . "/admin/db/voiding_db.inc");
4 include_once($path_to_root . "/includes/types.inc");
6 //--------------------------------------------------------------------------------------
8 function get_supplier_trans_view_str($type, $trans_no, $label="")
10 global $path_to_root, $use_popup_windows;
13 if ($type == systypes::po())
14 $viewer = "view_po.php";
16 $viewer = "view_supp_invoice.php";
18 $viewer = "view_supp_credit.php";
20 $viewer = "view_supp_payment.php";
22 $viewer = "view_grn.php";
31 if ($use_popup_windows)
32 $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>";
34 $preview_str = "<a target='_blank' href='$path_to_root/purchasing/view/$viewer?trans_no=$trans_no'>$label</a>";
37 $preview_str = $label;
42 //--------------------------------------------------------------------------------------
44 function get_gl_view_str($type, $trans_no, $label="", $force=false)
46 global $path_to_root, $use_popup_windows;
48 if (!$force && !user_show_gl_info())
53 if ($use_popup_windows)
54 $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>";
56 $gl_view = "<a target='_blank' href='$path_to_root/gl/view/gl_trans_view.php?type_id=$type&trans_no=$trans_no'>$label</a>";
61 //--------------------------------------------------------------------------------------
63 function get_gl_view_str_cell($type, $trans_no, $label="")
65 $str = get_gl_view_str($type, $trans_no, $label);
67 return "<td>$str</td>";
70 //--------------------------------------------------------------------------------------
72 function get_customer_trans_view_str($type, $trans_no, $label="")
74 global $path_to_root, $use_popup_windows;
78 $viewer = "view_invoice.php";
80 $viewer = "view_credit.php";
82 $viewer = "view_receipt.php";
84 $viewer = "view_dispatch.php";
86 $viewer = "view_sales_order.php";
90 if(!is_array($trans_no)) $trans_no = array($trans_no);
94 foreach($trans_no as $trans) {
98 if($preview_str!='') $preview_str .= ',';
102 if ($use_popup_windows)
103 $preview_str .= "<a target='_blank' href='$path_to_root/sales/view/$viewer?trans_no=$trans' onclick=\"javascript:openWindow(this.href,this.target); return false;\" >$lbl</a>";
105 $preview_str .= "<a target='_blank' href='$path_to_root/sales/view/$viewer?trans_no=$trans'>$lbl</a>";
108 $preview_str .= $lbl;
114 //--------------------------------------------------------------------------------------
116 function get_banking_trans_view_str($type, $trans_no, $label="")
118 global $path_to_root, $use_popup_windows;
123 $viewer = "bank_transfer_view.php";
125 $viewer = "gl_payment_view.php";
127 $viewer = "gl_deposit_view.php";
138 if ($use_popup_windows)
139 $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>";
141 $preview_str = "<a target='_blank' href='$path_to_root/gl/view/$viewer?trans_no=$trans_no'>$label</a>";
144 $preview_str = $label;
149 //--------------------------------------------------------------------------------------
151 function get_inventory_trans_view_str($type, $trans_no, $label="")
153 global $path_to_root, $use_popup_windows;
157 if ($type == systypes::inventory_adjustment())
158 $viewer = "view_adjustment.php";
159 elseif ($type == systypes::location_transfer())
160 $viewer = "view_transfer.php";
169 if ($use_popup_windows)
170 $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>";
172 $preview_str = "<a target='_blank' href='$path_to_root/inventory/view/$viewer?trans_no=$trans_no'>$label</a>";
175 $preview_str = $label;
180 //--------------------------------------------------------------------------------------
182 function get_manufacturing_trans_view_str($type, $trans_no, $label="")
184 global $path_to_root, $use_popup_windows;
189 $viewer = "wo_issue_view.php";
191 $viewer = "wo_production_view.php";
192 elseif ($type == systypes::work_order())
193 $viewer = "work_order_view.php";
202 if ($use_popup_windows)
203 $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>";
205 $preview_str = "<a target='_blank' href='$path_to_root/manufacturing/view/$viewer?trans_no=$trans_no'>$label</a>";
208 $preview_str = $label;
213 //--------------------------------------------------------------------------------------
215 function get_dimensions_trans_view_str($type, $trans_no, $label="")
217 global $path_to_root, $use_popup_windows;
222 $viewer = "view_dimension.php";
231 if ($use_popup_windows)
232 $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>";
234 $preview_str = "<a target='_blank' href='$path_to_root/dimensions/view/$viewer?trans_no=$trans_no'>$label</a>";
237 $preview_str = $label;
242 //--------------------------------------------------------------------------------------
244 function get_trans_view_str($type, $trans_no, $label="")
246 $view_str = get_customer_trans_view_str($type, $trans_no, $label);
247 if ($view_str != null)
250 $view_str = get_supplier_trans_view_str($type, $trans_no, $label);
251 if ($view_str != null)
254 $view_str = get_banking_trans_view_str($type, $trans_no, $label);
255 if ($view_str != null)
258 $view_str = get_inventory_trans_view_str($type, $trans_no, $label);
259 if ($view_str != null)
262 $view_str = get_manufacturing_trans_view_str($type, $trans_no, $label);
263 if ($view_str != null)
266 $view_str = get_dimensions_trans_view_str($type, $trans_no, $label);
267 if ($view_str != null)
273 //--------------------------------------------------------------------------------------
274 // Displays currency exchange rate for given date.
275 // When there is no exrate for today,
276 // gets it form ECB and stores in local database.
278 function exchange_rate_display($from_currency, $to_currency, $date_, $edit_rate=false)
282 if ($from_currency != $to_currency)
284 $comp_currency = get_company_currency();
285 if ($from_currency == $comp_currency)
286 $currency = $to_currency;
288 $currency = $from_currency;
290 if ($date_ == Today()) {
291 $rate = get_date_exchange_rate($currency, $date_);
293 $rate = get_ecb_rate($currency);
295 add_exchange_rate($currency, $date_, $rate, $rate);
299 $rate = get_exchange_rate_from_home_currency($currency, $date_);
300 if ($from_currency != $comp_currency)
301 $rate = 1 / ($rate / get_exchange_rate_from_home_currency($to_currency, $date_));
303 $rate = number_format2($rate, user_exrate_dec());
305 text_row(_("Exchange Rate:"), '_ex_rate', $rate, 8, 8, null, "", " $from_currency = 1 $to_currency");
307 label_row(_("Exchange Rate:"),"<span id='_ex_rate'>$rate</span> $from_currency = 1 $to_currency" );
308 $Ajax->addUpdate('_ex_rate','_ex_rate', $rate);
312 //--------------------------------------------------------------------------------------
314 function is_voided_display($type, $id, $label)
317 $void_entry = get_voided_entry($type, $id);
319 if ($void_entry == null)
322 start_table("width=50% $table_style");
323 echo "<tr><td align=center><font color=red>$label</font><br>";
324 echo "<font color=red>" . _("Date Voided:") . " " . sql2date($void_entry["date_"]) . "</font><br>";
325 if (strlen($void_entry["memo_"]) > 0)
326 echo "<center><font color=red>" . _("Memo:") . " " . $void_entry["memo_"] . "</font></center><br>";
333 //--------------------------------------------------------------------------------------
335 function comments_display_row($type, $id)
337 $comments = get_comments($type, $id);
338 if ($comments and db_num_rows($comments))
340 echo "<tr><td colspan=15>";
341 while ($comment = db_fetch($comments))
343 echo $comment["memo_"] . "<br>";
349 //--------------------------------------------------------------------------------------
351 function get_comments_string($type, $type_no)
354 $result = get_comments($type, $type_no);
355 while ($comment = db_fetch($result))
357 if (strlen($str_return))
358 $str_return = $str_return . " \n";
359 $str_return = $str_return . $comment["memo_"];
364 //--------------------------------------------------------------------------------------
366 function view_stock_status($stock_id, $description=null)
368 global $path_to_root;
370 //hyperlink_params_separate($path_to_root . "/inventory/inquiry/stock_status.php", (user_show_codes()?$stock_id . " - ":"") . $description, "stock_id=$stock_id");
371 $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>";
373 //hyperlink_params_separate($path_to_root . "/inventory/inquiry/stock_status.php", $stock_id, "stock_id=$stock_id");
374 $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>";
378 function view_stock_status_cell($stock_id, $description=null)
381 view_stock_status($stock_id, $description);
385 //--------------------------------------------------------------------------------------
387 function display_debit_or_credit_cells($value)
397 amount_cell(abs($value));
407 //--------------------------------------------------------------------------------------
409 function display_customer_trans_tax_details($tax_items, $columns)
411 while ($tax_item = db_fetch($tax_items))
413 $tax = number_format2($tax_item['amount'],user_price_dec());
414 if ($tax_item['included_in_price'])
415 label_row(_("Included") . " " . $tax_item['tax_type_name'] . " (" . $tax_item['rate'] . "%) " .
416 _("Amount") . ": $tax", "", "colspan=$columns align=right", "align=right");
418 label_row($tax_item['tax_type_name'] . " (" . $tax_item['rate'] . "%)",
419 $tax, "colspan=$columns align=right", "align=right");
423 //--------------------------------------------------------------------------------------
425 function display_supp_trans_tax_details($tax_items, $columns)
427 while ($tax_item = db_fetch($tax_items))
429 $tax = number_format2(abs($tax_item['amount']),user_price_dec());
430 if ($tax_item['included_in_price'])
431 label_row(_("Included") . " " . $tax_item['tax_type_name'] . " (" . $tax_item['rate'] . "%) " .
432 _("Amount:") . ": $tax", "colspan=$columns align=right", "align=right");
434 label_row($tax_item['tax_type_name'] . " (" . $tax_item['rate'] . "%)",
435 $tax, "colspan=$columns align=right", "align=right");
439 //--------------------------------------------------------------------------------------
441 function display_edit_tax_items($taxes, $columns, $tax_included, $leftspan=0)
445 foreach ($taxes as $taxitem)
449 label_row(_("Included") . " " . $taxitem['tax_type_name'] . " (" . $taxitem['rate'] . "%) " .
450 _("Amount:") . " " . number_format2($taxitem['Value'],user_price_dec()), "", "colspan=$columns align=right", "align=right",$leftspan);
454 label_row($taxitem['tax_type_name'] . " (" . $taxitem['rate'] . "%)",
455 number_format2($taxitem['Value'],user_price_dec()), "colspan=$columns align=right", "align=right",$leftspan);
456 $total += round2($taxitem['Value'], user_price_dec());
463 //--------------------------------------------------------------------------------------
465 function display_footer_exit()
472 //--------------------------------------------------------------------------------------
474 function display_allocations($alloc_result, $total)
478 if (!$alloc_result || db_num_rows($alloc_result) == 0)
481 display_heading2(_("Allocations"));
483 start_table("$table_style width=80%");
485 $th = array( _("Type"), _("Number"), _("Date"), _("Total Amount"),
486 _("Left to Allocate"), _("This Allocation"));
488 $k = $total_allocated = 0;
490 while ($alloc_row = db_fetch($alloc_result))
493 alt_table_row_color($k);
495 label_cell(systypes::name($alloc_row['type']));
496 label_cell(get_trans_view_str($alloc_row['type'],$alloc_row['trans_no']));
497 label_cell(sql2date($alloc_row['tran_date']));
498 $alloc_row['Total'] = round2($alloc_row['Total'], user_price_dec());
499 $alloc_row['amt'] = round2($alloc_row['amt'], user_price_dec());
500 amount_cell($alloc_row['Total']);
501 //amount_cell($alloc_row['Total'] - $alloc_row['PrevAllocs'] - $alloc_row['amt']);
502 amount_cell($alloc_row['Total'] - $alloc_row['amt']);
503 amount_cell($alloc_row['amt']);
506 $total_allocated += $alloc_row['amt'];
509 label_cell(_("Total Allocated:"), "align=right colspan=5");
510 amount_cell($total_allocated);
513 label_cell(_("Left to Allocate:"), "align=right colspan=5");
514 $total = round2($total, user_price_dec());
515 amount_cell($total - $total_allocated);
521 //--------------------------------------------------------------------------------------
523 function display_allocations_from($person_type, $person_id, $type, $type_no, $total)
525 switch ($person_type)
527 case payment_person_types::customer() :
528 $alloc_result = get_allocatable_to_cust_transactions($person_id, $type_no, $type);
529 display_allocations($alloc_result, $total);
531 case payment_person_types::supplier() :
532 $alloc_result = get_allocatable_to_supp_transactions($person_id, $type_no, $type);
533 display_allocations($alloc_result, $total);
538 function get_js_open_window($width, $height)
540 $js = "\n<script type=\"text/javascript\">\n"
542 . "function openWindow(url, title)\n"
544 . " var left = (screen.width - $width) / 2;\n"
545 . " var top = (screen.height - $height) / 2;\n"
546 . " return window.open(url, title, 'width=$width,height=$height,left='+left+',top='+top+',screenX='+left+',screenY='+top+',status=no,scrollbars=yes');\n"
554 Setting focus on element $name in $form.
555 If $form<0 $name is element id.
557 function set_focus($name, $form_no=0) {
559 $Ajax->addFocus(true, $name);
560 $_POST['_focus'] = $name;
563 // Set default focus on first field $name if not set yet
565 function default_focus($name, $form_no=0) {
566 if (!isset($_POST['_focus'])) {
571 function get_js_png_fix()
573 $js = "<script type=\"text/javascript\">\n"
574 . "function fixPNG(myImage)\n"
576 . " var arVersion = navigator.appVersion.split(\"MSIE\")\n"
577 . " var version = parseFloat(arVersion[1])\n"
578 . " if ((version >= 5.5) && (version < 7) && (document.body.filters))\n"
580 . " var imgID = (myImage.id) ? \"id='\" + myImage.id + \"' \" : \"\"\n"
581 . " var imgClass = (myImage.className) ? \"class='\" + myImage.className + \"' \" : \"\"\n"
582 . " var imgTitle = (myImage.title) ?\n"
583 . " \"title='\" + myImage.title + \"' \" : \"title='\" + myImage.alt + \"' \"\n"
584 . " var imgStyle = \"display:inline-block;\" + myImage.style.cssText\n"
585 . " var strNewHTML = \"<span \" + imgID + imgClass + imgTitle\n"
586 . " + \" style=\\\"\" + \"width:\" + myImage.width\n"
587 . " + \"px; height:\" + myImage.height\n"
588 . " + \"px;\" + imgStyle + \";\"\n"
589 . " + \"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader\"\n"
590 . " + \"(src=\'\" + myImage.src + \"\', sizingMethod='scale');\\\"></span>\"\n"
591 . " myImage.outerHTML = strNewHTML\n"
598 function get_js_date_picker()
600 global $comp_path, $go_debug;
601 $fpath = $comp_path.'/'.user_company().'/js_cache/'.'date_picker.js';
604 #CCIframe { display: none; left: 0px; position: absolute; top: 0px; height: 250px; width: 270px; z-index: 99;}
605 #CC { position:absolute; background-color:#FFF; margin:0; padding:0; display:none; z-index: 100;}
606 #CC table { font-family: arial, verdana, helvetica, sans-serif;font-size: 8pt; border-left: 1px solid #336; border-right: 1px solid #336;}
607 #CC th { font-weight: normal; text-align: center;}
608 #CC th a { font-weight: normal; text-decoration: none; color: #FFF; padding: 1px;}
609 #CC td { text-align: center;}
610 #CC .header { background-color: #336;}
611 #CC .weekday { background-color: #DDD; color: #000;}
612 #CC .weekend { background-color: #FFC; color: #000;}
613 #CC .weekno { background-color: #c0daf8; color: #555;}
614 #CC .current { border: 1px solid #339; background-color: #336; color: #FFF;}
615 #CC .weekday,#CC .weekend,#CC .current { display: block; text-decoration: none; border: 1px solid #FFF; width: 2em;}
616 #CC .weekday:hover,#CC .weekend:hover,#CC .current:hover { color: #FFF; background-color: #336; border: 1px solid #999;}
617 #CC .previous { text-align: left;}
618 #CC .next { text-align: right;}
619 #CC .previous,#CC .next { padding: 1px 3px 1px 3px; font-size: 1.4em;}
620 #CC .previous a,#CC .next a { color: #FFF; text-decoration: none; font-weight: bold;}
621 #CC .title { text-align: center; font-weight: bold; color: #FFF;}
622 #CC .empty { background-color: #CCC; border: 1px solid #FFF;}
627 if (!file_exists($fpath) || $go_debug) {
629 global $dateseps, $date_system;
631 $how = user_date_format(); // 0 = us/ca, 1 = eu, au, nz, 2 = jp, sw
632 $sep = $dateseps[user_date_sep()]; // date separator
633 $wstart = (($date_system == 1 || $date_system == 2) ? 6 : ($how == 0 ? 0 : 1)); // weekstart (sun = 0, mon = 1)
634 $months = array(_("January"),_("February"),_("March"),_("April"),_("May"),_("June"),_("July"),_("August"),_("September"),_("October"),_("November"),_("December"));
635 $wdays = array(_("Su"),_("Mo"),_("Tu"),_("We"),_("Th"),_("Fr"),_("Sa"));
636 $wno = _("W"); // week no
638 if ($date_system == 1)
639 list($cyear, $cmon, $cday) = gregorian_to_jalali(date("Y"), date("n"), date("j"));
640 else if ($date_system == 2)
641 list($cyear, $cmon, $cday) = gregorian_to_islamic(date("Y"), date("n"), date("j"));
645 function positionInfo(object) {
647 this.getElementLeft = getElementLeft;
648 function getElementLeft() {
651 if(typeof(p_elm) == 'object'){
654 elm = document.getElementById(p_elm);
656 while (elm != null) {
658 elm = elm.offsetParent;
662 this.getElementWidth = getElementWidth;
663 function getElementWidth(){
665 if(typeof(p_elm) == 'object'){
668 elm = document.getElementById(p_elm);
670 return parseInt(elm.offsetWidth);
672 this.getElementRight = getElementRight;
673 function getElementRight(){
674 return getElementLeft(p_elm) + getElementWidth(p_elm);
676 this.getElementTop = getElementTop;
677 function getElementTop() {
680 if(typeof(p_elm) == 'object'){
683 elm = document.getElementById(p_elm);
685 while (elm != null) {
687 elm = elm.offsetParent;
691 this.getElementHeight = getElementHeight;
692 function getElementHeight(){
694 if(typeof(p_elm) == 'object'){
697 elm = document.getElementById(p_elm);
699 return parseInt(elm.offsetHeight);
701 this.getElementBottom = getElementBottom;
702 function getElementBottom(){
703 return getElementTop(p_elm) + getElementHeight(p_elm);
707 var calendarId = 'CC';
709 var currentMonth = 0;
711 var selectedYear = 0;
712 var selectedMonth = 0;
714 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]'];
715 var wdays = ['$wdays[0]', '$wdays[1]', '$wdays[2]', '$wdays[3]', '$wdays[4]', '$wdays[5]', '$wdays[6]'];
716 var dateField = null;
717 function getProperty(p_property){
718 var p_elm = calendarId;
720 if(typeof(p_elm) == 'object'){
723 elm = document.getElementById(p_elm);
729 return elm[p_property];
738 function setElementProperty(p_property, p_value, p_elmId){
741 if(typeof(p_elm) == 'object'){
744 elm = document.getElementById(p_elm);
746 if((elm != null) && (elm.style != null)){
748 elm[ p_property ] = p_value;
751 function setProperty(p_property, p_value) {
752 setElementProperty(p_property, p_value, calendarId);
754 function getDaysInMonth(year, month) {
756 if ($date_system == 1)
758 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];
760 else if ($date_system == 2)
762 return [30,29,30,29,30,29,30,29,30,29,30,(((((11 * year) + 14) % 30) < 11) ? 30 : 29)][month-1];
766 return [31,((!(year % 4 ) && ( (year % 100 ) || !( year % 400 ) ))?29:28),31,30,31,30,31,31,30,31,30,31][month-1];
770 function getDayOfWeek(year, month, day) {
772 if ($date_system == 1 || $date_system == 2)
777 return a - (b * Math.floor(a / b));
781 return mod(Math.floor((j + 1.5)), 7);
784 if ($date_system == 1)
786 var epbase, epyear, t;
787 epbase = year - ((year >= 0) ? 474 : 473);
788 epyear = 474 + mod(epbase, 2820);
789 t = day + ((month <= 7) ? ((month - 1) * 31) : (((month - 1) * 30) + 6)) +
790 Math.floor(((epyear * 682) - 110) / 2816) + (epyear - 1) * 365 +
791 Math.floor(epbase / 2820) * 1029983 + (1948320.5 - 1);
793 else if ($date_system == 2)
796 t = Math.floor((11 * year + 3) / 30) + 354 * year + 30 * month -
797 Math.floor((month - 1) / 2) + day + 1948440 - 385;
805 var date = new Date(year,month-1,day)
806 return date.getDay();
810 this.clearDate = clearDate;
811 function clearDate() {
812 dateField.value = '';
815 this.getWeek = getWeek;
816 function getWeek(year, month, day) {
821 var date = new Date(year,month-1,day);
822 var D = date.getDay();
824 date.setDate(date.getDate() + (4 - D));
825 var YN = date.getFullYear();
826 var ZBDoCY = Math.floor((date.getTime() - new Date(YN, 0, 1, -6)) / 86400000);
827 var WN = 1 + Math.floor(ZBDoCY / 7);
830 this.setDate = setDate;
831 function setDate(year, month, day) {
833 if (month < 10) {month = '0' + month;}
834 if (day < 10) {day = '0' + day;}
838 var dateString = month+'$sep'+day+'$sep'+year;
842 var dateString = day+'$sep'+month+'$sep'+year;
846 var dateString = year+'$sep'+month+'$sep'+day;
849 dateField.value = dateString;
850 setFocus(dateField.name);
851 if (dateField.className=='searchbox')
857 this.changeMonth = changeMonth;
858 function changeMonth(change) {
859 currentMonth += change;
861 if(currentMonth > 12) {
864 } else if(currentMonth < 1) {
868 calendar = document.getElementById(calendarId);
869 calendar.innerHTML = calendarDrawTable();
871 this.changeYear = changeYear;
872 function changeYear(change) {
873 currentYear += change;
875 calendar = document.getElementById(calendarId);
876 calendar.innerHTML = calendarDrawTable();
878 function getCurrentYear() {
879 var year = new Date().getYear();
880 if(year < 1900) year += 1900;
883 function getCurrentMonth() {
884 return new Date().getMonth() + 1;
886 function getCurrentDay() {
887 return new Date().getDate();
889 function calendarDrawTable() {
891 var wstart = $wstart;
892 var wno = ' $wno ';
894 var startDayOfWeek = getDayOfWeek(currentYear, currentMonth, dayOfMonth);
895 var daysInMonth = getDaysInMonth(currentYear, currentMonth);
896 var css_class = null; //CSS class for each day
897 var table = \"<table cellspacing='0' cellpadding='0' border='0'>\";
898 table += \"<tr class='header'>\";
899 table += \" <td colspan='2' class='previous'><a href='javascript:changeCCMonth(-1);'><</a><br><a href='javascript:changeCCYear(-1);'>«</a></td>\";
900 table += \" <td colspan='4' class='title'>\" + months[currentMonth-1] + \"<br>\" + currentYear + \"</td>\";
901 table += \" <td colspan='2' class='next'><a href='javascript:changeCCMonth(1);'>></a><br><a href='javascript:changeCCYear(1);'>»</a></td>\";
904 table += \"<th class='weekno'>\"+wno+\"</th>\";
905 for (var n=0; n<7; n++)
906 table += \"<th>\" + wdays[(wstart+n)%7]+\"</th>\";
908 for(var week=0; week < 6; week++) {
910 for(var n=0; n < 7; n++) {
911 dayOfWeek = (wstart+n)%7;
912 if(week == 0 && startDayOfWeek == dayOfWeek) {
914 } else if (validDay == 1 && dayOfMonth > daysInMonth) {
919 if (dayOfMonth > daysInMonth)
920 table += \"<td class='empty'> </td>\";
922 table += \"<td class='weekno'>\"+getWeek(currentYear, currentMonth, dayOfMonth)+\"</td>\";
925 if (dayOfMonth == selectedDay && currentYear == selectedYear && currentMonth == selectedMonth) {
926 css_class = 'current';
928 if ($date_system == 1 || $date_system == 2)
930 } else if (dayOfWeek == 5) {
934 } else if (dayOfWeek == 0 || dayOfWeek == 6) {
937 css_class = 'weekend';
939 css_class = 'weekday';
941 table += \"<td><a class='\"+css_class+\"' href=\\\"javascript:setCCDate(\"+currentYear+\",\"+currentMonth+\",\"+dayOfMonth+\")\\\">\"+dayOfMonth+\"</a></td>\";
944 table += \"<td class='empty'> </td>\";
949 table += \"<tr class='header'><th colspan='8' style='padding: 3px;text-align:center;'><a href='javascript:hideCC();'>$back</a></td></tr>\";
950 table += \"</table>\";
954 function show(field) {
956 if (dateField == field) {
963 var dateString = new String(dateField.value);
964 var dateParts = dateString.split('$sep');
968 selectedMonth = parseInt(dateParts[0],10);
969 selectedDay = parseInt(dateParts[1],10);
970 selectedYear = parseInt(dateParts[2],10);
974 selectedDay = parseInt(dateParts[0],10);
975 selectedMonth = parseInt(dateParts[1],10);
976 selectedYear = parseInt(dateParts[2],10);
980 selectedYear = parseInt(dateParts[0],10);
981 selectedMonth = parseInt(dateParts[1],10);
982 selectedDay = parseInt(dateParts[2],10);
987 if (!(selectedYear && selectedMonth && selectedDay)) {
989 if ($date_system == 1 || $date_system == 2)
992 selectedMonth = $cmon;
994 selectedYear = $cyear;
1000 selectedMonth = getCurrentMonth();
1001 selectedDay = getCurrentDay();
1002 selectedYear = getCurrentYear();
1007 currentMonth = selectedMonth;
1008 currentDay = selectedDay;
1009 currentYear = selectedYear;
1010 if(document.getElementById){
1011 calendar = document.getElementById(calendarId);
1012 calendar.innerHTML = calendarDrawTable(currentYear, currentMonth);
1013 var fieldPos = new positionInfo(dateField);
1014 var calendarPos = new positionInfo(calendarId);
1015 var x = fieldPos.getElementLeft();
1016 var y = fieldPos.getElementBottom();
1017 setProperty('left', x + 'px');
1018 setProperty('top', y + 'px');
1019 setProperty('display', 'block');
1021 setElementProperty('left', x + 'px', 'CCIframe');
1022 setElementProperty('top', y + 'px', 'CCIframe');
1023 setElementProperty('width', calendarPos.getElementWidth() + 'px', 'CCIframe');
1024 setElementProperty('height', calendarPos.getElementHeight() + 'px', 'CCIframe');
1025 setElementProperty('display', 'block', 'CCIframe');
1032 setProperty('display', 'none');
1033 setElementProperty('display', 'none', 'CCIframe');
1037 this.visible = visible;
1038 function visible() {
1041 this.can_hide = can_hide;
1045 function date_picker(textField) {
1053 function setCCDate(year, month, day) {
1054 cC.setDate(year, month, day);
1056 function changeCCYear(change) {
1057 cC.changeYear(change);
1059 function changeCCMonth(change) {
1060 cC.changeMonth(change);
1062 document.write(\"<iframe id='CCIframe' src='javascript:false;' frameBorder='0' scrolling='no'></iframe>\");
1063 document.write(\"<div id='CC'></div>\");";
1065 cache_js_file($fpath, $js);
1067 add_js_ufile($fpath);
1072 function alert($msg)
1074 echo "\n<script type=\"text/javascript\">\n"
1076 . "alert('$msg');\n"
1081 if (!function_exists('_vd'))
1083 function _vd($mixed, $title = '', $exit = false)
1085 // Only the site admin is able to proceed here.
1086 echo (!empty($title) ? ($title .':') : '') .'<pre>';