function generate_number()
 {
     $return_value = '';
     $number_filed = array('num_suf');
     $rown = '';
     $n = $this->db->getRowCount($result);
     $query = 'SELECT num_suf';
     $query .= ' FROM purchaseorders';
     $query .= " WHERE deleted=0";
     $query .= " AND num_suf IS NOT NULL";
     $query .= " ORDER by num_suf ASC";
     $result = $this->db->query($query, true, " Error filling in additional detail fields: ");
     $n = $this->db->getRowCount($result);
     if ($n > 0) {
         while ($row = $this->db->fetchByAssoc($result)) {
             foreach ($number_filed as $num_field) {
                 for ($i = 0; $i < $n; $i++) {
                     $rown[$i] = $row[$num_field];
                 }
             }
         }
     }
     if ($rown != null) {
         $return_value = $rown;
         $number = PurchaseOrder::pnum_sort($return_value);
         $numb = $number[0] + 1;
     } else {
         $numb = 10000;
     }
     return $numb;
 }