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="")
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 $pars = access_string($label);
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;\"$pars[1]>$pars[0]</a>";
35 $preview_str = $label;
40 //--------------------------------------------------------------------------------------
42 function get_gl_view_str($type, $trans_no, $label="", $force=false)
46 if (!$force && !user_show_gl_info())
51 $pars = access_string($label);
52 $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;\"$pars[1]>$pars[0]</a>";
57 //--------------------------------------------------------------------------------------
59 function get_gl_view_str_cell($type, $trans_no, $label="")
61 $str = get_gl_view_str($type, $trans_no, $label);
63 return "<td>$str</td>";
66 //--------------------------------------------------------------------------------------
68 function get_customer_trans_view_str($type, $trans_no, $label="")
74 $viewer = "view_invoice.php";
76 $viewer = "view_credit.php";
78 $viewer = "view_receipt.php";
80 $viewer = "view_dispatch.php";
82 $viewer = "view_sales_order.php";
86 if(!is_array($trans_no)) $trans_no = array($trans_no);
90 foreach($trans_no as $trans) {
94 if($preview_str!='') $preview_str .= ',';
98 $pars = access_string($lbl);
99 $preview_str = "<a target='_blank' href='$path_to_root/sales/view/$viewer?trans_no=$trans' onclick=\"javascript:openWindow(this.href,this.target); return false;\" $pars[1]>$pars[0]</a>";
102 $preview_str .= $lbl;
108 //--------------------------------------------------------------------------------------
110 function get_banking_trans_view_str($type, $trans_no, $label="")
112 global $path_to_root;
117 $viewer = "bank_transfer_view.php";
119 $viewer = "gl_payment_view.php";
121 $viewer = "gl_deposit_view.php";
132 $pars = access_string($label);
133 $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;\"$pars[1]>$pars[0]</a>";
136 $preview_str = $label;
141 //--------------------------------------------------------------------------------------
143 function get_inventory_trans_view_str($type, $trans_no, $label="")
145 global $path_to_root;
149 if ($type == systypes::inventory_adjustment())
150 $viewer = "view_adjustment.php";
151 elseif ($type == systypes::location_transfer())
152 $viewer = "view_transfer.php";
161 $pars = access_string($label);
162 $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;\"$pars[1]>$pars[0]</a>";
165 $preview_str = $label;
170 //--------------------------------------------------------------------------------------
172 function get_manufacturing_trans_view_str($type, $trans_no, $label="")
174 global $path_to_root;
179 $viewer = "wo_issue_view.php";
181 $viewer = "wo_production_view.php";
182 elseif ($type == systypes::work_order())
183 $viewer = "work_order_view.php";
192 $pars = access_string($label);
193 $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;\"$pars[1]>$pars[0]</a>";
196 $preview_str = $label;
201 //--------------------------------------------------------------------------------------
203 function get_dimensions_trans_view_str($type, $trans_no, $label="")
205 global $path_to_root;
210 $viewer = "view_dimension.php";
219 $pars = access_string($label);
220 $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;\"$pars[1]>$pars[0]</a>";
223 $preview_str = $label;
228 //--------------------------------------------------------------------------------------
230 function get_trans_view_str($type, $trans_no, $label="")
232 $view_str = get_customer_trans_view_str($type, $trans_no, $label);
233 if ($view_str != null)
236 $view_str = get_supplier_trans_view_str($type, $trans_no, $label);
237 if ($view_str != null)
240 $view_str = get_banking_trans_view_str($type, $trans_no, $label);
241 if ($view_str != null)
244 $view_str = get_inventory_trans_view_str($type, $trans_no, $label);
245 if ($view_str != null)
248 $view_str = get_manufacturing_trans_view_str($type, $trans_no, $label);
249 if ($view_str != null)
252 $view_str = get_dimensions_trans_view_str($type, $trans_no, $label);
253 if ($view_str != null)
259 //--------------------------------------------------------------------------------------
260 // Displays currency exchange rate for given date.
261 // When there is no exrate for today,
262 // gets it form ECB and stores in local database.
264 function exchange_rate_display($from_currency, $to_currency, $date_)
268 if ($from_currency != $to_currency)
270 $comp_currency = get_company_currency();
271 if ($from_currency == $comp_currency)
272 $currency = $to_currency;
274 $currency = $from_currency;
276 if ($date_ == Today()) {
277 $rate = get_date_exchange_rate($currency, $date_);
279 $rate = get_ecb_rate($currency);
281 add_exchange_rate($currency, $date_, $rate, $rate);
285 $rate = get_exchange_rate_from_to($to_currency, $from_currency, $date_);
287 if ($from_currency == $comp_currency)
290 $rate = number_format2($rate, user_exrate_dec());
291 label_row(_("Exchange Rate:"),"1 " . $from_currency
292 . " = <span id='_ex_rate'>" . $rate . "</span> " . $to_currency );
293 $Ajax->addUpdate('_ex_rate','_ex_rate', $rate);
297 //--------------------------------------------------------------------------------------
299 function is_voided_display($type, $id, $label)
302 $void_entry = get_voided_entry($type, $id);
304 if ($void_entry == null)
307 start_table("width=50% $table_style");
308 echo "<tr><td align=center><font color=red>$label</font><br>";
309 echo "<font color=red>" . _("Date Voided:") . " " . sql2date($void_entry["date_"]) . "</font><br>";
310 if (strlen($void_entry["memo_"]) > 0)
311 echo "<center><font color=red>" . _("Memo:") . " " . $void_entry["memo_"] . "</font></center><br>";
318 //--------------------------------------------------------------------------------------
320 function comments_display_row($type, $id)
322 $comments = get_comments($type, $id);
323 if ($comments and db_num_rows($comments))
325 echo "<tr><td colspan=15>";
326 while ($comment = db_fetch($comments))
328 echo $comment["memo_"] . "<br>";
334 //--------------------------------------------------------------------------------------
336 function get_comments_string($type, $type_no)
339 $result = get_comments($type, $type_no);
340 while ($comment = db_fetch($result))
342 if (strlen($str_return))
343 $str_return = $str_return . " \n";
344 $str_return = $str_return . $comment["memo_"];
349 //--------------------------------------------------------------------------------------
351 function view_stock_status($stock_id, $description=null)
353 global $path_to_root;
355 //hyperlink_params_separate($path_to_root . "/inventory/inquiry/stock_status.php", (user_show_codes()?$stock_id . " - ":"") . $description, "stock_id=$stock_id");
356 $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>";
358 //hyperlink_params_separate($path_to_root . "/inventory/inquiry/stock_status.php", $stock_id, "stock_id=$stock_id");
359 $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>";
363 function view_stock_status_cell($stock_id, $description=null)
366 view_stock_status($stock_id, $description);
370 //--------------------------------------------------------------------------------------
372 function display_debit_or_credit_cells($value)
382 amount_cell(abs($value));
392 //--------------------------------------------------------------------------------------
394 function display_customer_trans_tax_details($tax_items, $columns)
396 while ($tax_item = db_fetch($tax_items))
398 $tax = number_format2($tax_item['amount'],user_price_dec());
399 if ($tax_item['included_in_price'])
400 label_row(_("Included") . " " . $tax_item['tax_type_name'] . " (" . $tax_item['rate'] . "%) " .
401 _("Amount") . ": $tax", "", "colspan=$columns align=right", "align=right");
403 label_row($tax_item['tax_type_name'] . " (" . $tax_item['rate'] . "%)",
404 $tax, "colspan=$columns align=right", "align=right");
408 //--------------------------------------------------------------------------------------
410 function display_supp_trans_tax_details($tax_items, $columns)
412 while ($tax_item = db_fetch($tax_items))
414 $tax = number_format2(abs($tax_item['amount']),user_price_dec());
415 if ($tax_item['included_in_price'])
416 label_row(_("Included") . " " . $tax_item['tax_type_name'] . " (" . $tax_item['rate'] . "%) " .
417 _("Amount:") . ": $tax", "colspan=$columns align=right", "align=right");
419 label_row($tax_item['tax_type_name'] . " (" . $tax_item['rate'] . "%)",
420 $tax, "colspan=$columns align=right", "align=right");
424 //--------------------------------------------------------------------------------------
426 function display_edit_tax_items($taxes, $columns, $tax_included, $leftspan=0)
430 foreach ($taxes as $taxitem)
434 label_row(_("Included") . " " . $taxitem['tax_type_name'] . " (" . $taxitem['rate'] . "%) " .
435 _("Amount:") . " " . number_format2($taxitem['Value'],user_price_dec()), "", "colspan=$columns align=right", "align=right",$leftspan);
439 label_row($taxitem['tax_type_name'] . " (" . $taxitem['rate'] . "%)",
440 number_format2($taxitem['Value'],user_price_dec()), "colspan=$columns align=right", "align=right",$leftspan);
441 $total += $taxitem['Value'];
448 //--------------------------------------------------------------------------------------
450 function display_footer_exit()
457 //--------------------------------------------------------------------------------------
459 function display_allocations($alloc_result, $total)
463 if (!$alloc_result || db_num_rows($alloc_result) == 0)
466 display_heading2(_("Allocations"));
468 start_table("$table_style width=80%");
470 $th = array( _("Type"), _("Number"), _("Date"), _("Total Amount"),
471 _("Left to Allocate"), _("This Allocation"));
473 $k = $total_allocated = 0;
475 while ($alloc_row = db_fetch($alloc_result))
478 alt_table_row_color($k);
480 label_cell(systypes::name($alloc_row['type']));
481 label_cell(get_trans_view_str($alloc_row['type'],$alloc_row['trans_no']));
482 label_cell(sql2date($alloc_row['tran_date']));
483 amount_cell($alloc_row['Total']);
484 //amount_cell($alloc_row['Total'] - $alloc_row['PrevAllocs'] - $alloc_row['amt']);
485 amount_cell($alloc_row['Total'] - $alloc_row['amt']);
486 amount_cell($alloc_row['amt']);
489 $total_allocated += $alloc_row['amt'];
492 label_cell(_("Total Allocated:"), "align=right colspan=5");
493 amount_cell($total_allocated);
496 label_cell(_("Left to Allocate:"), "align=right colspan=5");
497 amount_cell($total - $total_allocated);
503 //--------------------------------------------------------------------------------------
505 function display_allocations_from($person_type, $person_id, $type, $type_no, $total)
507 switch ($person_type)
509 case payment_person_types::customer() :
510 $alloc_result = get_allocatable_to_cust_transactions($person_id, $type_no, $type);
511 display_allocations($alloc_result, $total);
513 case payment_person_types::supplier() :
514 $alloc_result = get_allocatable_to_supp_transactions($person_id, $type_no, $type);
515 display_allocations($alloc_result, $total);
520 function get_js_open_window($width, $height)
522 $js = "\n<script type=\"text/javascript\">\n"
524 . "function openWindow(url, title)\n"
526 . " var left = (screen.width - $width) / 2;\n"
527 . " var top = (screen.height - $height) / 2;\n"
528 . " return window.open(url, title, 'width=$width,height=$height,left='+left+',top='+top+',screenX='+left+',screenY='+top+',status=no,scrollbars=yes');\n"
536 Setting focus on element $name in $form.
537 If $form<0 $name is element id.
539 function set_focus($name, $form_no=0) {
541 $Ajax->addFocus(true, $name);
542 $_POST['_focus'] = $name;
545 // Set default focus on first field $name if not set yet
547 function default_focus($name, $form_no=0) {
548 if (!isset($_POST['_focus'])) {
553 function get_js_png_fix()
555 $js = "<script type=\"text/javascript\">\n"
556 . "function fixPNG(myImage)\n"
558 . " var arVersion = navigator.appVersion.split(\"MSIE\")\n"
559 . " var version = parseFloat(arVersion[1])\n"
560 . " if ((version >= 5.5) && (version < 7) && (document.body.filters))\n"
562 . " var imgID = (myImage.id) ? \"id='\" + myImage.id + \"' \" : \"\"\n"
563 . " var imgClass = (myImage.className) ? \"class='\" + myImage.className + \"' \" : \"\"\n"
564 . " var imgTitle = (myImage.title) ?\n"
565 . " \"title='\" + myImage.title + \"' \" : \"title='\" + myImage.alt + \"' \"\n"
566 . " var imgStyle = \"display:inline-block;\" + myImage.style.cssText\n"
567 . " var strNewHTML = \"<span \" + imgID + imgClass + imgTitle\n"
568 . " + \" style=\\\"\" + \"width:\" + myImage.width\n"
569 . " + \"px; height:\" + myImage.height\n"
570 . " + \"px;\" + imgStyle + \";\"\n"
571 . " + \"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader\"\n"
572 . " + \"(src=\'\" + myImage.src + \"\', sizingMethod='scale');\\\"></span>\"\n"
573 . " myImage.outerHTML = strNewHTML\n"
580 function get_js_date_picker()
582 global $comp_path, $go_debug;
583 $fpath = $comp_path.'/'.user_company().'/js_cache/'.'date_picker.js';
586 #CCIframe { display: none; left: 0px; position: absolute; top: 0px; height: 250px; width: 270px; z-index: 99;}
587 #CC { position:absolute; background-color:#FFF; margin:0; padding:0; display:none; z-index: 100;}
588 #CC table { font-family: arial, verdana, helvetica, sans-serif;font-size: 8pt; border-left: 1px solid #336; border-right: 1px solid #336;}
589 #CC th { font-weight: normal; text-align: center;}
590 #CC th a { font-weight: normal; text-decoration: none; color: #FFF; padding: 1px;}
591 #CC td { text-align: center;}
592 #CC .header { background-color: #336;}
593 #CC .weekday { background-color: #DDD; color: #000;}
594 #CC .weekend { background-color: #FFC; color: #000;}
595 #CC .weekno { background-color: #c0daf8; color: #555;}
596 #CC .current { border: 1px solid #339; background-color: #336; color: #FFF;}
597 #CC .weekday,#CC .weekend,#CC .current { display: block; text-decoration: none; border: 1px solid #FFF; width: 2em;}
598 #CC .weekday:hover,#CC .weekend:hover,#CC .current:hover { color: #FFF; background-color: #336; border: 1px solid #999;}
599 #CC .previous { text-align: left;}
600 #CC .next { text-align: right;}
601 #CC .previous,#CC .next { padding: 1px 3px 1px 3px; font-size: 1.4em;}
602 #CC .previous a,#CC .next a { color: #FFF; text-decoration: none; font-weight: bold;}
603 #CC .title { text-align: center; font-weight: bold; color: #FFF;}
604 #CC .empty { background-color: #CCC; border: 1px solid #FFF;}
609 if (!file_exists($fpath) || $go_debug) {
611 global $dateseps, $date_system;
613 $how = user_date_format(); // 0 = us/ca, 1 = eu, au, nz, 2 = jp, sw
614 $sep = $dateseps[user_date_sep()]; // date separator
615 $wstart = (($date_system == 1 || $date_system == 2) ? 6 : ($how == 0 ? 0 : 1)); // weekstart (sun = 0, mon = 1)
616 $months = array(_("January"),_("February"),_("March"),_("April"),_("May"),_("June"),_("July"),_("August"),_("September"),_("October"),_("November"),_("December"));
617 $wdays = array(_("Su"),_("Mo"),_("Tu"),_("We"),_("Th"),_("Fr"),_("Sa"));
618 $wno = _("W"); // week no
620 if ($date_system == 1)
621 list($cyear, $cmon, $cday) = gregorian_to_jalali(date("Y"), date("n"), date("j"));
622 else if ($date_system == 2)
623 list($cyear, $cmon, $cday) = gregorian_to_islamic(date("Y"), date("n"), date("j"));
627 function positionInfo(object) {
629 this.getElementLeft = getElementLeft;
630 function getElementLeft() {
633 if(typeof(p_elm) == 'object'){
636 elm = document.getElementById(p_elm);
638 while (elm != null) {
640 elm = elm.offsetParent;
644 this.getElementWidth = getElementWidth;
645 function getElementWidth(){
647 if(typeof(p_elm) == 'object'){
650 elm = document.getElementById(p_elm);
652 return parseInt(elm.offsetWidth);
654 this.getElementRight = getElementRight;
655 function getElementRight(){
656 return getElementLeft(p_elm) + getElementWidth(p_elm);
658 this.getElementTop = getElementTop;
659 function getElementTop() {
662 if(typeof(p_elm) == 'object'){
665 elm = document.getElementById(p_elm);
667 while (elm != null) {
669 elm = elm.offsetParent;
673 this.getElementHeight = getElementHeight;
674 function getElementHeight(){
676 if(typeof(p_elm) == 'object'){
679 elm = document.getElementById(p_elm);
681 return parseInt(elm.offsetHeight);
683 this.getElementBottom = getElementBottom;
684 function getElementBottom(){
685 return getElementTop(p_elm) + getElementHeight(p_elm);
689 var calendarId = 'CC';
691 var currentMonth = 0;
693 var selectedYear = 0;
694 var selectedMonth = 0;
696 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]'];
697 var wdays = ['$wdays[0]', '$wdays[1]', '$wdays[2]', '$wdays[3]', '$wdays[4]', '$wdays[5]', '$wdays[6]'];
698 var dateField = null;
699 function getProperty(p_property){
700 var p_elm = calendarId;
702 if(typeof(p_elm) == 'object'){
705 elm = document.getElementById(p_elm);
711 return elm[p_property];
720 function setElementProperty(p_property, p_value, p_elmId){
723 if(typeof(p_elm) == 'object'){
726 elm = document.getElementById(p_elm);
728 if((elm != null) && (elm.style != null)){
730 elm[ p_property ] = p_value;
733 function setProperty(p_property, p_value) {
734 setElementProperty(p_property, p_value, calendarId);
736 function getDaysInMonth(year, month) {
738 if ($date_system == 1)
740 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];
742 else if ($date_system == 2)
744 return [30,29,30,29,30,29,30,29,30,29,30,(((((11 * year) + 14) % 30) < 11) ? 30 : 29)][month-1];
748 return [31,((!(year % 4 ) && ( (year % 100 ) || !( year % 400 ) ))?29:28),31,30,31,30,31,31,30,31,30,31][month-1];
752 function getDayOfWeek(year, month, day) {
754 if ($date_system == 1 || $date_system == 2)
759 return a - (b * Math.floor(a / b));
763 return mod(Math.floor((j + 1.5)), 7);
766 if ($date_system == 1)
768 var epbase, epyear, t;
769 epbase = year - ((year >= 0) ? 474 : 473);
770 epyear = 474 + mod(epbase, 2820);
771 t = day + ((month <= 7) ? ((month - 1) * 31) : (((month - 1) * 30) + 6)) +
772 Math.floor(((epyear * 682) - 110) / 2816) + (epyear - 1) * 365 +
773 Math.floor(epbase / 2820) * 1029983 + (1948320.5 - 1);
775 else if ($date_system == 2)
778 t = Math.floor((11 * year + 3) / 30) + 354 * year + 30 * month -
779 Math.floor((month - 1) / 2) + day + 1948440 - 385;
787 var date = new Date(year,month-1,day)
788 return date.getDay();
792 this.clearDate = clearDate;
793 function clearDate() {
794 dateField.value = '';
797 this.getWeek = getWeek;
798 function getWeek(year, month, day) {
803 var date = new Date(year,month-1,day);
804 var D = date.getDay();
806 date.setDate(date.getDate() + (4 - D));
807 var YN = date.getFullYear();
808 var ZBDoCY = Math.floor((date.getTime() - new Date(YN, 0, 1, -6)) / 86400000);
809 var WN = 1 + Math.floor(ZBDoCY / 7);
812 this.setDate = setDate;
813 function setDate(year, month, day) {
815 if (month < 10) {month = '0' + month;}
816 if (day < 10) {day = '0' + day;}
820 var dateString = month+'$sep'+day+'$sep'+year;
824 var dateString = day+'$sep'+month+'$sep'+year;
828 var dateString = year+'$sep'+month+'$sep'+day;
831 dateField.value = dateString;
832 setFocus(dateField.name);
833 if (dateField.className=='searchbox')
839 this.changeMonth = changeMonth;
840 function changeMonth(change) {
841 currentMonth += change;
843 if(currentMonth > 12) {
846 } else if(currentMonth < 1) {
850 calendar = document.getElementById(calendarId);
851 calendar.innerHTML = calendarDrawTable();
853 this.changeYear = changeYear;
854 function changeYear(change) {
855 currentYear += change;
857 calendar = document.getElementById(calendarId);
858 calendar.innerHTML = calendarDrawTable();
860 function getCurrentYear() {
861 var year = new Date().getYear();
862 if(year < 1900) year += 1900;
865 function getCurrentMonth() {
866 return new Date().getMonth() + 1;
868 function getCurrentDay() {
869 return new Date().getDate();
871 function calendarDrawTable() {
873 var wstart = $wstart;
874 var wno = ' $wno ';
876 var startDayOfWeek = getDayOfWeek(currentYear, currentMonth, dayOfMonth);
877 var daysInMonth = getDaysInMonth(currentYear, currentMonth);
878 var css_class = null; //CSS class for each day
879 var table = \"<table cellspacing='0' cellpadding='0' border='0'>\";
880 table += \"<tr class='header'>\";
881 table += \" <td colspan='2' class='previous'><a href='javascript:changeCCMonth(-1);'><</a><br><a href='javascript:changeCCYear(-1);'>«</a></td>\";
882 table += \" <td colspan='4' class='title'>\" + months[currentMonth-1] + \"<br>\" + currentYear + \"</td>\";
883 table += \" <td colspan='2' class='next'><a href='javascript:changeCCMonth(1);'>></a><br><a href='javascript:changeCCYear(1);'>»</a></td>\";
886 table += \"<th class='weekno'>\"+wno+\"</th>\";
887 for (var n=0; n<7; n++)
888 table += \"<th>\" + wdays[(wstart+n)%7]+\"</th>\";
890 for(var week=0; week < 6; week++) {
892 for(var n=0; n < 7; n++) {
893 dayOfWeek = (wstart+n)%7;
894 if(week == 0 && startDayOfWeek == dayOfWeek) {
896 } else if (validDay == 1 && dayOfMonth > daysInMonth) {
901 if (dayOfMonth > daysInMonth)
902 table += \"<td class='empty'> </td>\";
904 table += \"<td class='weekno'>\"+getWeek(currentYear, currentMonth, dayOfMonth)+\"</td>\";
907 if (dayOfMonth == selectedDay && currentYear == selectedYear && currentMonth == selectedMonth) {
908 css_class = 'current';
910 if ($date_system == 1 || $date_system == 2)
912 } else if (dayOfWeek == 5) {
916 } else if (dayOfWeek == 0 || dayOfWeek == 6) {
919 css_class = 'weekend';
921 css_class = 'weekday';
923 table += \"<td><a class='\"+css_class+\"' href=\\\"javascript:setCCDate(\"+currentYear+\",\"+currentMonth+\",\"+dayOfMonth+\")\\\">\"+dayOfMonth+\"</a></td>\";
926 table += \"<td class='empty'> </td>\";
931 table += \"<tr class='header'><th colspan='8' style='padding: 3px;text-align:center;'><a href='javascript:hideCC();'>$back</a></td></tr>\";
932 table += \"</table>\";
936 function show(field) {
938 if (dateField == field) {
945 var dateString = new String(dateField.value);
946 var dateParts = dateString.split('$sep');
950 selectedMonth = parseInt(dateParts[0],10);
951 selectedDay = parseInt(dateParts[1],10);
952 selectedYear = parseInt(dateParts[2],10);
956 selectedDay = parseInt(dateParts[0],10);
957 selectedMonth = parseInt(dateParts[1],10);
958 selectedYear = parseInt(dateParts[2],10);
962 selectedYear = parseInt(dateParts[0],10);
963 selectedMonth = parseInt(dateParts[1],10);
964 selectedDay = parseInt(dateParts[2],10);
969 if (!(selectedYear && selectedMonth && selectedDay)) {
971 if ($date_system == 1 || $date_system == 2)
974 selectedMonth = $cmon;
976 selectedYear = $cyear;
982 selectedMonth = getCurrentMonth();
983 selectedDay = getCurrentDay();
984 selectedYear = getCurrentYear();
989 currentMonth = selectedMonth;
990 currentDay = selectedDay;
991 currentYear = selectedYear;
992 if(document.getElementById){
993 calendar = document.getElementById(calendarId);
994 calendar.innerHTML = calendarDrawTable(currentYear, currentMonth);
995 var fieldPos = new positionInfo(dateField);
996 var calendarPos = new positionInfo(calendarId);
997 var x = fieldPos.getElementLeft();
998 var y = fieldPos.getElementBottom();
999 setProperty('left', x + 'px');
1000 setProperty('top', y + 'px');
1001 setProperty('display', 'block');
1003 setElementProperty('left', x + 'px', 'CCIframe');
1004 setElementProperty('top', y + 'px', 'CCIframe');
1005 setElementProperty('width', calendarPos.getElementWidth() + 'px', 'CCIframe');
1006 setElementProperty('height', calendarPos.getElementHeight() + 'px', 'CCIframe');
1007 setElementProperty('display', 'block', 'CCIframe');
1014 setProperty('display', 'none');
1015 setElementProperty('display', 'none', 'CCIframe');
1019 this.visible = visible;
1020 function visible() {
1023 this.can_hide = can_hide;
1027 function date_picker(textField) {
1035 function setCCDate(year, month, day) {
1036 cC.setDate(year, month, day);
1038 function changeCCYear(change) {
1039 cC.changeYear(change);
1041 function changeCCMonth(change) {
1042 cC.changeMonth(change);
1044 document.write(\"<iframe id='CCIframe' src='javascript:false;' frameBorder='0' scrolling='no'></iframe>\");
1045 document.write(\"<div id='CC'></div>\");";
1047 cache_js_file($fpath, $js);
1049 add_js_ufile($fpath);
1054 function alert($msg)
1056 echo "\n<script type=\"text/javascript\">\n"
1058 . "alert('$msg');\n"
1063 if (!function_exists('_vd'))
1065 function _vd($mixed, $title = '', $exit = false)
1067 // Only the site admin is able to proceed here.
1068 echo (!empty($title) ? ($title .':') : '') .'<pre>';