! -> Note
$ -> Affected files
+17-Feb-2008 Joe Hunt
+! Minor change in menu and function in view_print_transaction.php
+$ /admin/view_print_transaction.php
+ /application/setup.php
++ Preparing for print of single documents
+$ /reporting/includes/reporting.inc
+! Removing 'out' field in table tax_types
+$ /sql/alter.sql
+ /taxes/tax_types.php
+ /taxes/db/tax_types_db.inc
+
11-Feb-2008 Joe Hunt
+ Added file, update_db.php, for updating company databases from an SQL script.
$ update_db.php (New file)
$js = "";
if ($use_popup_windows)
$js .= get_js_open_window(800, 500);
-page(_("View or Print Transactions"), false, false, "", $js);
+page(_("View Transactions"), false, false, "", $js);
//----------------------------------------------------------------------------------------
systypes_list_cells(_("Type:"), 'filterType', null, true);
+ if (!isset($_POST['FromTransNo']))
+ $_POST['FromTransNo'] = "1";
+ if (!isset($_POST['ToTransNo']))
+ $_POST['ToTransNo'] = "999999";
+
ref_cells(_("from #:"), 'FromTransNo');
ref_cells(_("to #:"), 'ToTransNo');
echo _("The ending transaction number is expected to be numeric and greater than zero.");
return false;
}
+ if ($_POST['filterType'] == "")
+ return false;
return true;
}
{
$db_info = get_systype_db_info($_POST['filterType']);
+ if ($db_info == null)
+ return;
+
$table_name = $db_info[0];
$type_name = $db_info[1];
$trans_no_name = $db_info[2];
$result = db_query($sql, "could not query transactions on $table_name");
- if (db_num_rows($result) == 0)
+ if (db_num_rows($result) == 0)
{
echo _("There are no transactions for the given parameters.");
return;
start_table($table_style);
if ($trans_ref)
- $th = array(_("#"), _("Reference"), _("View"), _("Print"));
- else
- $th = array(_("#"), _("View"), _("Print"));
- table_header($th);
+ $th = array(_("#"), _("Reference"), _("View"), _("GL"));
+ else
+ $th = array(_("#"), _("View"), _("GL"));
+ table_header($th);
$k = 0;
- while ($line = db_fetch($result))
+ while ($line = db_fetch($result))
{
alt_table_row_color($k);
if ($trans_ref)
label_cell($line[$trans_ref]);
label_cell(get_trans_view_str($_POST['filterType'],$line[$trans_no_name], _("View")));
- label_cell(get_gl_view_str_cell($_POST['filterType'], $line[$trans_no_name], _("View GL")));
+ label_cell(get_gl_view_str($_POST['filterType'], $line[$trans_no_name], _("View GL")));
- $forms = get_form_entries($_POST['filterType'], $line[$trans_no_name]);
- while ($form_item = db_fetch($forms))
- {
-
- $param1 = $form_item['param1'];
- $param2 = $form_item['param2'];
-
- if ($_POST['filterType'] == systypes::bank_payment()
- || $_POST['filterType'] == systypes::bank_deposit()
- || $_POST['filterType'] == systypes::cust_payment()
- || $_POST['filterType'] == systypes::supp_payment())
- {
- $param1 = payment_person_types::type_name($form_item['param1']);
- $param2 = payment_person_types::person_name($form_item['param1'], $form_item['param2'], false);
- }
-
- //label_cell(printTransaction(_("Print") . " " . getFormTypeName($form_item["form_type"]), $form_item['form_id'], $form_item['form_type'], $_POST['filterType'], $line[$trans_no_name], $line[$trans_ref], $param1, $param2));
- }
- end_row();
+ end_row();
}
viewing_controls();
-//echo getHiddenFieldScript();
-
handle_search();
br(2);
<?php
include_once("./modules/installed_modules.php");
- class setup_app extends application
+ class setup_app extends application
{
- function setup_app()
+ function setup_app()
{
global $installed_modules;
$this->application("system",_("Setup"));
$this->add_module(_("Maintanance"));
$this->add_lapp_function(2, _("Void a Transaction"),"admin/void_transaction.php?");
- $this->add_lapp_function(2, _("View or Print Transactions"),"admin/view_print_transaction.php?");
+ $this->add_lapp_function(2, _("View Transactions"),"admin/view_print_transaction.php?");
$this->add_rapp_function(2, _("Backup and Restore"),"admin/backups.php?", 15);
$this->add_rapp_function(2, _("Create/Update Companies"),"admin/create_coy.php?", 14);
$this->add_rapp_function(2, _("Install/Update Languages"),"admin/inst_lang.php?", 14);
if ($mod["tab"] == "system")
$this->add_rapp_function(2, $mod["name"], "modules/".$mod["path"]."/".$mod["filename"]."?");
}
- }
+ }
}
}
<?php
-function printTransaction($link_text, $form_id, $form_type, $trans_type, $trans_no, $ref, $param1, $param2) {
- $ar = array(
- 'COMPANY' => $_SESSION["wa_current_user"]->company,
- 'FORMID' => $form_id,
- 'FORMTYPE' => $form_type,
- 'TRANSNO' => $trans_no,
- 'TRANSTYPE' => $trans_type,
- 'REF' => $ref,
- 'PARAM1' => $param1,
- 'PARAM2' => $param2
- );
- $pdf_href = getPDFOpenScript($link_text, $ar);
- return "<a href=\"javascript:$pdf_href\">" . _($link_text) . "</a>";
-}
-function getHiddenFieldScript() {
- $ar = Array('COMPANY','LANG','FORMID','FORMTYPE','TRANSNO','TRANSTYPE','REF','PARAM1','PARAM2');
- foreach ($ar as $value) $st.= "<input type='hidden' name='$value'>";
-
- $st .= "<input type='hidden' name='QTY_DEC' value='" . user_qty_dec() . "'>
- <input type='hidden' name='PRICE_DEC' value='" . user_price_dec() . "'>
- <input type='hidden' name='PER_DEC' value='" . user_percent_dec(). "'>";
-
- $st = "<form method='post' name='pdf_form'>" . $st . "</form>";
- return $st;
-}
+// Put this on the page only once, e.g. print_hidden_script(systypes::sales_order());
+
+function print_hidden_script($type_no)
+{
+ global $path_to_root;
+ include_once($path_to_root . "/includes/types.inc");
+ $action = "";
+ $_POST['PARAM_0'] = $_POST['PARAM_1'] = 0; // the document no. is updated in print_document_link().
-function getPDFOpenScript($link_text, $ar_params) {
- $st = "document.pdf_form.LANG.value='" . $_SESSION['language']->code . "';";
- foreach ($ar_params as $key => $value) {
- $st .= "document.pdf_form.{$key}.value = '{$value}';";
+ switch ($type_no)
+ {
+ case systypes::sales_order() :
+ $action = "$path_to_root/reporting/rep109.php";
+ $_POST['PARAM_2'] = ""; // currency
+ $_POST['PARAM_3'] = ""; // bank account
+ $_POST['PARAM_4'] = 0; // email
+ $_POST['PARAM_5'] = 0; // quote
+ $_POST['PARAM_6'] = ""; // comments
+ $params = 7;
+ break;
+ case systypes::cust_dispatch() :
+ $action = "$path_to_root/reporting/rep110.php";
+ $_POST['PARAM_2'] = 0; // email
+ $_POST['PARAM_3'] = ""; // comments
+ $params = 4;
+ break;
+ case 10 : // Sales Invoice
+ case 11 : // Customer Credit Note
+ $action = "$path_to_root/reporting/rep107.php";
+ $_POST['PARAM_2'] = ""; // currency
+ $_POST['PARAM_3'] = ""; // bank account
+ $_POST['PARAM_4'] = 0; // email
+ $_POST['PARAM_5'] = ""; // paylink
+ $_POST['PARAM_6'] = ""; // comments
+ $params = 7;
+ break;
+ case systypes::po() :
+ $action = "$path_to_root/reporting/rep209.php";
+ $_POST['PARAM_2'] = ""; // currency
+ $_POST['PARAM_3'] = ""; // bank account
+ $_POST['PARAM_4'] = 0; // email
+ $_POST['PARAM_5'] = ""; // comments
+ $params = 6;
+ break;
}
- $st.= "window.open('','REP_WINDOW','toolbar=no,scrollbar=no,resizable=yes,menubar=no');";
- $st.= "document.pdf_form.target='REP_WINDOW';";
- $st.= "document.pdf_form.action= '" . C_JSP_ROOT . "/reporting/gen_pdf_form.jsp';";
- $st.= "document.pdf_form.submit();";
-
- return $st;
+ $st = "";
+ for ($i = 0; $i < $params; $i++)
+ {
+ $st .= "<input type='hidden' name='PARAM_".$i."' value='".$_POST['PARAM_'.$i]."' />";
+ }
+ $st = "<form method='post' name='pdf_form' action='$action'>" . $st . "</form>\n";
+ echo $st;
}
+// Ex. label_cell(print_document_link($myrow['order_no'], _("Print")));
+// or display_note(print_document_link($order_no, _("Print this order")));
+// or if a button
+// echo "<input type='button' name='button' value='"._("Print this order")."' onclick=\"".
+// print_document_link($order_no, "", false)."\" class='inputsubmit' />\n";
+
+function print_document_link($doc_no, $link_text, $link=true)
+{
+ $st = "document.pdf_form.PARAM_0.value = '$doc_no';";
+ $st .= "document.pdf_form.PARAM_1.value = '$doc_no';";
+ $st .= "window.open('','REP_WINDOW','toolbar=no,scrollbar=no,resizable=yes,menubar=no');
+ document.pdf_form.target='REP_WINDOW';
+ document.pdf_form.submit();\n";
+ if ($link)
+ return "<a href=\"javascript:$st\">" . $link_text . "</a>";
+ else
+ return "javascript:$st";
+}
?>
\ No newline at end of file
-- --------------------------------------------------------
--
--- ALTER TABLE for `0_company`
+-- ALTER TABLE
--
-ALTER TABLE `0_supp_invoice_items` CHANGE `gl_code` `gl_code` VARCHAR(11) NOT NULL DEFAULT '0';
+ALTER TABLE `0_tax_types` DROP `out`;
+ALTER TABLE `0_debtor_trans_details` ADD COLUMN `qty_done` double NOT NULL default '0';
+
+ALTER TABLE `0_debtor_trans` ADD COLUMN `trans_link` int(11) NOT NULL default '0';
+INSERT INTO `0_sys_types` VALUES ('13', 'Delivery', '1', '1');
+ALTER TABLE `0_sales_order_details` CHANGE `qty_invoiced` `qty_sent` DOUBLE NOT NULL default '0';
+
+ALTER TABLE `0_supp_invoice_items` CHANGE `gl_code` `gl_code` VARCHAR(11) NOT NULL DEFAULT '0';
ALTER TABLE `0_sales_order_details` DROP PRIMARY KEY;
ALTER TABLE `0_sales_order_details` ADD `id` INTEGER(11) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (`id`);
-ALTER TABLE `0_sales_order_details` CHANGE `qty_invoiced` `qty_sent` DOUBLE NOT NULL default '0';
ALTER TABLE `0_company` ADD `no_item_list` TINYINT(1) NOT NULL DEFAULT '0' AFTER `f_year`;
ALTER TABLE `0_company` ADD `no_customer_list` TINYINT(1) NOT NULL DEFAULT '0' AFTER `no_item_list`;
ALTER TABLE `0_salesman` ADD `break_pt` DOUBLE NOT NULL DEFAULT '0' AFTER `provision`;
ALTER TABLE `0_salesman` ADD `provision2` DOUBLE NOT NULL DEFAULT '0' AFTER `break_pt`;
-ALTER TABLE `0_debtor_trans_details` ADD COLUMN `qty_done` double NOT NULL default '0';
-ALTER TABLE `0_debtor_trans` ADD COLUMN `trans_link` int(11) NOT NULL default '0';
-
-INSERT INTO `0_sys_types` VALUES ('13', 'Delivery', '1', '1');
<?php
-function add_tax_type($name, $sales_gl_code, $purchasing_gl_code, $rate, $out)
+function add_tax_type($name, $sales_gl_code, $purchasing_gl_code, $rate)
{
- $sql = "INSERT INTO ".TB_PREF."tax_types (name, sales_gl_code, purchasing_gl_code, rate, `out`)
- VALUES ('$name', '$sales_gl_code', '$purchasing_gl_code', $rate, $out)";
-
- db_query($sql, "could not add tax type");
+ $sql = "INSERT INTO ".TB_PREF."tax_types (name, sales_gl_code, purchasing_gl_code, rate)
+ VALUES ('$name', '$sales_gl_code', '$purchasing_gl_code', $rate)";
+
+ db_query($sql, "could not add tax type");
}
-function update_tax_type($type_id, $name, $sales_gl_code, $purchasing_gl_code, $rate, $out)
+function update_tax_type($type_id, $name, $sales_gl_code, $purchasing_gl_code, $rate)
{
$sql = "UPDATE ".TB_PREF."tax_types SET name='$name',
sales_gl_code='$sales_gl_code',
purchasing_gl_code='$purchasing_gl_code',
- rate=$rate,
- `out`=$out
+ rate=$rate
WHERE id=$type_id";
-
- db_query($sql, "could not update tax type");
+
+ db_query($sql, "could not update tax type");
}
function get_all_tax_types()
{
$sql = "SELECT ".TB_PREF."tax_types.*,
- Chart1.account_name AS SalesAccountName,
- Chart2.account_name AS PurchasingAccountName
- FROM ".TB_PREF."tax_types, ".TB_PREF."chart_master AS Chart1,
- ".TB_PREF."chart_master AS Chart2
- WHERE ".TB_PREF."tax_types.sales_gl_code = Chart1.account_code
+ Chart1.account_name AS SalesAccountName,
+ Chart2.account_name AS PurchasingAccountName
+ FROM ".TB_PREF."tax_types, ".TB_PREF."chart_master AS Chart1,
+ ".TB_PREF."chart_master AS Chart2
+ WHERE ".TB_PREF."tax_types.sales_gl_code = Chart1.account_code
AND ".TB_PREF."tax_types.purchasing_gl_code = Chart2.account_code";
-
+
return db_query($sql, "could not get all tax types");
-}
+}
function get_all_tax_types_simple()
{
$sql = "SELECT * FROM ".TB_PREF."tax_types";
-
+
return db_query($sql, "could not get all tax types");
-}
+}
function get_tax_type($type_id)
{
$sql = "SELECT ".TB_PREF."tax_types.*,
- Chart1.account_name AS SalesAccountName,
- Chart2.account_name AS PurchasingAccountName
- FROM ".TB_PREF."tax_types, ".TB_PREF."chart_master AS Chart1,
- ".TB_PREF."chart_master AS Chart2
- WHERE ".TB_PREF."tax_types.sales_gl_code = Chart1.account_code
+ Chart1.account_name AS SalesAccountName,
+ Chart2.account_name AS PurchasingAccountName
+ FROM ".TB_PREF."tax_types, ".TB_PREF."chart_master AS Chart1,
+ ".TB_PREF."chart_master AS Chart2
+ WHERE ".TB_PREF."tax_types.sales_gl_code = Chart1.account_code
AND ".TB_PREF."tax_types.purchasing_gl_code = Chart2.account_code AND id=$type_id";
-
+
$result = db_query($sql, "could not get tax type");
-
+
return db_fetch($result);
}
function get_tax_type_default_rate($type_id)
{
$sql = "SELECT rate FROM ".TB_PREF."tax_types WHERE id=$type_id";
-
+
$result = db_query($sql, "could not get tax type rate");
-
+
$row = db_fetch_row($result);
return $row[0];
}
function delete_tax_type($type_id)
{
begin_transaction();
-
+
$sql = "DELETE FROM ".TB_PREF."tax_types WHERE id=$type_id";
-
- db_query($sql, "could not delete tax type");
-
+
+ db_query($sql, "could not delete tax type");
+
// also delete any item tax exemptions associated with this type
$sql = "DELETE FROM ".TB_PREF."item_tax_type_exemptions WHERE tax_type_id=$type_id";
-
+
db_query($sql, "could not delete item tax type exemptions");
-
- commit_transaction();
+
+ commit_transaction();
}
?>
\ No newline at end of file
$path_to_root="..";
include($path_to_root . "/includes/session.inc");
-
page(_("Tax Types"));
include_once($path_to_root . "/includes/ui.inc");
if (isset($_GET['selected_id']))
{
$selected_id = $_GET['selected_id'];
-}
+}
elseif(isset($_POST['selected_id']))
{
$selected_id = $_POST['selected_id'];
}
//-----------------------------------------------------------------------------------
-function can_process()
+function can_process()
{
- if (strlen($_POST['name']) == 0)
+ if (strlen($_POST['name']) == 0)
{
display_error(_("The tax type name cannot be empty."));
return false;
- }
- elseif (!is_numeric($_POST['rate']))
+ }
+ elseif (!is_numeric($_POST['rate']))
{
display_error( _("The default tax rate must be numeric."));
return false;
- }
- elseif ($_POST['rate'] < 0)
+ }
+ elseif ($_POST['rate'] < 0)
{
display_error( _("The default tax rate cannot be less than zero."));
return false;
//-----------------------------------------------------------------------------------
-if (isset($_POST['ADD_ITEM']) && can_process())
+if (isset($_POST['ADD_ITEM']) && can_process())
{
add_tax_type($_POST['name'], $_POST['sales_gl_code'],
- $_POST['purchasing_gl_code'], $_POST['rate'], check_value('out'));
+ $_POST['purchasing_gl_code'], $_POST['rate']);
meta_forward($_SERVER['PHP_SELF']);
}
//-----------------------------------------------------------------------------------
-if (isset($_POST['UPDATE_ITEM']) && can_process())
+if (isset($_POST['UPDATE_ITEM']) && can_process())
{
update_tax_type($selected_id, $_POST['name'],
- $_POST['sales_gl_code'], $_POST['purchasing_gl_code'], $_POST['rate'], check_value('out'));
+ $_POST['sales_gl_code'], $_POST['purchasing_gl_code'], $_POST['rate']);
meta_forward($_SERVER['PHP_SELF']);
}
$sql= "SELECT COUNT(*) FROM ".TB_PREF."tax_group_items WHERE tax_type_id=$selected_id";
$result = db_query($sql, "could not query tax groups");
$myrow = db_fetch_row($result);
- if ($myrow[0] > 0)
+ if ($myrow[0] > 0)
{
display_error(_("Cannot delete this tax type because tax groups been created referring to it."));
return false;
//-----------------------------------------------------------------------------------
-if (isset($_GET['delete']))
+if (isset($_GET['delete']))
{
if (can_delete($selected_id))
start_table($table_style);
$th = array(_("Description"), _("Default Rate (%)"),
- _("Sales GL Account"), _("Purchasing GL Account"), _("Outstanding"), "", "");
-table_header($th);
+ _("Sales GL Account"), _("Purchasing GL Account"), "", "");
+table_header($th);
$k = 0;
-while ($myrow = db_fetch($result))
+while ($myrow = db_fetch($result))
{
- if ($myrow['out'] == 1)
- $out = _("Yes");
- else
- $out = _("No");
alt_table_row_color($k);
label_cell($myrow["name"]);
label_cell(number_format2($myrow["rate"],user_percent_dec()), "align=right");
label_cell($myrow["sales_gl_code"] . " " . $myrow["SalesAccountName"]);
label_cell($myrow["purchasing_gl_code"] . " " . $myrow["PurchasingAccountName"]);
- label_cell($out);
edit_link_cell("selected_id=".$myrow["id"]);
delete_link_cell("selected_id=".$myrow["id"]."&delete=1");
+
end_row();
}
start_table($table_style2);
-if (isset($selected_id))
+if (isset($selected_id))
{
//editing an existing status code
$_POST['rate'] = $myrow["rate"];
$_POST['sales_gl_code'] = $myrow["sales_gl_code"];
$_POST['purchasing_gl_code'] = $myrow["purchasing_gl_code"];
- $_POST['out'] = $myrow["out"];
hidden('selected_id', $selected_id);
}
gl_all_accounts_list_row(_("Sales GL Account:"), 'sales_gl_code', null);
gl_all_accounts_list_row(_("Purchasing GL Account:"), 'purchasing_gl_code', null);
-check_row(_("Outstanding:"), 'out', null);
-
end_table(1);
submit_add_or_update_center(!isset($selected_id));