6 include_once($path_to_root . "/includes/session.inc");
8 include_once($path_to_root . "/includes/date_functions.inc");
9 include_once($path_to_root . "/includes/ui.inc");
11 if ($use_popup_windows)
12 $js .= get_js_open_window(800, 500);
14 if ($_GET['outstanding_only'])
16 $outstanding_only = 1;
17 page(_("Search Outstanding Dimensionss"), false, false, "", $js);
21 $outstanding_only = 0;
22 page(_("Search Dimensions"), false, false, "", $js);
25 //--------------------------------------------------------------------------------------
27 if (isset($_GET["stock_id"]))
28 $_POST['SelectedStockItem'] = $_GET["stock_id"];
30 //--------------------------------------------------------------------------------------
32 start_form(false, true, $_SERVER['PHP_SELF'] ."?outstanding_only=" . $outstanding_only . SID);
34 start_table("class='tablestyle_noborder'");
37 ref_cells(_("Reference:"), 'OrderNumber', null);
39 number_list_cells(_("Type"), 'type_', null, 0, 2);
40 date_cells(_("From:"), 'FromDate', null, 0, 0, -5);
41 date_cells(_("To:"), 'ToDate');
43 check_cells( _("Only Overdue:"), 'OverdueOnly', null);
45 if (!$outstanding_only)
47 check_cells( _("Only Open:"), 'OpenOnly', null);
50 $_POST['OpenOnly'] = 1;
52 submit_cells('SearchOrders', _("Search"));
59 $dim = get_company_pref('use_dimension');
61 $sql = "SELECT * FROM ".TB_PREF."dimensions WHERE id > 0";
64 $sql .= " AND type_=1";
66 if (isset($_POST['OpenOnly']))
68 $sql .= " AND closed=0";
71 if (isset($_POST['type_']) && ($_POST['type_'] > 0))
73 $sql .= " AND type_=" . $_POST['type_'];
76 if (isset($_POST['OrderNumber']) && $_POST['OrderNumber'] != "")
78 $sql .= " AND reference LIKE '%". $_POST['OrderNumber'] . "%'";
81 if (isset($_POST['OverdueOnly']))
83 $today = date2sql(Today());
85 $sql .= " AND due_date < '$today' ";
88 $sql .= " AND date_ >= '" . date2sql($_POST['FromDate']) . "'
89 AND date_ <= '" . date2sql($_POST['ToDate']) . "'";
91 $sql .= " ORDER BY due_date";
93 $result = db_query($sql,"could not query dimensions");
95 start_table("$table_style width=80%");
97 if (!$outstanding_only)
98 $th = array(_("#"), _("Reference"), _("Name"), _("Type"), _("Date"),
99 _("Due Date"), _("Closed"), _("Balance"));
101 $th = array(_("#"), _("Reference"), _("Name"), _("Type"), _("Date"),
102 _("Due Date"), _("Balance"));
107 while ($myrow = db_fetch($result))
109 $sql = "SELECT SUM(amount) FROM ".TB_PREF."gl_trans WHERE tran_date >= '" .
110 date2sql($_POST['FromDate']) . "' AND
111 tran_date <= '" . date2sql($_POST['ToDate']) . "' AND dimension_id = " .
113 $res = db_query($sql, "Transactions could not be calculated");
114 $row = db_fetch_row($res);
118 $row_text = "class='oddrow'";
123 $row_text = "class='evenrow'";
127 // check if it's an overdue work order
128 if (date_diff(Today(), sql2date($myrow["due_date"]), "d") > 0)
130 $row_text = "class='overduebg'";
133 start_row($row_text);
135 $mpage = $path_to_root . "/dimensions/dimension_entry.php?" . SID . "trans_no=" . $myrow["id"];
137 label_cell(get_dimensions_trans_view_str(systypes::dimension(), $myrow["id"]));
138 label_cell(get_dimensions_trans_view_str(systypes::dimension(), $myrow["id"], $myrow["reference"]));
139 label_cell($myrow["name"]);
140 label_cell($myrow["type_"]);
141 label_cell(sql2date($myrow["date_"]));
142 label_cell(sql2date($myrow["due_date"]));
143 if (!$outstanding_only)
144 label_cell(($myrow["closed"] ? _("Yes") : _("No")));
145 amount_cell($row[0]);
146 if ($myrow["closed"] == 0)
147 label_cell("<a href='$mpage'>" . _("Edit") . "</a>");
156 //end of page full new headings if
162 //---------------------------------------------------------------------------------