From 72c7510d29d26a0ede9cc23ad052b0ed156b1aaf Mon Sep 17 00:00:00 2001 From: Joe Hunt Date: Fri, 14 Nov 2008 15:57:07 +0000 Subject: [PATCH] *** empty log message *** --- CHANGELOG.txt | 18 +++ applications/customers.php | 3 + includes/ui/ui_lists.inc | 62 ++++++++ reporting/includes/reporting.inc | 2 +- reporting/rep108.php | 2 +- sales/create_recurrent_invoices.php | 158 ++++++++++++++++++++ sales/includes/db/branches_db.inc | 7 + sales/includes/db/sales_credit_db.inc | 6 +- sales/includes/db/sales_delivery_db.inc | 6 +- sales/includes/db/sales_invoice_db.inc | 6 +- sales/inquiry/sales_orders_view.php | 4 +- sales/manage/customer_branches.php | 7 +- sales/manage/customers.php | 2 +- sales/manage/recurrent_invoices.php | 189 ++++++++++++++++++++++++ sales/manage/sales_groups.php | 131 ++++++++++++++++ sql/alter2.1.sql | 32 ++++ 16 files changed, 623 insertions(+), 12 deletions(-) create mode 100644 sales/create_recurrent_invoices.php create mode 100644 sales/manage/recurrent_invoices.php create mode 100644 sales/manage/sales_groups.php diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 77d9da68..a60246b8 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,24 @@ Legend: ! -> Note $ -> Affected files +14-Nov-2008 Joe Hunt ++ Added Sales Groups and Recurrent Invoices. +$ /applications/customers.php + /includes/ui/ui_lists.inc + /reporting/includes/reporting.inc + /reporting/rep108.php + /sales/includes/db/branches_db.inc + /sales/includes/db/sales_credit_db.inc + /sales/includes/db/sales_delivery_db.inc + /sales/includes/db/sales_invoice_db.inc + /sales/inquiry/sales_orders_view.php + /sales/manage/customer_branches.php + /sales/manage/customers.php + /sql/alter2.1.sql + /sales/create_recurrent_invoices.php (new file) + /sales/manage/recurrent_invoices.php (new file) + /sales/manage/sales_groups.php (new file) + 13-Nov-2008 Janusz Dobrowolski ! Rewritten for paged query results. $ /dimensions/inquiry/search_dimensions.php diff --git a/applications/customers.php b/applications/customers.php index 92b10dcd..245ee62e 100644 --- a/applications/customers.php +++ b/applications/customers.php @@ -18,6 +18,7 @@ $this->add_rapp_function(0, _("&Template Delivery"),"sales/inquiry/sales_orders_view.php?DeliveryTemplates=Yes"); $this->add_rapp_function(0, _("&Template Invoice"),"sales/inquiry/sales_orders_view.php?InvoiceTemplates=Yes"); + $this->add_rapp_function(0, _("&Create and Print Recurrent Invoices"),"sales/create_recurrent_invoices.php?"); $this->add_rapp_function(0, "",""); $this->add_rapp_function(0, _("Customer &Payments"),"sales/customer_payments.php?"); $this->add_rapp_function(0, _("Customer &Credit Notes"),"sales/credit_note_entry.php?NewCredit=Yes"); @@ -34,6 +35,8 @@ $this->add_module(_("Maintenance")); $this->add_lapp_function(2, _("Add and Manage &Customers"),"sales/manage/customers.php?"); $this->add_lapp_function(2, _("Customer &Branches"),"sales/manage/customer_branches.php?"); + $this->add_lapp_function(2, _("Sales &Groups"),"sales/manage/sales_groups.php?"); + $this->add_lapp_function(2, _("Recurrent &Invoices"),"sales/manage/recurrent_invoices.php?"); $this->add_rapp_function(2, _("Sales T&ypes"),"sales/manage/sales_types.php?"); $this->add_rapp_function(2, _("Sales &Persons"),"sales/manage/sales_people.php?"); $this->add_rapp_function(2, _("Sales &Areas"),"sales/manage/sales_areas.php?"); diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index b960c27d..4748136e 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -1009,6 +1009,68 @@ function sales_areas_list_row($label, $name, $selected_id=null) //------------------------------------------------------------------------------------ +function sales_groups_list($name, $selected_id=null, $special_option=false) +{ + $sql = "SELECT id, description FROM ".TB_PREF."groups"; + combo_input($name, $selected_id, $sql, 'id', 'description', array( + 'spec_option' => $special_option===true ? ' ' : $special_option, + 'order' => 'description', 'spec_id' => 0, + )); +} + +function sales_groups_list_cells($label, $name, $selected_id=null, $special_option=false) +{ + if ($label != null) + echo "$label\n"; + echo ""; + sales_groups_list($name, $selected_id, $special_option); + echo "\n"; +} + +function sales_groups_list_row($label, $name, $selected_id=null, $special_option=false) +{ + echo "\n"; + sales_groups_list_cells($label, $name, $selected_id, $special_option); + echo "\n"; +} + +//------------------------------------------------------------------------------------ + +function _format_template_items($row) +{ + return ($row[0] . " -  " . _("Amount") . " ".$row[1]); +} + +function templates_list($name, $selected_id=null, $special_option=false) +{ + $sql = "SELECT sorder.order_no, Sum(line.unit_price*line.quantity*(1-line.discount_percent)) AS OrderValue + FROM ".TB_PREF."sales_orders as sorder, ".TB_PREF."sales_order_details as line + WHERE sorder.order_no = line.order_no AND sorder.type = 1 GROUP BY line.order_no"; + combo_input($name, $selected_id, $sql, 'order_no', 'OrderValue', array( + 'format' => '_format_template_items', + 'spec_option' => $special_option===true ? ' ' : $special_option, + 'order' => 'order_no', 'spec_id' => 0, + )); +} + +function templates_list_cells($label, $name, $selected_id=null, $special_option=false) +{ + if ($label != null) + echo "$label\n"; + echo ""; + templates_list($name, $selected_id, $special_option); + echo "\n"; +} + +function templates_list_row($label, $name, $selected_id=null, $special_option=false) +{ + echo "\n"; + templates_list_cells($label, $name, $selected_id, $special_option); + echo "\n"; +} + +//------------------------------------------------------------------------------------ + function workorders_list($name, $selected_id=null) { $sql = "SELECT id, wo_ref FROM ".TB_PREF."workorders WHERE closed=0"; diff --git a/reporting/includes/reporting.inc b/reporting/includes/reporting.inc index a304f22e..f5c1bd38 100644 --- a/reporting/includes/reporting.inc +++ b/reporting/includes/reporting.inc @@ -85,7 +85,7 @@ function print_link($link_text, $rep, $pars = array(), $dir = '') function get_first_bank_account() { - $sql = "SELECT ".TB_PREF."bank_accounts.account_code FROM ".TB_PREF."bank_accounts, ".TB_PREF."company + $sql = "SELECT ".TB_PREF."bank_accounts.id FROM ".TB_PREF."bank_accounts, ".TB_PREF."company WHERE bank_curr_code=curr_default LIMIT 0, 1"; $result = db_query($sql); $row = db_fetch_row($result); diff --git a/reporting/rep108.php b/reporting/rep108.php index f6eae3ee..4a5bb107 100644 --- a/reporting/rep108.php +++ b/reporting/rep108.php @@ -136,7 +136,7 @@ function print_statements() $rep->TextCol(7, 8, $DisplayNet, -2); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + (10 * $rep->lineHeight)) - $rep->Header2($myrow, null, null, $baccount); + $rep->Header2($myrow, null, null, $baccount, 12); } $nowdue = "1-" . $PastDueDays1 . " " . $doc_Days; $pastdue1 = $PastDueDays1 + 1 . "-" . $PastDueDays2 . " " . $doc_Days; diff --git a/sales/create_recurrent_invoices.php b/sales/create_recurrent_invoices.php new file mode 100644 index 00000000..d398648c --- /dev/null +++ b/sales/create_recurrent_invoices.php @@ -0,0 +1,158 @@ +trans_type = 30; + $doc->trans_no = 0; + $doc->document_date = Today(); // 2006-06-15. Added so Invoices and Deliveries get current day + + $doc->due_date = get_invoice_duedate($doc->customer_id, $doc->document_date); + $doc->reference = references::get_next($doc->trans_type); + $doc->Comments=''; + + foreach ($doc->line_items as $line_no=>$item) { + $line = &$doc->line_items[$line_no]; + $line->price = get_price($line->stock_id, $doc->customer_currency, + $doc->sales_type, $doc->price_factor, $doc->document_date); + } + $cart = $doc; + $cart->trans_type = 10; + $cart->reference = references::get_next($cart->trans_type); + $invno = $cart->write(1); + set_last_sent($tmpl_no, $cart->document_date); + return $invno; +} + +if (isset($_GET['recurrent'])) +{ + $invs = array(); + $sql = "SELECT * FROM ".TB_PREF."recurrent_invoices WHERE id=".$_GET['recurrent']; + + $result = db_query($sql,"could not get recurrent invoice"); + $myrow = db_fetch($result); + if ($myrow['debtor_no'] == 0) + { + $cust = get_cust_branches_from_group($myrow['group_no']); + while ($row = db_fetch($cust)) + { + $invs[] = create_recurrent_invoices($row['debtor_no'], $row['branch_code'], $myrow['order_no'], $myrow['id']); + } + } + else + { + $invs[] = create_recurrent_invoices($myrow['debtor_no'], $myrow['group_no'], $myrow['order_no'], $myrow['id']); + } + if (count($invs) > 0) + { + $min = min($invs); + $max = max($invs); + } + else + $min = $max = 0; + display_notification(sprintf(_("%s recurrent invoice(s) created, # $min - # $max."), count($invs))); + if (count($invs) > 0) + { + $ar = array('PARAM_0' => $min, 'PARAM_1' => $max, 'PARAM_2' => "", 'PARAM_3' => get_first_bank_account(), + 'PARAM_4' => 0, 'PARAM_5' => 0, 'PARAM_6' => "", 'PARAM_7' => 10); + display_note(print_link(_("&Print Recurrent Invoices # $min - # $max"), 107, $ar), 0, 1); + } +} + +//------------------------------------------------------------------------------------------------- +function get_sales_group_name($group_no) +{ + $sql = "SELECT description FROM ".TB_PREF."groups WHERE id = $group_no"; + $result = db_query($sql, "could not get group"); + $row = db_fetch($result); + return $row[0]; +} + +$sql = "SELECT * FROM ".TB_PREF."recurrent_invoices ORDER BY description, group_no, debtor_no"; +$result = db_query($sql,"could not get recurrent invoices"); + +start_table("$table_style width=70%"); +$th = array(_("Description"), _("Template No"),_("Customer"),_("Branch")."/"._("Group"),_("Days"),_("Monthly"),_("Begin"),_("End"),_("Last Created"),""); +table_header($th); +$k = 0; +$today = add_days(Today(), 1); +$due = false; +while ($myrow = db_fetch($result)) +{ + $begin = sql2date($myrow["begin"]); + $end = sql2date($myrow["end"]); + $last_sent = sql2date($myrow["last_sent"]); + if ($myrow['monthly'] > 0) + $due_date = begin_month($last_sent); + else + $due_date = $last_sent; + $due_date = add_months($due_date, $myrow['monthly']); + $due_date = add_days($due_date, $myrow['days']); + $overdue = date1_greater_date2($today, $due_date) && date1_greater_date2($today, $begin) + && date1_greater_date2($end, $today); + if ($overdue) + { + start_row("class='overduebg'"); + $due = true; + } + else + alt_table_row_color($k); + + label_cell($myrow["description"]); + label_cell(get_customer_trans_view_str(30, $myrow["order_no"])); + if ($myrow["debtor_no"] == 0) + { + label_cell(""); + label_cell(get_sales_group_name($myrow["group_no"])); + } + else + { + label_cell(get_customer_name($myrow["debtor_no"])); + label_cell(get_branch_name($myrow['group_no'])); + } + label_cell($myrow["days"]); + label_cell($myrow['monthly']); + label_cell($begin); + label_cell($end); + label_cell($last_sent); + if ($overdue) + label_cell("" . _("Create Invoices") . ""); + else + label_cell(""); + end_row(); +} +end_table(); +if ($due) + display_note(_("Marked items are due."), 1, 0, "class='overduefg'"); +else + display_note(("No recurrent invoices are due."), 1, 0); + +echo '
'; + +end_page(); +?> diff --git a/sales/includes/db/branches_db.inc b/sales/includes/db/branches_db.inc index 2c4eb522..fb709542 100644 --- a/sales/includes/db/branches_db.inc +++ b/sales/includes/db/branches_db.inc @@ -34,4 +34,11 @@ function get_branch_name($branch_id) return $myrow[0]; } +function get_cust_branches_from_group($group_no) +{ + $sql = "SELECT branch_code, debtor_no FROM ".TB_PREF."cust_branch + WHERE group_no = '$group_no'"; + + return db_query($sql,"could not retreive branches for group " . $group_no); +} ?> \ No newline at end of file diff --git a/sales/includes/db/sales_credit_db.inc b/sales/includes/db/sales_credit_db.inc index 3a810944..ed22cba2 100644 --- a/sales/includes/db/sales_credit_db.inc +++ b/sales/includes/db/sales_credit_db.inc @@ -208,8 +208,10 @@ function add_gl_trans_credit_costs($order, $order_line, $credit_no, $date_, $customer = get_customer($order->customer_id); // 2008-08-01. If there is a Customer Dimension, then override with this, // else take the Item Dimension (if any) - $dim = ($order->dimension_id > 0 ? $order->dimension_id : ($customer['dimension_id'] != 0 ? $customer["dimension_id"] : $stock_gl_codes["dimension_id"])); - $dim2 = ($order->dimension2_id > 0 ? $order->dimension2_id : ($customer['dimension2_id'] != 0 ? $customer["dimension2_id"] : $stock_gl_codes["dimension2_id"])); + $dim = ($order->dimension_id != $customer['dimension_id'] ? $order->dimension_id : + ($customer['dimension_id'] != 0 ? $customer["dimension_id"] : $stock_gl_codes["dimension_id"])); + $dim2 = ($order->dimension2_id != $customer['dimension2_id'] ? $order->dimension2_id : + ($customer['dimension2_id'] != 0 ? $customer["dimension2_id"] : $stock_gl_codes["dimension2_id"])); /* insert gl_trans to credit stock and debit cost of sales at standard cost*/ $standard_cost = get_standard_cost($order_line->stock_id); diff --git a/sales/includes/db/sales_delivery_db.inc b/sales/includes/db/sales_delivery_db.inc index f2237dbd..5d72855f 100644 --- a/sales/includes/db/sales_delivery_db.inc +++ b/sales/includes/db/sales_delivery_db.inc @@ -81,8 +81,10 @@ function write_sales_delivery(&$delivery,$bo_policy) /*first the cost of sales entry*/ // 2008-08-01. If there is a Customer Dimension, then override with this, // else take the Item Dimension (if any) - $dim = ($delivery->dimension_id > 0 ? $delivery->dimension_id : ($customer['dimension_id'] != 0 ? $customer["dimension_id"] : $stock_gl_code["dimension_id"])); - $dim2 = ($delivery->dimension2_id > 0 ? $delivery->dimension2_id : ($customer['dimension2_id'] != 0 ? $customer["dimension2_id"] : $stock_gl_code["dimension2_id"])); + $dim = ($delivery->dimension_id != $customer['dimension_id'] ? $delivery->dimension_id : + ($customer['dimension_id'] != 0 ? $customer["dimension_id"] : $stock_gl_code["dimension_id"])); + $dim2 = ($delivery->dimension2_id != $customer['dimension2_id'] ? $delivery->dimension2_id : + ($customer['dimension2_id'] != 0 ? $customer["dimension2_id"] : $stock_gl_code["dimension2_id"])); add_gl_trans_std_cost(13, $delivery_no, $delivery->document_date, $stock_gl_code["cogs_account"], $dim, $dim2, "", diff --git a/sales/includes/db/sales_invoice_db.inc b/sales/includes/db/sales_invoice_db.inc index 689cd956..0c145715 100644 --- a/sales/includes/db/sales_invoice_db.inc +++ b/sales/includes/db/sales_invoice_db.inc @@ -105,8 +105,10 @@ function write_sales_invoice(&$invoice) $sales_account = ($branch_data['sales_account'] != "" ? $branch_data['sales_account'] : $stock_gl_code['sales_account']); // 2008-08-01. If there is a Customer Dimension, then override with this, // else take the Item Dimension (if any) - $dim = ($invoice->dimension_id > 0 ? $invoice->dimension_id : ($customer['dimension_id'] != 0 ? $customer["dimension_id"] : $stock_gl_code["dimension_id"])); - $dim2 = ($invoice->dimension2_id > 0 ? $invoice->dimension2_id : ($customer['dimension2_id'] != 0 ? $customer["dimension2_id"] : $stock_gl_code["dimension2_id"])); + $dim = ($invoice->dimension_id != $customer['dimension_id'] ? $invoice->dimension_id : + ($customer['dimension_id'] != 0 ? $customer["dimension_id"] : $stock_gl_code["dimension_id"])); + $dim2 = ($invoice->dimension2_id != $customer['dimension2_id'] ? $invoice->dimension2_id : + ($customer['dimension2_id'] != 0 ? $customer["dimension2_id"] : $stock_gl_code["dimension2_id"])); add_gl_trans_customer(10, $invoice_no, $date_, $sales_account, $dim, $dim2, (-$line_taxfree_price * $invoice_line->qty_dispatched), $invoice->customer_id, "The sales price GL posting could not be inserted"); diff --git a/sales/inquiry/sales_orders_view.php b/sales/inquiry/sales_orders_view.php index 2d4e5b31..c68d63d7 100644 --- a/sales/inquiry/sales_orders_view.php +++ b/sales/inquiry/sales_orders_view.php @@ -3,10 +3,10 @@ $page_security = 2; $path_to_root="../.."; -include($path_to_root . "/sales/includes/sales_ui.inc"); include($path_to_root . "/includes/db_pager.inc"); -include_once($path_to_root . "/reporting/includes/reporting.inc"); include($path_to_root . "/includes/session.inc"); +include($path_to_root . "/sales/includes/sales_ui.inc"); +include_once($path_to_root . "/reporting/includes/reporting.inc"); $js = ""; if ($use_popup_windows) diff --git a/sales/manage/customer_branches.php b/sales/manage/customer_branches.php index 69ecd9e4..a9345a0f 100644 --- a/sales/manage/customer_branches.php +++ b/sales/manage/customer_branches.php @@ -82,6 +82,7 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') default_location=".db_escape($_POST['default_location']) . ", br_post_address =".db_escape($_POST['br_post_address']) . ", disable_trans=".db_escape($_POST['disable_trans']) . ", + group_no=".db_escape($_POST['group_no']) . ", default_ship_via=".db_escape($_POST['default_ship_via']) . " WHERE branch_code =".db_escape($_POST['branch_code']) . " AND debtor_no=".db_escape($_POST['customer_id']); @@ -94,7 +95,7 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') $sql = "INSERT INTO ".TB_PREF."cust_branch (debtor_no, br_name, br_address, salesman, phone, fax, contact_name, area, email, tax_group_id, sales_account, receivables_account, payment_discount_account, sales_discount_account, default_location, - br_post_address, disable_trans, default_ship_via) + br_post_address, disable_trans, group_no, default_ship_via) VALUES (".db_escape($_POST['customer_id']). ",".db_escape($_POST['br_name']) . ", " .db_escape($_POST['br_address']) . ", ".db_escape($_POST['salesman']) . ", " .db_escape($_POST['phone']) . ", ".db_escape($_POST['fax']) . "," @@ -107,6 +108,7 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') .db_escape($_POST['default_location']) . ", " .db_escape($_POST['br_post_address']) . "," .db_escape($_POST['disable_trans']) . ", " + .db_escape($_POST['group_no']) . ", " .db_escape($_POST['default_ship_via']) . ")"; $note = _('New customer branch has been added'); @@ -248,6 +250,7 @@ if ($selected_id != -1) $_POST['sales_discount_account'] = $myrow['sales_discount_account']; $_POST['receivables_account'] = $myrow['receivables_account']; $_POST['payment_discount_account'] = $myrow['payment_discount_account']; + $_POST['group_no'] = $myrow["group_no"]; } } elseif ($Mode != 'ADD_ITEM') @@ -304,6 +307,8 @@ tax_groups_list_row(_("Tax Group:"), 'tax_group_id', null); yesno_list_row(_("Disable this Branch:"), 'disable_trans', null); +sales_groups_list_row(_("Sales Group:"), 'group_no', null, true); + echo ""; echo ""; // outer table diff --git a/sales/manage/customers.php b/sales/manage/customers.php index 944d63e0..6eff2117 100644 --- a/sales/manage/customers.php +++ b/sales/manage/customers.php @@ -86,7 +86,7 @@ function handle_submit() begin_transaction(); $sql = "INSERT INTO ".TB_PREF."debtors_master (name, address, tax_id, email, dimension_id, dimension2_id, - curr_code, credit_status, payment_terms, discount, pymt_discount,credit_limit, + curr_code, credit_status, payment_terms, discount, pymt_discount,credit_limit, sales_type) VALUES (".db_escape($_POST['CustName']) .", " .db_escape($_POST['address']) . ", " . db_escape($_POST['tax_id']) . "," .db_escape($_POST['email']) . ", ".db_escape($_POST['dimension_id']) . ", " diff --git a/sales/manage/recurrent_invoices.php b/sales/manage/recurrent_invoices.php new file mode 100644 index 00000000..c432e201 --- /dev/null +++ b/sales/manage/recurrent_invoices.php @@ -0,0 +1,189 @@ +'; + +//------------------------------------------------------------------------------------------------- + +start_form(); + +start_table("$table_style2 width=40%"); + +if ($selected_id != -1) +{ + if ($Mode == 'Edit') { + //editing an existing area + $sql = "SELECT * FROM ".TB_PREF."recurrent_invoices WHERE id='$selected_id'"; + + $result = db_query($sql,"could not get recurrent invoice"); + $myrow = db_fetch($result); + + $_POST['description'] = $myrow["description"]; + $_POST['order_no'] = $myrow["order_no"]; + $_POST['debtor_no'] = $myrow["debtor_no"]; + $_POST['group_no'] = $myrow["group_no"]; + $_POST['days'] = $myrow["days"]; + $_POST['monthly'] = $myrow["monthly"]; + $_POST['begin'] = sql2date($myrow["begin"]); + $_POST['end'] = sql2date($myrow["end"]); + } + hidden("selected_id", $selected_id); +} + + +text_row_ex(_("Description:"), 'description', 50); + +templates_list_row(_("Template:"), 'order_no'); + +customer_list_row(_("Customer:"), 'debtor_no', null, " ", true); + +if ($_POST['debtor_no'] > 0) + customer_branches_list_row(_("Branch:"), $_POST['debtor_no'], 'group_no', null, false); +else + sales_groups_list_row(_("Sales Group:"), 'group_no', null, " "); + +small_amount_row(_("Days:"), 'days', null, null, null, 0); + +small_amount_row(_("Monthly:"), 'monthly', null, null, null, 0); + +date_row(_("Begin:"), 'begin'); + +date_row(_("End:"), 'end', null, null, 0, 0, 5); + +end_table(1); + +submit_add_or_update_center($selected_id == -1, '', true); + +end_form(); + +end_page(); +?> diff --git a/sales/manage/sales_groups.php b/sales/manage/sales_groups.php new file mode 100644 index 00000000..1e165779 --- /dev/null +++ b/sales/manage/sales_groups.php @@ -0,0 +1,131 @@ + 0) + { + $cancel_delete = 1; + display_error(_("Cannot delete this group because customers have been created using this group.")); + } + if ($cancel_delete == 0) + { + $sql="DELETE FROM ".TB_PREF."groups WHERE id='" . $selected_id . "'"; + db_query($sql,"could not delete sales group"); + + display_notification(_('Selected sales group has been deleted')); + } //end if Delete area + $Mode = 'RESET'; +} + +if ($Mode == 'RESET') +{ + $selected_id = -1; + unset($_POST); +} +//------------------------------------------------------------------------------------------------- + +$sql = "SELECT * FROM ".TB_PREF."groups ORDER BY description"; +$result = db_query($sql,"could not get groups"); + +start_form(); +start_table("$table_style width=40%"); +$th = array(_("Group Name"), "", ""); +table_header($th); +$k = 0; + +while ($myrow = db_fetch($result)) +{ + + alt_table_row_color($k); + + label_cell($myrow["description"]); + edit_button_cell("Edit".$myrow["id"], _("Edit")); + edit_button_cell("Delete".$myrow["id"], _("Delete")); + end_row(); +} + + +end_table(); +end_form(); +echo '
'; + +//------------------------------------------------------------------------------------------------- + +start_form(); + +start_table("$table_style2 width=40%"); + +if ($selected_id != -1) +{ + if ($Mode == 'Edit') { + //editing an existing area + $sql = "SELECT * FROM ".TB_PREF."groups WHERE id='$selected_id'"; + + $result = db_query($sql,"could not get group"); + $myrow = db_fetch($result); + + $_POST['description'] = $myrow["description"]; + } + hidden("selected_id", $selected_id); +} + +text_row_ex(_("Group Name:"), 'description', 30); + +end_table(1); + +submit_add_or_update_center($selected_id == -1, '', true); + +end_form(); + +end_page(); +?> diff --git a/sql/alter2.1.sql b/sql/alter2.1.sql index 153ccda8..48f286ef 100644 --- a/sql/alter2.1.sql +++ b/sql/alter2.1.sql @@ -1,3 +1,35 @@ +DROP TABLE IF EXISTS `0_groups`; + +CREATE TABLE `0_groups` ( + `id` int(11) NOT NULL auto_increment, + `description` varchar(60) NOT NULL default '', + PRIMARY KEY (`id`), + UNIQUE KEY `description` (`description`) +) TYPE=MyISAM AUTO_INCREMENT=1 ; + +INSERT INTO `0_groups` VALUES ('1', 'Small'); +INSERT INTO `0_groups` VALUES ('2', 'Medium'); +INSERT INTO `0_groups` VALUES ('3', 'Large'); + +DROP TABLE IF EXISTS `0_recurrent_invoices`; + +CREATE TABLE `0_recurrent_invoices` ( + `id` int(11) NOT NULL auto_increment, + `description` varchar(60) NOT NULL default '', + `order_no` int(11) NOT NULL default '0', + `debtor_no` int(11) NOT NULL default '0', + `group_no` int(11) NOT NULL default '0', + `days` int(11) NOT NULL default '0', + `monthly` int(11) NOT NULL default '0', + `begin` date NOT NULL default '0000-00-00', + `end` date NOT NULL default '0000-00-00', + `last_sent` date NOT NULL default '0000-00-00', + PRIMARY KEY (`id`), + UNIQUE KEY `description` (`description`) +) TYPE=InnoDB AUTO_INCREMENT=1 ; + +ALTER TABLE `0_cust_branch` ADD `group_no` int(11) NOT NULL default '0'; + ALTER TABLE `0_debtor_trans` ADD `dimension_id` int(11) NOT NULL default '0'; ALTER TABLE `0_debtor_trans` ADD `dimension2_id` int(11) NOT NULL default '0'; -- 2.30.2