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 $js .= get_js_date_picker();
16 if (isset($_GET['outstanding_only']) && $_GET['outstanding_only'])
18 $outstanding_only = 1;
19 page(_("Search Outstanding Dimensionss"), false, false, "", $js);
23 $outstanding_only = 0;
24 page(_("Search Dimensions"), false, false, "", $js);
27 //--------------------------------------------------------------------------------------
29 if (isset($_GET["stock_id"]))
30 $_POST['SelectedStockItem'] = $_GET["stock_id"];
32 //--------------------------------------------------------------------------------------
34 start_form(false, true, $_SERVER['PHP_SELF'] ."?outstanding_only=" . $outstanding_only . SID);
36 start_table("class='tablestyle_noborder'");
39 ref_cells(_("Reference:"), 'OrderNumber', null);
41 number_list_cells(_("Type"), 'type_', null, 0, 2);
42 date_cells(_("From:"), 'FromDate', null, 0, 0, -5);
43 date_cells(_("To:"), 'ToDate');
45 check_cells( _("Only Overdue:"), 'OverdueOnly', null);
47 if (!$outstanding_only)
49 check_cells( _("Only Open:"), 'OpenOnly', null);
52 $_POST['OpenOnly'] = 1;
54 submit_cells('SearchOrders', _("Search"));
61 $dim = get_company_pref('use_dimension');
63 $sql = "SELECT * FROM ".TB_PREF."dimensions WHERE id > 0";
66 $sql .= " AND type_=1";
68 if (isset($_POST['OpenOnly']))
70 $sql .= " AND closed=0";
73 if (isset($_POST['type_']) && ($_POST['type_'] > 0))
75 $sql .= " AND type_=" . $_POST['type_'];
78 if (isset($_POST['OrderNumber']) && $_POST['OrderNumber'] != "")
80 $sql .= " AND reference LIKE '%". $_POST['OrderNumber'] . "%'";
83 if (isset($_POST['OverdueOnly']))
85 $today = date2sql(Today());
87 $sql .= " AND due_date < '$today' ";
90 $sql .= " AND date_ >= '" . date2sql($_POST['FromDate']) . "'
91 AND date_ <= '" . date2sql($_POST['ToDate']) . "'";
93 $sql .= " ORDER BY due_date";
95 $result = db_query($sql,"could not query dimensions");
97 start_table("$table_style width=80%");
99 if (!$outstanding_only)
100 $th = array(_("#"), _("Reference"), _("Name"), _("Type"), _("Date"),
101 _("Due Date"), _("Closed"), _("Balance"));
103 $th = array(_("#"), _("Reference"), _("Name"), _("Type"), _("Date"),
104 _("Due Date"), _("Balance"));
109 while ($myrow = db_fetch($result))
111 $sql = "SELECT SUM(amount) FROM ".TB_PREF."gl_trans WHERE tran_date >= '" .
112 date2sql($_POST['FromDate']) . "' AND
113 tran_date <= '" . date2sql($_POST['ToDate']) . "' AND dimension_id = " .
115 $res = db_query($sql, "Transactions could not be calculated");
116 $row = db_fetch_row($res);
120 $row_text = "class='oddrow'";
125 $row_text = "class='evenrow'";
129 // check if it's an overdue work order
130 if (date_diff(Today(), sql2date($myrow["due_date"]), "d") > 0)
132 $row_text = "class='overduebg'";
135 start_row($row_text);
137 $mpage = $path_to_root . "/dimensions/dimension_entry.php?" . SID . "trans_no=" . $myrow["id"];
139 label_cell(get_dimensions_trans_view_str(systypes::dimension(), $myrow["id"]));
140 label_cell(get_dimensions_trans_view_str(systypes::dimension(), $myrow["id"], $myrow["reference"]));
141 label_cell($myrow["name"]);
142 label_cell($myrow["type_"]);
143 label_cell(sql2date($myrow["date_"]));
144 label_cell(sql2date($myrow["due_date"]));
145 if (!$outstanding_only)
146 label_cell(($myrow["closed"] ? _("Yes") : _("No")));
147 amount_cell($row[0]);
148 if ($myrow["closed"] == 0)
149 label_cell("<a href='$mpage'>" . _("Edit") . "</a>");
158 //end of page full new headings if
164 //---------------------------------------------------------------------------------