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_dispatch.php";
85 $viewer = "view_sales_order.php";
89 if(!is_array($trans_no)) $trans_no = array($trans_no);
93 foreach($trans_no as $trans) {
97 if($preview_str!='') $preview_str .= ',';
101 if ($use_popup_windows)
102 $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>";
104 $preview_str .= "<a target='_blank' href='$path_to_root/sales/view/$viewer?trans_no=$trans'>$lbl</a>";
107 $preview_str .= $lbl;
113 //--------------------------------------------------------------------------------------
115 function get_banking_trans_view_str($type, $trans_no, $label="")
117 global $path_to_root, $use_popup_windows;
122 $viewer = "bank_transfer_view.php";
124 $viewer = "gl_payment_view.php";
126 $viewer = "gl_deposit_view.php";
137 if ($use_popup_windows)
138 $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>";
140 $preview_str = "<a target='_blank' href='$path_to_root/gl/view/$viewer?trans_no=$trans_no'>$label</a>";
143 $preview_str = $label;
148 //--------------------------------------------------------------------------------------
150 function get_inventory_trans_view_str($type, $trans_no, $label="")
152 global $path_to_root, $use_popup_windows;
156 if ($type == systypes::inventory_adjustment())
157 $viewer = "view_adjustment.php";
158 elseif ($type == systypes::location_transfer())
159 $viewer = "view_transfer.php";
168 if ($use_popup_windows)
169 $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>";
171 $preview_str = "<a target='_blank' href='$path_to_root/inventory/view/$viewer?trans_no=$trans_no'>$label</a>";
174 $preview_str = $label;
179 //--------------------------------------------------------------------------------------
181 function get_manufacturing_trans_view_str($type, $trans_no, $label="")
183 global $path_to_root, $use_popup_windows;
188 $viewer = "wo_issue_view.php";
190 $viewer = "wo_production_view.php";
191 elseif ($type == systypes::work_order())
192 $viewer = "work_order_view.php";
201 if ($use_popup_windows)
202 $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>";
204 $preview_str = "<a target='_blank' href='$path_to_root/manufacturing/view/$viewer?trans_no=$trans_no'>$label</a>";
207 $preview_str = $label;
212 //--------------------------------------------------------------------------------------
214 function get_dimensions_trans_view_str($type, $trans_no, $label="")
216 global $path_to_root, $use_popup_windows;
221 $viewer = "view_dimension.php";
230 if ($use_popup_windows)
231 $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>";
233 $preview_str = "<a target='_blank' href='$path_to_root/dimensions/view/$viewer?trans_no=$trans_no'>$label</a>";
236 $preview_str = $label;
241 //--------------------------------------------------------------------------------------
243 function get_trans_view_str($type, $trans_no, $label="")
245 $view_str = get_customer_trans_view_str($type, $trans_no, $label);
246 if ($view_str != null)
249 $view_str = get_supplier_trans_view_str($type, $trans_no, $label);
250 if ($view_str != null)
253 $view_str = get_banking_trans_view_str($type, $trans_no, $label);
254 if ($view_str != null)
257 $view_str = get_inventory_trans_view_str($type, $trans_no, $label);
258 if ($view_str != null)
261 $view_str = get_manufacturing_trans_view_str($type, $trans_no, $label);
262 if ($view_str != null)
265 $view_str = get_dimensions_trans_view_str($type, $trans_no, $label);
266 if ($view_str != null)
272 //--------------------------------------------------------------------------------------
274 function exchange_rate_display($from_currency, $to_currency, $date_, $buttons=true)
276 if ($from_currency != $to_currency)
278 if ($buttons && isset($_POST['get_rate']))
280 $comp_currency = get_company_currency();
281 if ($from_currency == $comp_currency)
282 $currency = $to_currency;
284 $currency = $from_currency;
285 $rate = get_ecb_rate($currency);
286 if (get_date_exchange_rate($currency, $date_))
287 update_exchange_rate($currency, $date_, $rate, $rate);
289 add_exchange_rate($currency, $date_, $rate, $rate);
290 if ($from_currency == $comp_currency)
294 $rate = get_exchange_rate_from_to($to_currency, $from_currency, $date_);
295 $rate = number_format2($rate, user_exrate_dec());
296 label_row(_("Exchange Rate:"),"1 " . $from_currency . " = " . $rate . " " . $to_currency .
297 ($buttons?" " . submit('get_rate',_("Get"), false):""));
301 //--------------------------------------------------------------------------------------
303 function is_voided_display($type, $id, $label)
306 $void_entry = get_voided_entry($type, $id);
308 if ($void_entry == null)
311 start_table("width=50% $table_style");
312 echo "<tr><td align=center><font color=red>$label</font><br>";
313 echo "<font color=red>" . _("Date Voided:") . " " . sql2date($void_entry["date_"]) . "</font><br>";
314 if (strlen($void_entry["memo_"]) > 0)
315 echo "<center><font color=red>" . _("Memo:") . " " . $void_entry["memo_"] . "</font><br>";
322 //--------------------------------------------------------------------------------------
324 function comments_display_row($type, $id)
326 $comments = get_comments($type, $id);
327 if ($comments and db_num_rows($comments))
329 echo "<tr><td colspan=15>";
330 while ($comment = db_fetch($comments))
332 echo $comment["memo_"] . "<br>";
338 //--------------------------------------------------------------------------------------
340 function get_comments_string($type, $type_no)
343 $result = get_comments($type, $type_no);
344 while ($comment = db_fetch($result))
346 if (strlen($str_return))
347 $str_return = $str_return . " \n";
348 $str_return = $str_return . $comment["memo_"];
353 //--------------------------------------------------------------------------------------
355 function view_stock_status($stock_id, $description=null)
357 global $path_to_root;
359 //hyperlink_params_separate($path_to_root . "/inventory/inquiry/stock_status.php", (user_show_codes()?$stock_id . " - ":"") . $description, "stock_id=$stock_id");
360 $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>";
362 //hyperlink_params_separate($path_to_root . "/inventory/inquiry/stock_status.php", $stock_id, "stock_id=$stock_id");
363 $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>";
367 function view_stock_status_cell($stock_id, $description=null)
370 view_stock_status($stock_id, $description);
374 //--------------------------------------------------------------------------------------
376 function display_debit_or_credit_cells($value)
386 amount_cell(abs($value));
396 //--------------------------------------------------------------------------------------
398 function display_customer_trans_tax_details($tax_items, $columns)
400 while ($tax_item = db_fetch($tax_items))
402 $tax = number_format2($tax_item['amount'],user_price_dec());
403 if ($tax_item['included_in_price'])
404 label_row(_("Included") . " " . $tax_item['tax_type_name'] . " (" . $tax_item['rate'] . "%) " .
405 _("Amount") . ": $tax", "", "colspan=$columns align=right", "align=right");
407 label_row($tax_item['tax_type_name'] . " (" . $tax_item['rate'] . "%)",
408 $tax, "colspan=$columns align=right", "align=right");
412 //--------------------------------------------------------------------------------------
414 function display_supp_trans_tax_details($tax_items, $columns)
416 while ($tax_item = db_fetch($tax_items))
418 $tax = number_format2(abs($tax_item['amount']),user_price_dec());
419 if ($tax_item['included_in_price'])
420 label_row(_("Included") . " " . $tax_item['tax_type_name'] . " (" . $tax_item['rate'] . "%) " .
421 _("Amount:") . ": $tax", "colspan=$columns align=right", "align=right");
423 label_row($tax_item['tax_type_name'] . " (" . $tax_item['rate'] . "%)",
424 $tax, "colspan=$columns align=right", "align=right");
428 //--------------------------------------------------------------------------------------
430 function display_edit_tax_items($taxes, $columns, $tax_included, $leftspan=0)
434 foreach ($taxes as $taxitem)
438 label_row(_("Included") . " " . $taxitem['tax_type_name'] . " (" . $taxitem['rate'] . "%) " .
439 _("Amount:") . " " . number_format2($taxitem['Value'],user_price_dec()), "", "colspan=$columns align=right", "align=right",$leftspan);
443 label_row($taxitem['tax_type_name'] . " (" . $taxitem['rate'] . "%)",
444 number_format2($taxitem['Value'],user_price_dec()), "colspan=$columns align=right", "align=right",$leftspan);
445 $total += $taxitem['Value'];
452 //--------------------------------------------------------------------------------------
454 function display_footer_exit()
456 global $path_to_root;
462 //--------------------------------------------------------------------------------------
464 function display_allocations($alloc_result, $total)
468 if (!$alloc_result || db_num_rows($alloc_result) == 0)
471 display_heading2(_("Allocations"));
473 start_table("$table_style width=80%");
475 $th = array( _("Type"), _("Number"), _("Date"), _("Total Amount"),
476 _("Left to Allocate"), _("This Allocation"));
478 $k = $total_allocated = 0;
480 while ($alloc_row = db_fetch($alloc_result))
483 alt_table_row_color($k);
485 label_cell(systypes::name($alloc_row['type']));
486 label_cell(get_trans_view_str($alloc_row['type'],$alloc_row['trans_no']));
487 label_cell(sql2date($alloc_row['tran_date']));
488 amount_cell($alloc_row['Total']);
489 //amount_cell($alloc_row['Total'] - $alloc_row['PrevAllocs'] - $alloc_row['amt']);
490 amount_cell($alloc_row['Total'] - $alloc_row['amt']);
491 amount_cell($alloc_row['amt']);
494 $total_allocated += $alloc_row['amt'];
497 label_cell(_("Total Allocated:"), "align=right colspan=5");
498 amount_cell($total_allocated);
501 label_cell(_("Left to Allocate:"), "align=right colspan=5");
502 amount_cell($total - $total_allocated);
508 //--------------------------------------------------------------------------------------
510 function display_allocations_from($person_type, $person_id, $type, $type_no, $total)
512 switch ($person_type)
514 case payment_person_types::customer() :
515 $alloc_result = get_allocatable_to_cust_transactions($person_id, $type_no, $type);
516 display_allocations($alloc_result, $total);
518 case payment_person_types::supplier() :
519 $alloc_result = get_allocatable_to_supp_transactions($person_id, $type_no, $type);
520 display_allocations($alloc_result, $total);
525 function get_js_go_back()
527 $js = "\n<script type=\"text/javascript\">\n"
529 . "function goBack()\n"
531 . " if (window.history.length <= 1)\n"
532 . " window.close();\n"
534 . " window.history.go(-1);\n"
541 function get_js_open_window($width, $height)
543 $js = "\n<script type=\"text/javascript\">\n"
545 . "function openWindow(url, title)\n"
547 . " var left = (screen.width - $width) / 2;\n"
548 . " var top = (screen.height - $height) / 2;\n"
549 . " window.open(url, title, 'width=$width,height=$height,left='+left+',top='+top+',screenX='+left+',screenY='+top+',status=no,scrollbars=yes');\n"
556 function get_js_form_entry($edit_name, $sel_name, $next_name)
558 $js = "\n<script type=\"text/javascript\">\n"
560 . "function recalcAccounts()\n"
562 . " var myForm = document.forms[0];\n"
563 . " var len = myForm.$sel_name.length;\n"
565 . " var ac = myForm.$edit_name.value;\n"
567 . " myForm.$sel_name.options[myForm.$sel_name.selectedIndex].selected = false;\n"
568 . " for (i = 0; i < len; i++)\n"
570 . " txt = myForm.$sel_name.options[i].text;\n"
571 . " if (txt.indexOf(ac) == 0)\n"
573 . " myForm.$sel_name.options[i].selected = true;\n"
578 . "function setAccount(p, s)\n"
580 . " var myForm = document.forms[0];\n"
581 . " if (p == 0 && myForm.$edit_name.value == \"\")\n"
583 . " myForm.$edit_name.value = myForm.$sel_name.options[myForm.$sel_name.selectedIndex].value;\n"
585 . " myForm.submit();\n"
586 . " myForm.$next_name.focus();\n"
594 function get_js_set_focus($name)
596 $js = "\n<script type=\"text/javascript\">\n"
598 . "function setFocus()\n"
600 . " document.forms[0].$name.focus();\n"
607 function get_js_png_fix()
609 $js = "<script type=\"text/javascript\">\n"
610 . "function fixPNG(myImage)\n"
612 . " var arVersion = navigator.appVersion.split(\"MSIE\")\n"
613 . " var version = parseFloat(arVersion[1])\n"
614 . " if ((version >= 5.5) && (version < 7) && (document.body.filters))\n"
616 . " var imgID = (myImage.id) ? \"id='\" + myImage.id + \"' \" : \"\"\n"
617 . " var imgClass = (myImage.className) ? \"class='\" + myImage.className + \"' \" : \"\"\n"
618 . " var imgTitle = (myImage.title) ?\n"
619 . " \"title='\" + myImage.title + \"' \" : \"title='\" + myImage.alt + \"' \"\n"
620 . " var imgStyle = \"display:inline-block;\" + myImage.style.cssText\n"
621 . " var strNewHTML = \"<span \" + imgID + imgClass + imgTitle\n"
622 . " + \" style=\\\"\" + \"width:\" + myImage.width\n"
623 . " + \"px; height:\" + myImage.height\n"
624 . " + \"px;\" + imgStyle + \";\"\n"
625 . " + \"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader\"\n"
626 . " + \"(src=\'\" + myImage.src + \"\', sizingMethod='scale');\\\"></span>\"\n"
627 . " myImage.outerHTML = strNewHTML\n"
634 function get_js_date_picker()
636 global $dateseps, $date_system;
638 $how = user_date_format(); // 0 = us/ca, 1 = eu, au, nz, 2 = jp, sw
639 $sep = $dateseps[user_date_sep()]; // date separator
640 $wstart = (($date_system == 1 || $date_system == 2) ? 6 : ($how == 0 ? 0 : 1)); // weekstart (sun = 0, mon = 1)
641 $months = array(_("January"),_("February"),_("March"),_("April"),_("May"),_("June"),_("July"),_("August"),_("September"),_("October"),_("November"),_("December"));
642 $wdays = array(_("Su"),_("Mo"),_("Tu"),_("We"),_("Th"),_("Fr"),_("Sa"));
644 if ($date_system == 1)
645 list($cyear, $cmon, $cday) = gregorian_to_jalali(date("Y"), date("n"), date("j"));
646 else if ($date_system == 2)
647 list($cyear, $cmon, $cday) = gregorian_to_islamic(date("Y"), date("n"), date("j"));
650 #CCIFrame { display: none; left: 0px; position: absolute; top: 0px; height: 250px; width: 250px; z-index: 99;}
651 #CC { position:absolute; background-color:#FFF; margin:0; padding:0; display:none; z-index: 100;}
652 #CC table { font-family: arial, verdana, helvetica, sans-serif;font-size: 8pt; border-left: 1px solid #336; border-right: 1px solid #336;}
653 #CC th { font-weight: normal;}
654 #CC th a { font-weight: normal; text-decoration: none; color: #FFF; padding: 1px;}
655 #CC td { text-align: center;}
656 #CC .header { background-color: #336;}
657 #CC .weekday { background-color: #DDD; color: #000;}
658 #CC .weekend { background-color: #FFC; color: #000;}
659 #CC .current { border: 1px solid #339; background-color: #336; color: #FFF;}
660 #CC .weekday,#CC .weekend,#CC .current { display: block; text-decoration: none; border: 1px solid #FFF; width: 2em;}
661 #CC .weekday:hover,#CC .weekend:hover,#CC .current:hover { color: #FFF; background-color: #336; border: 1px solid #999;}
662 #CC .previous { text-align: left;}
663 #CC .next { text-align: right;}
664 #CC .previous,#CC .next { padding: 1px 3px 1px 3px; font-size: 1.4em;}
665 #CC .previous a,#CC .next a { color: #FFF; text-decoration: none; font-weight: bold;}
666 #CC .title { text-align: center; font-weight: bold; color: #FFF;}
667 #CC .empty { background-color: #CCC; border: 1px solid #FFF;}
670 $js .= "<script type=\"text/javascript\">
672 function positionInfo(object) {
674 this.getElementLeft = getElementLeft;
675 function getElementLeft() {
678 if(typeof(p_elm) == 'object'){
681 elm = document.getElementById(p_elm);
683 while (elm != null) {
685 elm = elm.offsetParent;
689 this.getElementWidth = getElementWidth;
690 function getElementWidth(){
692 if(typeof(p_elm) == 'object'){
695 elm = document.getElementById(p_elm);
697 return parseInt(elm.offsetWidth);
699 this.getElementRight = getElementRight;
700 function getElementRight(){
701 return getElementLeft(p_elm) + getElementWidth(p_elm);
703 this.getElementTop = getElementTop;
704 function getElementTop() {
707 if(typeof(p_elm) == 'object'){
710 elm = document.getElementById(p_elm);
712 while (elm != null) {
714 elm = elm.offsetParent;
718 this.getElementHeight = getElementHeight;
719 function getElementHeight(){
721 if(typeof(p_elm) == 'object'){
724 elm = document.getElementById(p_elm);
726 return parseInt(elm.offsetHeight);
728 this.getElementBottom = getElementBottom;
729 function getElementBottom(){
730 return getElementTop(p_elm) + getElementHeight(p_elm);
734 var calendarId = 'CC';
736 var currentMonth = 0;
738 var selectedYear = 0;
739 var selectedMonth = 0;
741 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]'];
742 var wdays = ['$wdays[0]', '$wdays[1]', '$wdays[2]', '$wdays[3]', '$wdays[4]', '$wdays[5]', '$wdays[6]'];
743 var dateField = null;
744 function getProperty(p_property){
745 var p_elm = calendarId;
747 if(typeof(p_elm) == 'object'){
750 elm = document.getElementById(p_elm);
756 return elm[p_property];
765 function setElementProperty(p_property, p_value, p_elmId){
768 if(typeof(p_elm) == 'object'){
771 elm = document.getElementById(p_elm);
773 if((elm != null) && (elm.style != null)){
775 elm[ p_property ] = p_value;
778 function setProperty(p_property, p_value) {
779 setElementProperty(p_property, p_value, calendarId);
781 function getDaysInMonth(year, month) {
783 if ($date_system == 1)
785 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];
787 else if ($date_system == 2)
789 return [30,29,30,29,30,29,30,29,30,29,30,(((((11 * year) + 14) % 30) < 11) ? 30 : 29)][month-1];
793 return [31,((!(year % 4 ) && ( (year % 100 ) || !( year % 400 ) ))?29:28),31,30,31,30,31,31,30,31,30,31][month-1];
797 function getDayOfWeek(year, month, day) {
799 if ($date_system == 1 || $date_system == 2)
804 return a - (b * Math.floor(a / b));
808 return mod(Math.floor((j + 1.5)), 7);
811 if ($date_system == 1)
813 var epbase, epyear, t;
814 epbase = year - ((year >= 0) ? 474 : 473);
815 epyear = 474 + mod(epbase, 2820);
816 t = day + ((month <= 7) ? ((month - 1) * 31) : (((month - 1) * 30) + 6)) +
817 Math.floor(((epyear * 682) - 110) / 2816) + (epyear - 1) * 365 +
818 Math.floor(epbase / 2820) * 1029983 + (1948320.5 - 1);
820 else if ($date_system == 2)
823 t = Math.floor((11 * year + 3) / 30) + 354 * year + 30 * month -
824 Math.floor((month - 1) / 2) + day + 1948440 - 385;
832 var date = new Date(year,month-1,day)
833 return date.getDay();
837 this.clearDate = clearDate;
838 function clearDate() {
839 dateField.value = '';
842 this.setDate = setDate;
843 function setDate(year, month, day) {
845 if (month < 10) {month = '0' + month;}
846 if (day < 10) {day = '0' + day;}
850 var dateString = month+'$sep'+day+'$sep'+year;
854 var dateString = day+'$sep'+month+'$sep'+year;
858 var dateString = year+'$sep'+month+'$sep'+day;
861 dateField.value = dateString;
866 this.changeMonth = changeMonth;
867 function changeMonth(change) {
868 currentMonth += change;
870 if(currentMonth > 12) {
873 } else if(currentMonth < 1) {
877 calendar = document.getElementById(calendarId);
878 calendar.innerHTML = calendarDrawTable();
880 this.changeYear = changeYear;
881 function changeYear(change) {
882 currentYear += change;
884 calendar = document.getElementById(calendarId);
885 calendar.innerHTML = calendarDrawTable();
887 function getCurrentYear() {
888 var year = new Date().getYear();
889 if(year < 1900) year += 1900;
892 function getCurrentMonth() {
893 return new Date().getMonth() + 1;
895 function getCurrentDay() {
896 return new Date().getDate();
898 function calendarDrawTable() {
900 var wstart = $wstart;
902 var startDayOfWeek = getDayOfWeek(currentYear, currentMonth, dayOfMonth);
903 var daysInMonth = getDaysInMonth(currentYear, currentMonth);
904 var css_class = null; //CSS class for each day
905 var table = \"<table cellspacing='0' cellpadding='0' border='0'>\";
906 table += \"<tr class='header'>\";
907 table += \" <td colspan='2' class='previous'><a href='javascript:changeCCMonth(-1);'><</a><br><a href='javascript:changeCCYear(-1);'>«</a></td>\";
908 table += \" <td colspan='3' class='title'>\" + months[currentMonth-1] + \"<br>\" + currentYear + \"</td>\";
909 table += \" <td colspan='2' class='next'><a href='javascript:changeCCMonth(1);'>></a><br><a href='javascript:changeCCYear(1);'>»</a></td>\";
912 for (var n=0; n<7; n++)
913 table += \"<th>\" + wdays[(wstart+n)%7]+\"</th>\";
915 for(var week=0; week < 6; week++) {
917 for(var n=0; n < 7; n++) {
918 dayOfWeek = (wstart+n)%7;
919 if(week == 0 && startDayOfWeek == dayOfWeek) {
921 } else if (validDay == 1 && dayOfMonth > daysInMonth) {
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='7' style='padding: 3px;'><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 setProperty('display', 'block');
1014 var fieldPos = new positionInfo(dateField);
1015 var calendarPos = new positionInfo(calendarId);
1016 var x = fieldPos.getElementLeft();
1017 var y = fieldPos.getElementBottom();
1018 setProperty('left', x + 'px');
1019 setProperty('top', y + 'px');
1021 setElementProperty('display', 'block', 'CCIframe');
1022 setElementProperty('left', x + 'px', 'CCIframe');
1023 setElementProperty('top', y + 'px', 'CCIframe');
1024 setElementProperty('width', calendarPos.getElementWidth() + 'px', 'CCIframe');
1025 setElementProperty('height', calendarPos.getElementHeight() + 'px', '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>\");
1070 // Javascript conversions to/from user numeric format.
1072 function add_js_user_num() {
1073 global $thoseps, $decseps;
1074 $ts = $thoseps[user_tho_sep()];
1075 $ds = $decseps[user_dec_sep()];
1078 "<script language=\"javascript\">
1079 function price_format(post, num, dec, label) {
1080 //num = num.toString().replace(/\\$|\\,/g,'');
1083 sign = (num == (num = Math.abs(num)));
1085 decsize = Math.pow(10, dec);
1086 num = Math.floor(num*decsize+0.50000000001);
1087 cents = num%decsize;
1088 num = Math.floor(num/decsize).toString();
1089 for( i=cents.toString().length; i<dec; i++){
1090 cents = \"0\" + cents;
1092 for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
1093 num = num.substring(0,num.length-(4*i+3))+'".$ts."'+
1094 num.substring(num.length-(4*i+3));
1095 num = ((sign)?'':'-') + num;
1096 if(dec!=0) num = num + '".$ds."' + cents;
1098 document.getElementById(post).innerHTML = num;
1100 document.getElementsByName(post)[0].value = num;
1102 function get_amount(doc, label) {
1104 var val = document.getElementById(doc).innerHTML;
1106 var val = document.getElementsByName(doc)[0].value;
1107 val = val.replace(/\\".$ts."/g,'');
1108 val = val.replace(/\\".$ds."/g,'.');
1115 function add_js_allocate() {
1118 function allocate_all(doc) {
1119 var amount = get_amount('amount'+doc);
1120 var unallocated = get_amount('un_allocated'+doc);
1121 var total = get_amount('total_allocated', 1);
1122 var left = get_amount('left_to_allocate', 1);
1124 if(unallocated<amount) amount = unallocated;
1125 if((unallocated-amount)<=left){
1126 left-=unallocated-amount;
1127 total+=unallocated-amount;
1134 price_format('amount'+doc, amount, ".user_price_dec().");
1135 price_format('left_to_allocate', left, ".user_price_dec().", 1);
1136 price_format('total_allocated', total, ".user_price_dec().", 1);
1138 function allocate_none(doc) {
1139 amount = get_amount('amount'+doc);
1140 left = get_amount('left_to_allocate', 1);
1141 total = get_amount('total_allocated', 1);
1142 price_format('left_to_allocate',amount+left, ".user_price_dec().", 1);
1143 price_format('amount'+doc, 0, ".user_price_dec().");
1144 price_format('total_allocated', total-amount, ".user_price_dec().", 1);
1148 add_js_source($source);
1151 function alert($msg)
1153 echo "\n<script type=\"text/javascript\">\n"
1155 . "alert('$msg');\n"
1160 if (!function_exists('_vd'))
1162 function _vd($mixed, $title = '', $exit = false)
1164 // Only the site admin is able to proceed here.
1165 echo (!empty($title) ? ($title .':') : '') .'<pre>';