Sales invoice voiding is blocked when sales credit was issued against the invoice.
[fa-stable.git] / gl / inquiry / journal_inquiry.php
index 3fd59521e59157fdd96c81777b983490a29ce4e6..0b5a47dc0d990b0279e528c5e452bc29d7ff4737 100644 (file)
@@ -19,9 +19,9 @@ include_once($path_to_root . "/includes/session.inc");
 include_once($path_to_root . "/includes/date_functions.inc");
 include_once($path_to_root . "/includes/ui.inc");
 $js = "";
-if ($use_popup_windows)
+if ($SysPrefs->use_popup_windows)
        $js .= get_js_open_window(800, 500);
-if ($use_date_picker)
+if (user_use_date_picker())
        $js .= get_js_date_picker();
 
 page(_($help_context = "Journal Inquiry"), false, false, "", $js);
@@ -81,7 +81,15 @@ function gl_link($row)
 
 function edit_link($row)
 {
-       return edit_trans_link($row["type"], $row["type_no"]);
+
+       $ok = true;
+       if ($row['type'] == ST_SALESINVOICE)
+       {
+               $myrow = get_customer_trans($row["type_no"], $row["type"]);
+               if ($myrow['alloc'] != 0 || get_voided_entry(ST_SALESINVOICE, $row["type_no"]) !== false)
+                       $ok = false;
+       }
+       return $ok ? trans_editor_link($row["type"], $row["type_no"]) : '';
 }
 
 $sql = get_sql_for_journal_inquiry(get_post('filterType', -1), get_post('FromDate'),
@@ -89,7 +97,7 @@ $sql = get_sql_for_journal_inquiry(get_post('filterType', -1), get_post('FromDat
 
 $cols = array(
        _("#") => array('fun'=>'journal_pos', 'align'=>'center'), 
-       _("Date") =>array('name'=>'tran_date','type'=>'date', 'ord' => check_value('AlsoClosed') ? 'asc' : 'desc'),
+       _("Date") =>array('name'=>'tran_date','type'=>'date','ord'=>'desc'),
        _("Type") => array('fun'=>'systype_name'), 
        _("Trans #") => array('fun'=>'view_link'), 
        _("Reference"), 
@@ -113,4 +121,3 @@ display_db_pager($table);
 end_form();
 end_page();
 
-?>