Added inactive record support.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Wed, 22 Apr 2009 21:32:57 +0000 (21:32 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Wed, 22 Apr 2009 21:32:57 +0000 (21:32 +0000)
includes/data_checks.inc
sales/includes/db/credit_status_db.inc
sales/includes/db/sales_types_db.inc
sales/manage/credit_status.php
sales/manage/customer_branches.php
sales/manage/sales_groups.php
sales/manage/sales_people.php
sales/manage/sales_types.php

index 95bcb2ca68e5c5f16f29417e63769a99232cec8e..633daa87e43a400c9df7403e6ecb8ba62b9bfe49 100644 (file)
@@ -123,12 +123,14 @@ function check_db_has_movement_types($msg)
 
 function db_customer_has_branches($customer_id)
 {
-       return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."cust_branch WHERE debtor_no='$customer_id'");
+       return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."cust_branch "
+               ."WHERE debtor_no='$customer_id'");
 }
 
 function db_has_customer_branches()
 {
-       return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."cust_branch");
+       return check_empty_result("SELECT COUNT(*) FROM "
+               .TB_PREF."cust_branch WHERE !inactive");
 }
 
 function check_db_has_customer_branches($msg)
index 411cdfd5ad64b9a1ed5f962d6e00d029620117af..d59785a365cf5ad00dcbbc0471dc662030e4ddc5 100644 (file)
@@ -25,10 +25,11 @@ function update_credit_status($status_id, $description, $disallow_invoicing)
        db_query($sql, "could not update credit status");                       
 }
 
-function get_all_credit_status()
+function get_all_credit_status($all=false)
 {
        $sql = "SELECT * FROM ".TB_PREF."credit_status";
-       
+       if (!$all) $sql .= " WHERE !inactive";
+
        return db_query($sql, "could not get all credit status");
 } 
 
index f52374769a182de5a1079ec91f403d1af9f3bf5a..9e462bc2a26c60e9991e3911579b538eaa19dbb7 100644 (file)
@@ -24,9 +24,11 @@ function update_sales_type($id, $name, $tax_included, $factor)
        db_query($sql, "could not update sales type");                  
 }
 
-function get_all_sales_types()
+function get_all_sales_types($all=false)
 {
        $sql = "SELECT * FROM ".TB_PREF."sales_types";
+       if (!$all)
+               $sql .= " WHERE !inactive";
        
        return db_query($sql, "could not get all sales types");
 } 
index 20e6d117222bb1d55c6acda3f3a79dc64e2198a8..bab7f269e36552980c4b23dbeda0ced9f4513764 100644 (file)
@@ -88,15 +88,18 @@ if ($Mode == 'Delete')
 if ($Mode == 'RESET')
 {
        $selected_id = -1;
+       $sav = get_post('show_inactive');
        unset($_POST);
+       $_POST['show_inactive'] = $sav;
 }
 //-----------------------------------------------------------------------------------
 
-$result = get_all_credit_status();
+$result = get_all_credit_status(check_value('show_inactive'));
 
 start_form();
 start_table("$table_style width=40%");
 $th = array(_("Description"), _("Dissallow Invoices"),'','');
+inactive_control_column($th);
 table_header($th);
 
 $k = 0;
@@ -116,19 +119,18 @@ while ($myrow = db_fetch($result))
        
        label_cell($myrow["reason_description"]);
        label_cell($disallow_text);
+       inactive_control_cell($myrow["id"], $myrow["inactive"], 'credit_status', 'id');
        edit_button_cell("Edit".$myrow['id'], _("Edit"));
        delete_button_cell("Delete".$myrow['id'], _("Delete"));
        end_row();
 }
 
+inactive_control_row($th);
 end_table();
-end_form();
 echo '<br>';
 
 //-----------------------------------------------------------------------------------
 
-start_form();
-
 start_table($table_style2);
 
 if ($selected_id != -1) 
index 0e0fe1b9388cf9effbe48720e954bf3b2dcfa58b..37572a63490ceb5733cdf62b936a3a5c1a40cc5f 100644 (file)
@@ -168,7 +168,9 @@ if ($Mode == 'RESET' || get_post('_customer_id_update'))
 {
        $selected_id = -1;
        $cust_id = $_POST['customer_id'];
+       $inact = get_post('show_inactive');
        unset($_POST);
+       $_POST['show_inactive'] = $inact;
        $_POST['customer_id'] = $cust_id;
        $Ajax->activate('_page_body');
 }
@@ -176,7 +178,7 @@ start_form();
 
 echo "<center>" . _("Select a customer: ") . "&nbsp;&nbsp;";
 customer_list('customer_id', null, false, true);
-echo "</center><br><br>";
+echo "</center><br>";
 
 $num_branches = db_customer_has_branches($_POST['customer_id']);
 
@@ -191,13 +193,17 @@ if ($num_branches)
                AND ".TB_PREF."cust_branch.salesman=".TB_PREF."salesman.salesman_code
                AND ".TB_PREF."cust_branch.debtor_no = '" . $_POST['customer_id']. "'";
 
+       if (!check_value('show_inactive')) $sql .= " AND !".TB_PREF."cust_branch.inactive";
+
        $result = db_query($sql,"could not get customer branches");
 
        start_table("$table_style width=60%");
 
        $th = array(_("Name"), _("Contact"), _("Sales Person"), _("Area"),
                _("Phone No"), _("Fax No"), _("E-mail"), _("Tax Group"), "", "");
+       inactive_control_column($th);
        if (count($_SESSION['Context'])) $th[] = '';
+
        table_header($th);
 
        while ($myrow = db_fetch($result))
@@ -211,13 +217,16 @@ if ($num_branches)
                label_cell($myrow["fax"]);
                email_cell($myrow["email"]);
                label_cell($myrow["tax_group_name"]);
+               inactive_control_cell($myrow["branch_code"], $myrow["inactive"],
+                       'cust_branch', 'branch_code');
                if (count($_SESSION['Context']))
                        edit_button_cell("Select".$myrow["branch_code"], _("Select"));
                edit_button_cell("Edit".$myrow["branch_code"], _("Edit"));
                delete_button_cell("Delete".$myrow["branch_code"], _("Delete"));
                end_row();
        }
-       end_table();
+       inactive_control_row($th);
+       end_table(1);
        //END WHILE LIST LOOP
 }
 else
index 3fa4cc47913a64aac1981d47e8fbb73a2c3f565d..73b4467a3d5382c3efec42d88beafbf2a8b0ec77 100644 (file)
@@ -78,16 +78,22 @@ if ($Mode == 'Delete')
 if ($Mode == 'RESET')
 {
        $selected_id = -1;
+       $sav = get_post('show_inactive');
        unset($_POST);
+       if ($sav) $_POST['show_inactive'] = 1;
 }
 //-------------------------------------------------------------------------------------------------
 
-$sql = "SELECT * FROM ".TB_PREF."groups ORDER BY description";
+$sql = "SELECT * FROM ".TB_PREF."groups";
+if (!check_value('show_inactive')) $sql .= " WHERE !inactive";
+$sql .= " ORDER BY description";
 $result = db_query($sql,"could not get groups");
 
 start_form();
 start_table("$table_style width=30%");
 $th = array(_("Group Name"), "", "");
+inactive_control_column($th);
+
 table_header($th);
 $k = 0; 
 
@@ -97,20 +103,19 @@ while ($myrow = db_fetch($result))
        alt_table_row_color($k);
                
        label_cell($myrow["description"]);
+       inactive_control_cell($myrow["id"], $myrow["inactive"], 'groups', 'id');
        edit_button_cell("Edit".$myrow["id"], _("Edit"));
        delete_button_cell("Delete".$myrow["id"], _("Delete"));
        end_row();
 }
 
-
+inactive_control_row($th);
 end_table();
-end_form();
+
 echo '<br>';
 
 //-------------------------------------------------------------------------------------------------
 
-start_form();
-
 start_table($table_style2);
 
 if ($selected_id != -1) 
index d31799240c17294021ea9f08f63594df22a5b1fa..333fe8968f9a2ea25c50019f2e1cef1b6ebf7515 100644 (file)
@@ -105,16 +105,20 @@ if ($Mode == 'Delete')
 if ($Mode == 'RESET')
 {
        $selected_id = -1;
+       $sav = get_post('show_inactive');
        unset($_POST);
+       $_POST['show_inactive'] = $sav;
 }
 //------------------------------------------------------------------------------------------------
 
 $sql = "SELECT * FROM ".TB_PREF."salesman";
+if (!check_value('show_inactive')) $sql .= " WHERE !inactive";
 $result = db_query($sql,"could not get sales persons");
 
 start_form();
 start_table("$table_style width=60%");
 $th = array(_("Name"), _("Phone"), _("Fax"), _("Email"), _("Provision"), _("Break Pt."), _("Provision")." 2", "", "");
+inactive_control_column($th);
 table_header($th);
 
 $k = 0;
@@ -131,21 +135,20 @@ while ($myrow = db_fetch($result))
        label_cell(percent_format($myrow["provision"])." %", "nowrap align=right");
        amount_cell($myrow["break_pt"]);
        label_cell(percent_format($myrow["provision2"])." %", "nowrap align=right");
+       inactive_control_cell($myrow["salesman_code"], $myrow["inactive"],
+               'salesman', 'salesman_code');
        edit_button_cell("Edit".$myrow["salesman_code"], _("Edit"));
        delete_button_cell("Delete".$myrow["salesman_code"], _("Delete"));
        end_row();
 
 } //END WHILE LIST LOOP
 
+inactive_control_row($th);
 end_table();
-end_form();
 echo '<br>';
 
 //------------------------------------------------------------------------------------------------
 
-start_form();
-
-
 $_POST['salesman_email'] = "";
 if ($selected_id != -1) 
 {
index d7213335efde51d00ac1ba6cd545df4087d0838e..05a3166adb8b0618d06b0d80f3590c226c9d132f 100644 (file)
@@ -100,16 +100,19 @@ if ($Mode == 'Delete')
 if ($Mode == 'RESET')
 {
        $selected_id = -1;
+       $sav = get_post('show_inactive');
        unset($_POST);
+       $_POST['show_inactive'] = $sav;
 }
 //----------------------------------------------------------------------------------------------------
 
-$result = get_all_sales_types();
+$result = get_all_sales_types(check_value('show_inactive'));
 
 start_form();
 start_table("$table_style width=30%");
 
 $th = array (_('Type Name'), _('Factor'), _('Tax Incl'), '','');
+inactive_control_column($th);
 table_header($th);
 $k = 0;
 $base_sales = get_base_sales_type();
@@ -125,18 +128,18 @@ while ($myrow = db_fetch($result))
        if($myrow["id"] == $base_sales) $f = "<I>"._('Base')."</I>";
        label_cell($f);
        label_cell($myrow["tax_included"] ? _('Yes'):_('No'), 'align=center');
+       inactive_control_cell($myrow["id"], $myrow["inactive"], 'sales_types', 'id');
        edit_button_cell("Edit".$myrow['id'], _("Edit"));
        delete_button_cell("Delete".$myrow['id'], _("Delete"));
        end_row();
 }
-
+inactive_control_row($th);
 end_table();
-end_form();
+
 display_note(_("Marked sales type is the company base pricelist for prices calculations."), 0, 0, "class='overduefg'");
 
 //----------------------------------------------------------------------------------------------------
 
-start_form();
  if (!isset($_POST['tax_included']))
        $_POST['tax_included'] = 0;
  if (!isset($_POST['base']))