Merged changes up to version 2.3.4 into unstable.
[fa-stable.git] / includes / ui / ui_input.inc
index 272d515b9965283b1770fc8ce02f65ba077b0b00..9048cac4641d00e536164537c6a5657482a05956 100644 (file)
@@ -247,17 +247,24 @@ function submit_return($name, $value, $title=false)
        }
 }
 
-function submit_js_confirm($name, $msg) {
-       add_js_source(
-               "_validate.$name=function(){ return confirm('"
-                       . strtr($msg, array("\n"=>'\\n')) . "');};");
-};
+function submit_js_confirm($name, $msg, $set = true) {
+       global $Ajax;
+       $js = "_validate.$name=".($set ? "function(){ return confirm('"
+                               . strtr($msg, array("\n"=>'\\n')) . "');};"
+                               : 'null;');
+       if (in_ajax()) {
+               $Ajax->addScript(true, $js);
+       } else
+               add_js_source($js);
+}
 //-----------------------------------------------------------------------------------
 
 function set_icon($icon, $title=false)
 {
        global $path_to_root;
-       return "<img src='$path_to_root/themes/".user_theme()."/images/$icon' width='12' height='12' border='0'".($title ? " title='$title'" : "")." />\n";     
+       if (basename($icon) === $icon) // standard icons does not contain path separator
+               $icon = "$path_to_root/themes/".user_theme()."/images/$icon";
+       return "<img src='$icon' width='12' height='12' border='0'".($title ? " title='$title'" : "")." />\n";  
 }
 
 function button($name, $value, $title=false, $icon=false,  $aspect='')
@@ -924,4 +931,38 @@ function supplier_credit_row($supplier, $credit, $parms='')
                ."</a>", $parms);
 }
 
+/*
+       Edit transaction link to be used in transaction inquires
+*/
+function edit_trans_link($trans_type, $trans_no, $url='')
+{
+       global $path_to_root, $trans_editors;
+
+       if (!$url) $url = @$trans_editors[$trans_type];
+
+       if (!$trans_no || !$url)
+               return '';
+
+       if (is_closed_trans($trans_type, $trans_no)) {
+               return set_icon(ICON_CLOSED, _('Closed'));
+       } else {
+               $link_text = user_graphic_links() ? set_icon(ICON_EDIT, _('Edit')) : _('Edit');
+               return "<a href='".$path_to_root . sprintf($url, $trans_no, $trans_type)."'>$link_text</a>";
+       }
+}
+
+function bank_balance_row($bank_acc, $parms='')
+{
+       global $path_to_root;
+       
+       $to = add_days(Today(), 1);
+       $bal = get_balance_before_for_bank_account($bank_acc, $to);
+       label_row( _("Bank Balance:"),
+               "<a target='_blank' " . ($bal<0 ? 'class="redfg"' : '')
+               ."href='$path_to_root/gl/inquiry/bank_inquiry.php?bank_account=".$bank_acc."'"
+               ." onclick=\"javascript:openWindow(this.href,this.target); return false;\" >&nbsp;"
+               . price_format($bal)
+               ."</a>", $parms);
+}
+
 ?>
\ No newline at end of file