Mysqli errors: Trying to access array offset on value of type bool. Fixed. Please...
[fa-stable.git] / sales / includes / db / sales_points_db.inc
index 55e579ef181c0107bddfb0e7e632a5cc7e8f6150..9537a913812e95b6abefaf21a738e2a5767bf94f 100644 (file)
@@ -30,12 +30,13 @@ function update_sales_point($id, $name, $location, $account, $cash, $credit)
        db_query($sql, "could not update sales type");                  
 }
 
-function get_all_sales_points()
+function get_all_sales_points($all=false)
 {
        $sql = "SELECT pos.*, loc.location_name, acc.bank_account_name FROM "
                .TB_PREF."sales_pos as pos
                LEFT JOIN ".TB_PREF."locations as loc on pos.pos_location=loc.loc_code
                LEFT JOIN ".TB_PREF."bank_accounts as acc on pos.pos_account=acc.id";
+       if (!$all) $sql .= " WHERE !pos.inactive";
        
        return db_query($sql, "could not get all POS definitions");
 } 
@@ -60,7 +61,7 @@ function get_sales_point_name($id)
        $result = db_query($sql, "could not get POS name");
        
        $row = db_fetch_row($result);
-       return $row[0];
+       return is_array($row) ? $row[0] : false;
 }
 
 function delete_sales_point($id)
@@ -69,4 +70,3 @@ function delete_sales_point($id)
        db_query($sql,"The point of sale record could not be deleted");
 }
 
-?>
\ No newline at end of file