prefix . NET360RECLAMACIONES_LEGACY_DB_PREFIX . '_peru_claims'; } public static function next_code() { global $wpdb; $year = wp_date('Y'); $like = 'REC-' . $year . '-%'; $table = self::table(); $count = (int) $wpdb->get_var( $wpdb->prepare( 'SELECT COUNT(*) FROM %i WHERE claim_code LIKE %s', $table, $like ) ); return 'REC-' . $year . '-' . str_pad( (string) ( $count + 1 ), 6, '0', STR_PAD_LEFT ); } }