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 //--------------------------------------------------------------------------------------
275 function exchange_rate_display($from_currency, $to_currency, $date_, $buttons=true)
279 if ($from_currency != $to_currency)
281 if ($buttons && isset($_POST['get_rate']))
283 $comp_currency = get_company_currency();
284 if ($from_currency == $comp_currency)
285 $currency = $to_currency;
287 $currency = $from_currency;
288 $rate = get_ecb_rate($currency);
289 if (get_date_exchange_rate($currency, $date_))
290 update_exchange_rate($currency, $date_, $rate, $rate);
292 add_exchange_rate($currency, $date_, $rate, $rate);
293 if ($from_currency == $comp_currency)
295 $Ajax->activate('get_rate');
298 $rate = get_exchange_rate_from_to($to_currency, $from_currency, $date_);
299 $rate = number_format2($rate, user_exrate_dec());
300 label_row(_("Exchange Rate:"),"1 " . $from_currency . " = <span id='_ex_rate'>" . $rate . "</span> " . $to_currency .
301 ($buttons?" " . submit('get_rate',_("Get"), false, true):""));
303 $Ajax->addUpdate('get_rate','_ex_rate', $rate);
308 //--------------------------------------------------------------------------------------
310 function is_voided_display($type, $id, $label)
313 $void_entry = get_voided_entry($type, $id);
315 if ($void_entry == null)
318 start_table("width=50% $table_style");
319 echo "<tr><td align=center><font color=red>$label</font><br>";
320 echo "<font color=red>" . _("Date Voided:") . " " . sql2date($void_entry["date_"]) . "</font><br>";
321 if (strlen($void_entry["memo_"]) > 0)
322 echo "<center><font color=red>" . _("Memo:") . " " . $void_entry["memo_"] . "</font></center><br>";
329 //--------------------------------------------------------------------------------------
331 function comments_display_row($type, $id)
333 $comments = get_comments($type, $id);
334 if ($comments and db_num_rows($comments))
336 echo "<tr><td colspan=15>";
337 while ($comment = db_fetch($comments))
339 echo $comment["memo_"] . "<br>";
345 //--------------------------------------------------------------------------------------
347 function get_comments_string($type, $type_no)
350 $result = get_comments($type, $type_no);
351 while ($comment = db_fetch($result))
353 if (strlen($str_return))
354 $str_return = $str_return . " \n";
355 $str_return = $str_return . $comment["memo_"];
360 //--------------------------------------------------------------------------------------
362 function view_stock_status($stock_id, $description=null)
364 global $path_to_root;
366 //hyperlink_params_separate($path_to_root . "/inventory/inquiry/stock_status.php", (user_show_codes()?$stock_id . " - ":"") . $description, "stock_id=$stock_id");
367 $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>";
369 //hyperlink_params_separate($path_to_root . "/inventory/inquiry/stock_status.php", $stock_id, "stock_id=$stock_id");
370 $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>";
374 function view_stock_status_cell($stock_id, $description=null)
377 view_stock_status($stock_id, $description);
381 //--------------------------------------------------------------------------------------
383 function display_debit_or_credit_cells($value)
393 amount_cell(abs($value));
403 //--------------------------------------------------------------------------------------
405 function display_customer_trans_tax_details($tax_items, $columns)
407 while ($tax_item = db_fetch($tax_items))
409 $tax = number_format2($tax_item['amount'],user_price_dec());
410 if ($tax_item['included_in_price'])
411 label_row(_("Included") . " " . $tax_item['tax_type_name'] . " (" . $tax_item['rate'] . "%) " .
412 _("Amount") . ": $tax", "", "colspan=$columns align=right", "align=right");
414 label_row($tax_item['tax_type_name'] . " (" . $tax_item['rate'] . "%)",
415 $tax, "colspan=$columns align=right", "align=right");
419 //--------------------------------------------------------------------------------------
421 function display_supp_trans_tax_details($tax_items, $columns)
423 while ($tax_item = db_fetch($tax_items))
425 $tax = number_format2(abs($tax_item['amount']),user_price_dec());
426 if ($tax_item['included_in_price'])
427 label_row(_("Included") . " " . $tax_item['tax_type_name'] . " (" . $tax_item['rate'] . "%) " .
428 _("Amount:") . ": $tax", "colspan=$columns align=right", "align=right");
430 label_row($tax_item['tax_type_name'] . " (" . $tax_item['rate'] . "%)",
431 $tax, "colspan=$columns align=right", "align=right");
435 //--------------------------------------------------------------------------------------
437 function display_edit_tax_items($taxes, $columns, $tax_included, $leftspan=0)
441 foreach ($taxes as $taxitem)
445 label_row(_("Included") . " " . $taxitem['tax_type_name'] . " (" . $taxitem['rate'] . "%) " .
446 _("Amount:") . " " . number_format2($taxitem['Value'],user_price_dec()), "", "colspan=$columns align=right", "align=right",$leftspan);
450 label_row($taxitem['tax_type_name'] . " (" . $taxitem['rate'] . "%)",
451 number_format2($taxitem['Value'],user_price_dec()), "colspan=$columns align=right", "align=right",$leftspan);
452 $total += $taxitem['Value'];
459 //--------------------------------------------------------------------------------------
461 function display_footer_exit()
468 //--------------------------------------------------------------------------------------
470 function display_allocations($alloc_result, $total)
474 if (!$alloc_result || db_num_rows($alloc_result) == 0)
477 display_heading2(_("Allocations"));
479 start_table("$table_style width=80%");
481 $th = array( _("Type"), _("Number"), _("Date"), _("Total Amount"),
482 _("Left to Allocate"), _("This Allocation"));
484 $k = $total_allocated = 0;
486 while ($alloc_row = db_fetch($alloc_result))
489 alt_table_row_color($k);
491 label_cell(systypes::name($alloc_row['type']));
492 label_cell(get_trans_view_str($alloc_row['type'],$alloc_row['trans_no']));
493 label_cell(sql2date($alloc_row['tran_date']));
494 amount_cell($alloc_row['Total']);
495 //amount_cell($alloc_row['Total'] - $alloc_row['PrevAllocs'] - $alloc_row['amt']);
496 amount_cell($alloc_row['Total'] - $alloc_row['amt']);
497 amount_cell($alloc_row['amt']);
500 $total_allocated += $alloc_row['amt'];
503 label_cell(_("Total Allocated:"), "align=right colspan=5");
504 amount_cell($total_allocated);
507 label_cell(_("Left to Allocate:"), "align=right colspan=5");
508 amount_cell($total - $total_allocated);
514 //--------------------------------------------------------------------------------------
516 function display_allocations_from($person_type, $person_id, $type, $type_no, $total)
518 switch ($person_type)
520 case payment_person_types::customer() :
521 $alloc_result = get_allocatable_to_cust_transactions($person_id, $type_no, $type);
522 display_allocations($alloc_result, $total);
524 case payment_person_types::supplier() :
525 $alloc_result = get_allocatable_to_supp_transactions($person_id, $type_no, $type);
526 display_allocations($alloc_result, $total);
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"
547 Setting focus on element $name in $form.
548 If $form<0 $name is element id.
550 function set_focus($name, $form_no=0) {
551 $_POST['_focus'] = $name;
554 // Set default focus on first field $name if not set yet
556 function default_focus($name, $form_no=0) {
557 if (!isset($_POST['_focus'])) {
558 $_POST['_focus'] = $name;
562 function get_js_png_fix()
564 $js = "<script type=\"text/javascript\">\n"
565 . "function fixPNG(myImage)\n"
567 . " var arVersion = navigator.appVersion.split(\"MSIE\")\n"
568 . " var version = parseFloat(arVersion[1])\n"
569 . " if ((version >= 5.5) && (version < 7) && (document.body.filters))\n"
571 . " var imgID = (myImage.id) ? \"id='\" + myImage.id + \"' \" : \"\"\n"
572 . " var imgClass = (myImage.className) ? \"class='\" + myImage.className + \"' \" : \"\"\n"
573 . " var imgTitle = (myImage.title) ?\n"
574 . " \"title='\" + myImage.title + \"' \" : \"title='\" + myImage.alt + \"' \"\n"
575 . " var imgStyle = \"display:inline-block;\" + myImage.style.cssText\n"
576 . " var strNewHTML = \"<span \" + imgID + imgClass + imgTitle\n"
577 . " + \" style=\\\"\" + \"width:\" + myImage.width\n"
578 . " + \"px; height:\" + myImage.height\n"
579 . " + \"px;\" + imgStyle + \";\"\n"
580 . " + \"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader\"\n"
581 . " + \"(src=\'\" + myImage.src + \"\', sizingMethod='scale');\\\"></span>\"\n"
582 . " myImage.outerHTML = strNewHTML\n"
589 function get_js_date_picker()
592 $fpath = $comp_path.'/'.user_company().'/js_cache/'.'date_picker.js';
595 #CCIframe { display: none; left: 0px; position: absolute; top: 0px; height: 250px; width: 250px; z-index: 99;}
596 #CC { position:absolute; background-color:#FFF; margin:0; padding:0; display:none; z-index: 100;}
597 #CC table { font-family: arial, verdana, helvetica, sans-serif;font-size: 8pt; border-left: 1px solid #336; border-right: 1px solid #336;}
598 #CC th { font-weight: normal; text-align: center;}
599 #CC th a { font-weight: normal; text-decoration: none; color: #FFF; padding: 1px;}
600 #CC td { text-align: center;}
601 #CC .header { background-color: #336;}
602 #CC .weekday { background-color: #DDD; color: #000;}
603 #CC .weekend { background-color: #FFC; color: #000;}
604 #CC .current { border: 1px solid #339; background-color: #336; color: #FFF;}
605 #CC .weekday,#CC .weekend,#CC .current { display: block; text-decoration: none; border: 1px solid #FFF; width: 2em;}
606 #CC .weekday:hover,#CC .weekend:hover,#CC .current:hover { color: #FFF; background-color: #336; border: 1px solid #999;}
607 #CC .previous { text-align: left;}
608 #CC .next { text-align: right;}
609 #CC .previous,#CC .next { padding: 1px 3px 1px 3px; font-size: 1.4em;}
610 #CC .previous a,#CC .next a { color: #FFF; text-decoration: none; font-weight: bold;}
611 #CC .title { text-align: center; font-weight: bold; color: #FFF;}
612 #CC .empty { background-color: #CCC; border: 1px solid #FFF;}
617 if (!file_exists($fpath)) {
619 global $dateseps, $date_system;
621 $how = user_date_format(); // 0 = us/ca, 1 = eu, au, nz, 2 = jp, sw
622 $sep = $dateseps[user_date_sep()]; // date separator
623 $wstart = (($date_system == 1 || $date_system == 2) ? 6 : ($how == 0 ? 0 : 1)); // weekstart (sun = 0, mon = 1)
624 $months = array(_("January"),_("February"),_("March"),_("April"),_("May"),_("June"),_("July"),_("August"),_("September"),_("October"),_("November"),_("December"));
625 $wdays = array(_("Su"),_("Mo"),_("Tu"),_("We"),_("Th"),_("Fr"),_("Sa"));
627 if ($date_system == 1)
628 list($cyear, $cmon, $cday) = gregorian_to_jalali(date("Y"), date("n"), date("j"));
629 else if ($date_system == 2)
630 list($cyear, $cmon, $cday) = gregorian_to_islamic(date("Y"), date("n"), date("j"));
634 function positionInfo(object) {
636 this.getElementLeft = getElementLeft;
637 function getElementLeft() {
640 if(typeof(p_elm) == 'object'){
643 elm = document.getElementById(p_elm);
645 while (elm != null) {
647 elm = elm.offsetParent;
651 this.getElementWidth = getElementWidth;
652 function getElementWidth(){
654 if(typeof(p_elm) == 'object'){
657 elm = document.getElementById(p_elm);
659 return parseInt(elm.offsetWidth);
661 this.getElementRight = getElementRight;
662 function getElementRight(){
663 return getElementLeft(p_elm) + getElementWidth(p_elm);
665 this.getElementTop = getElementTop;
666 function getElementTop() {
669 if(typeof(p_elm) == 'object'){
672 elm = document.getElementById(p_elm);
674 while (elm != null) {
676 elm = elm.offsetParent;
680 this.getElementHeight = getElementHeight;
681 function getElementHeight(){
683 if(typeof(p_elm) == 'object'){
686 elm = document.getElementById(p_elm);
688 return parseInt(elm.offsetHeight);
690 this.getElementBottom = getElementBottom;
691 function getElementBottom(){
692 return getElementTop(p_elm) + getElementHeight(p_elm);
696 var calendarId = 'CC';
698 var currentMonth = 0;
700 var selectedYear = 0;
701 var selectedMonth = 0;
703 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]'];
704 var wdays = ['$wdays[0]', '$wdays[1]', '$wdays[2]', '$wdays[3]', '$wdays[4]', '$wdays[5]', '$wdays[6]'];
705 var dateField = null;
706 function getProperty(p_property){
707 var p_elm = calendarId;
709 if(typeof(p_elm) == 'object'){
712 elm = document.getElementById(p_elm);
718 return elm[p_property];
727 function setElementProperty(p_property, p_value, p_elmId){
730 if(typeof(p_elm) == 'object'){
733 elm = document.getElementById(p_elm);
735 if((elm != null) && (elm.style != null)){
737 elm[ p_property ] = p_value;
740 function setProperty(p_property, p_value) {
741 setElementProperty(p_property, p_value, calendarId);
743 function getDaysInMonth(year, month) {
745 if ($date_system == 1)
747 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];
749 else if ($date_system == 2)
751 return [30,29,30,29,30,29,30,29,30,29,30,(((((11 * year) + 14) % 30) < 11) ? 30 : 29)][month-1];
755 return [31,((!(year % 4 ) && ( (year % 100 ) || !( year % 400 ) ))?29:28),31,30,31,30,31,31,30,31,30,31][month-1];
759 function getDayOfWeek(year, month, day) {
761 if ($date_system == 1 || $date_system == 2)
766 return a - (b * Math.floor(a / b));
770 return mod(Math.floor((j + 1.5)), 7);
773 if ($date_system == 1)
775 var epbase, epyear, t;
776 epbase = year - ((year >= 0) ? 474 : 473);
777 epyear = 474 + mod(epbase, 2820);
778 t = day + ((month <= 7) ? ((month - 1) * 31) : (((month - 1) * 30) + 6)) +
779 Math.floor(((epyear * 682) - 110) / 2816) + (epyear - 1) * 365 +
780 Math.floor(epbase / 2820) * 1029983 + (1948320.5 - 1);
782 else if ($date_system == 2)
785 t = Math.floor((11 * year + 3) / 30) + 354 * year + 30 * month -
786 Math.floor((month - 1) / 2) + day + 1948440 - 385;
794 var date = new Date(year,month-1,day)
795 return date.getDay();
799 this.clearDate = clearDate;
800 function clearDate() {
801 dateField.value = '';
804 this.setDate = setDate;
805 function setDate(year, month, day) {
807 if (month < 10) {month = '0' + month;}
808 if (day < 10) {day = '0' + day;}
812 var dateString = month+'$sep'+day+'$sep'+year;
816 var dateString = day+'$sep'+month+'$sep'+year;
820 var dateString = year+'$sep'+month+'$sep'+day;
823 dateField.value = dateString;
828 this.changeMonth = changeMonth;
829 function changeMonth(change) {
830 currentMonth += change;
832 if(currentMonth > 12) {
835 } else if(currentMonth < 1) {
839 calendar = document.getElementById(calendarId);
840 calendar.innerHTML = calendarDrawTable();
842 this.changeYear = changeYear;
843 function changeYear(change) {
844 currentYear += change;
846 calendar = document.getElementById(calendarId);
847 calendar.innerHTML = calendarDrawTable();
849 function getCurrentYear() {
850 var year = new Date().getYear();
851 if(year < 1900) year += 1900;
854 function getCurrentMonth() {
855 return new Date().getMonth() + 1;
857 function getCurrentDay() {
858 return new Date().getDate();
860 function calendarDrawTable() {
862 var wstart = $wstart;
864 var startDayOfWeek = getDayOfWeek(currentYear, currentMonth, dayOfMonth);
865 var daysInMonth = getDaysInMonth(currentYear, currentMonth);
866 var css_class = null; //CSS class for each day
867 var table = \"<table cellspacing='0' cellpadding='0' border='0'>\";
868 table += \"<tr class='header'>\";
869 table += \" <td colspan='2' class='previous'><a href='javascript:changeCCMonth(-1);'><</a><br><a href='javascript:changeCCYear(-1);'>«</a></td>\";
870 table += \" <td colspan='3' class='title'>\" + months[currentMonth-1] + \"<br>\" + currentYear + \"</td>\";
871 table += \" <td colspan='2' class='next'><a href='javascript:changeCCMonth(1);'>></a><br><a href='javascript:changeCCYear(1);'>»</a></td>\";
874 for (var n=0; n<7; n++)
875 table += \"<th>\" + wdays[(wstart+n)%7]+\"</th>\";
877 for(var week=0; week < 6; week++) {
879 for(var n=0; n < 7; n++) {
880 dayOfWeek = (wstart+n)%7;
881 if(week == 0 && startDayOfWeek == dayOfWeek) {
883 } else if (validDay == 1 && dayOfMonth > daysInMonth) {
887 if (dayOfMonth == selectedDay && currentYear == selectedYear && currentMonth == selectedMonth) {
888 css_class = 'current';
890 if ($date_system == 1 || $date_system == 2)
892 } else if (dayOfWeek == 5) {
896 } else if (dayOfWeek == 0 || dayOfWeek == 6) {
899 css_class = 'weekend';
901 css_class = 'weekday';
903 table += \"<td><a class='\"+css_class+\"' href=\\\"javascript:setCCDate(\"+currentYear+\",\"+currentMonth+\",\"+dayOfMonth+\")\\\">\"+dayOfMonth+\"</a></td>\";
906 table += \"<td class='empty'> </td>\";
911 table += \"<tr class='header'><th colspan='7' style='padding: 3px;text-align:center;'><a href='javascript:hideCC();'>$back</a></td></tr>\";
912 table += \"</table>\";
916 function show(field) {
918 if (dateField == field) {
925 var dateString = new String(dateField.value);
926 var dateParts = dateString.split('$sep');
930 selectedMonth = parseInt(dateParts[0],10);
931 selectedDay = parseInt(dateParts[1],10);
932 selectedYear = parseInt(dateParts[2],10);
936 selectedDay = parseInt(dateParts[0],10);
937 selectedMonth = parseInt(dateParts[1],10);
938 selectedYear = parseInt(dateParts[2],10);
942 selectedYear = parseInt(dateParts[0],10);
943 selectedMonth = parseInt(dateParts[1],10);
944 selectedDay = parseInt(dateParts[2],10);
949 if (!(selectedYear && selectedMonth && selectedDay)) {
951 if ($date_system == 1 || $date_system == 2)
954 selectedMonth = $cmon;
956 selectedYear = $cyear;
962 selectedMonth = getCurrentMonth();
963 selectedDay = getCurrentDay();
964 selectedYear = getCurrentYear();
969 currentMonth = selectedMonth;
970 currentDay = selectedDay;
971 currentYear = selectedYear;
972 if(document.getElementById){
973 calendar = document.getElementById(calendarId);
974 calendar.innerHTML = calendarDrawTable(currentYear, currentMonth);
975 setProperty('display', 'block');
976 var fieldPos = new positionInfo(dateField);
977 var calendarPos = new positionInfo(calendarId);
978 var x = fieldPos.getElementLeft();
979 var y = fieldPos.getElementBottom();
980 setProperty('left', x + 'px');
981 setProperty('top', y + 'px');
983 setElementProperty('display', 'block', 'CCIframe');
984 setElementProperty('left', x + 'px', 'CCIframe');
985 setElementProperty('top', y + 'px', 'CCIframe');
986 setElementProperty('width', calendarPos.getElementWidth() + 'px', 'CCIframe');
987 setElementProperty('height', calendarPos.getElementHeight() + 'px', 'CCIframe');
994 setProperty('display', 'none');
995 setElementProperty('display', 'none', 'CCIframe');
999 this.visible = visible;
1000 function visible() {
1003 this.can_hide = can_hide;
1007 function date_picker(textField) {
1015 function setCCDate(year, month, day) {
1016 cC.setDate(year, month, day);
1018 function changeCCYear(change) {
1019 cC.changeYear(change);
1021 function changeCCMonth(change) {
1022 cC.changeMonth(change);
1024 document.write(\"<iframe id='CCIframe' src='javascript:false;' frameBorder='0' scrolling='no'></iframe>\");
1025 document.write(\"<div id='CC'></div>\");";
1027 cache_js_file($fpath, $js);
1029 add_js_ufile($fpath);
1034 function alert($msg)
1036 echo "\n<script type=\"text/javascript\">\n"
1038 . "alert('$msg');\n"
1043 if (!function_exists('_vd'))
1045 function _vd($mixed, $title = '', $exit = false)
1047 // Only the site admin is able to proceed here.
1048 echo (!empty($title) ? ($title .':') : '') .'<pre>';